Skip to content

Commit

Permalink
Add a mocked GitHub repository to streamline testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nbish11 committed Jul 7, 2018
1 parent c6c9e45 commit 82a0aef
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/MockRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php declare(strict_types=1);

namespace ins0\GitHub;

use Generator;

/**
* Mocks responses from GitHub's API. Used for testing purposes only.
*/
final class MockRepository extends Repository
{
public function __construct(string $repository = '', string $token = null)
{
$this->releases = [];
$this->issues = [];
$this->issueEvents = [];
}

public function getReleases(array $params = []): Generator
{
yield from $this->releases;
}

public function getIssues(array $params = []): Generator
{
yield from $this->issues;
}

public function getIssueEvents(int $number): Generator
{
yield from $this->issueEvents[$number];
}
}

0 comments on commit 82a0aef

Please sign in to comment.