Passed
Pull Request — master (#38)
by Marco
02:55
created

MultiClassBasedTest::testFoo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 47
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 47
c 0
b 0
f 0
rs 9.0303
cc 1
eloc 30
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\ApiCompare\Comparator\BackwardsCompatibility\ClassBased;
6
7
use PHPUnit\Framework\MockObject\MockObject;
8
use PHPUnit\Framework\TestCase;
9
use Roave\ApiCompare\Change;
10
use Roave\ApiCompare\Changes;
11
use Roave\ApiCompare\Comparator\BackwardsCompatibility\ClassBased\ClassBased;
12
use Roave\ApiCompare\Comparator\BackwardsCompatibility\ClassBased\MultiClassBased;
13
use Roave\BetterReflection\Reflection\ReflectionClass;
14
15
final class MultiClassBasedTest extends TestCase
16
{
17
    public function testChecksAllGivenCheckers() : void
18
    {
19
        /** @var ClassBased|MockObject $checker1 */
20
        $checker1 = $this->createMock(ClassBased::class);
21
        /** @var ClassBased|MockObject $checker2 */
22
        $checker2 = $this->createMock(ClassBased::class);
23
        /** @var ClassBased|MockObject $checker3 */
24
        $checker3 = $this->createMock(ClassBased::class);
25
26
        $multiCheck = new MultiClassBased($checker1, $checker2, $checker3);
27
28
        /** @var ReflectionClass|MockObject $from */
29
        $from = $this->createMock(ReflectionClass::class);
30
        /** @var ReflectionClass|MockObject $to */
31
        $to = $this->createMock(ReflectionClass::class);
32
33
        $checker1
34
            ->expects(self::once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on Roave\ApiCompare\Compara...y\ClassBased\ClassBased. ( Ignorable by Annotation )

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

34
            ->/** @scrutinizer ignore-call */ 
35
              expects(self::once())

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...
35
            ->method('compare')
36
            ->with($from, $to)
37
            ->willReturn(Changes::fromArray([
38
                Change::added('1', true),
39
            ]));
40
41
        $checker2
42
            ->expects(self::once())
43
            ->method('compare')
44
            ->with($from, $to)
45
            ->willReturn(Changes::fromArray([
46
                Change::added('2', true),
47
            ]));
48
49
        $checker3
50
            ->expects(self::once())
51
            ->method('compare')
52
            ->with($from, $to)
53
            ->willReturn(Changes::fromArray([
54
                Change::added('3', true),
55
            ]));
56
57
        $this->assertEquals(
58
            Changes::fromArray([
59
                Change::added('1', true),
60
                Change::added('2', true),
61
                Change::added('3', true),
62
            ]),
63
            $multiCheck->compare($from, $to)
64
        );
65
    }
66
}
67