Completed
Push — master ( aaccd5...c6e65b )
by Jonathan
10s
created

IssueFetcherTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ChangelogGenerator\Tests;
6
7
use ChangelogGenerator\IssueClient;
8
use ChangelogGenerator\IssueClientResponse;
9
use ChangelogGenerator\IssueFetcher;
10
use PHPUnit\Framework\TestCase;
11
12
final class IssueFetcherTest extends TestCase
13
{
14
    /** @var \PHPUnit_Framework_MockObject_MockObject|IssueClient */
15
    private $issueClient;
16
17
    /** @var IssueFetcher */
18
    private $issueFetcher;
19
20
    public function testFetchMilestoneIssues() : void
21
    {
22
        $response1 = new IssueClientResponse(['items' => [1]], 'https://www.google.com');
23
        $response2 = new IssueClientResponse(['items' => [2]], null);
24
25
        $this->issueClient->expects($this->at(0))
26
            ->method('execute')
27
            ->with('https://api.github.com/search/issues?q=milestone%3A%221.0%22+repo%3Ajwage%2Fchangelog-generator+state%3Aclosed')
28
            ->willReturn($response1);
29
30
        $this->issueClient->expects($this->at(1))
31
            ->method('execute')
32
            ->with('https://www.google.com')
33
            ->willReturn($response2);
34
35
        $issues = $this->issueFetcher->fetchMilestoneIssues('jwage', 'changelog-generator', '1.0');
36
37
        self::assertEquals([1, 2], $issues);
38
    }
39
40
    protected function setUp() : void
41
    {
42
        $this->issueClient = $this->createMock(IssueClient::class);
43
44
        $this->issueFetcher = new IssueFetcher($this->issueClient);
45
    }
46
}
47