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

IssueFetcherTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testFetchMilestoneIssues() 0 18 1
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