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

MultipleChecksOnAPropertyTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 49
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testChecksAllGivenCheckers() 0 47 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\ApiCompare\Comparator\BackwardsCompatibility\PropertyBased;
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\PropertyBased\MultipleChecksOnAProperty;
12
use Roave\ApiCompare\Comparator\BackwardsCompatibility\PropertyBased\PropertyBased;
13
use Roave\BetterReflection\Reflection\ReflectionProperty;
14
15
/**
16
 * @covers \Roave\ApiCompare\Comparator\BackwardsCompatibility\PropertyBased\MultipleChecksOnAProperty
17
 */
18
final class MultipleChecksOnAPropertyTest extends TestCase
19
{
20
    public function testChecksAllGivenCheckers() : void
21
    {
22
        /** @var PropertyBased|MockObject $checker1 */
23
        $checker1 = $this->createMock(PropertyBased::class);
24
        /** @var PropertyBased|MockObject $checker2 */
25
        $checker2 = $this->createMock(PropertyBased::class);
26
        /** @var PropertyBased|MockObject $checker3 */
27
        $checker3 = $this->createMock(PropertyBased::class);
28
29
        $multiCheck = new MultipleChecksOnAProperty($checker1, $checker2, $checker3);
30
31
        /** @var ReflectionProperty|MockObject $from */
32
        $from = $this->createMock(ReflectionProperty::class);
33
        /** @var ReflectionProperty|MockObject $to */
34
        $to = $this->createMock(ReflectionProperty::class);
35
36
        $checker1
37
            ->expects(self::once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on Roave\ApiCompare\Compara...ertyBased\PropertyBased. ( Ignorable by Annotation )

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

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