IssueFetcherTest::testFetchMilestoneIssues()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 13
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 24
rs 9.8333
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ChangelogGenerator\Tests;
6
7
use ChangelogGenerator\ChangelogConfig;
8
use ChangelogGenerator\IssueClient;
9
use ChangelogGenerator\IssueClientResponse;
10
use ChangelogGenerator\IssueFetcher;
11
use PHPUnit\Framework\MockObject\MockObject;
12
use PHPUnit\Framework\TestCase;
13
14
final class IssueFetcherTest extends TestCase
15
{
16
    /** @var MockObject&IssueClient */
17
    private $issueClient;
18
19
    private IssueFetcher $issueFetcher;
20
21
    public function testFetchMilestoneIssues(): void
22
    {
23
        $response1 = new IssueClientResponse(['items' => [1]], 'https://www.google.com');
24
        $response2 = new IssueClientResponse(['items' => [2]], null);
25
26
        $this->issueClient->method('execute')
0 ignored issues
show
Bug introduced by
The method method() does not exist on ChangelogGenerator\IssueClient. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $this->issueClient->/** @scrutinizer ignore-call */ 
27
                            method('execute')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
            ->willReturnMap([
28
                [
29
                    'https://api.github.com/search/issues?q=milestone%3A%221.0%22+repo%3Ajwage%2Fchangelog-generator+state%3Aclosed',
30
                    null,
31
                    $response1,
32
                ],
33
                [
34
                    'https://www.google.com',
35
                    null,
36
                    $response2,
37
                ],
38
            ]);
39
40
        $changelogConfig = new ChangelogConfig('jwage', 'changelog-generator', '1.0', []);
41
42
        $issues = $this->issueFetcher->fetchMilestoneIssues($changelogConfig);
43
44
        self::assertSame([1, 2], $issues);
45
    }
46
47
    protected function setUp(): void
48
    {
49
        $this->issueClient = $this->createMock(IssueClient::class);
50
51
        $this->issueFetcher = new IssueFetcher($this->issueClient);
52
    }
53
}
54