Passed
Pull Request — master (#50)
by Marco
02:36
created

MultipleChecksOnAMethodTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B testChecksAllGivenCheckers() 0 41 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\BackwardCompatibility\DetectChanges\BCBreak\MethodBased;
6
7
use PHPUnit\Framework\MockObject\MockObject;
8
use PHPUnit\Framework\TestCase;
9
use Roave\BackwardCompatibility\Change;
10
use Roave\BackwardCompatibility\Changes;
11
use Roave\BackwardCompatibility\DetectChanges\BCBreak\MethodBased\MethodBased;
12
use Roave\BackwardCompatibility\DetectChanges\BCBreak\MethodBased\MultipleChecksOnAMethod;
13
use Roave\BetterReflection\Reflection\ReflectionMethod;
14
15
/**
16
 * @covers \Roave\BackwardCompatibility\DetectChanges\BCBreak\MethodBased\MultipleChecksOnAMethod
17
 */
18
final class MultipleChecksOnAMethodTest extends TestCase
19
{
20
    public function testChecksAllGivenCheckers() : void
21
    {
22
        /** @var MethodBased|MockObject $checker1 */
23
        $checker1 = $this->createMock(MethodBased::class);
24
        /** @var MethodBased|MockObject $checker2 */
25
        $checker2 = $this->createMock(MethodBased::class);
26
        /** @var MethodBased|MockObject $checker3 */
27
        $checker3 = $this->createMock(MethodBased::class);
28
29
        $multiCheck = new MultipleChecksOnAMethod($checker1, $checker2, $checker3);
30
31
        /** @var ReflectionMethod|MockObject $from */
32
        $from = $this->createMock(ReflectionMethod::class);
33
        /** @var ReflectionMethod|MockObject $to */
34
        $to = $this->createMock(ReflectionMethod::class);
35
36
        $checker1
37
            ->expects(self::once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on Roave\BackwardCompatibil...MethodBased\MethodBased. ( 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('__invoke')
39
            ->with($from, $to)
40
            ->willReturn(Changes::fromList(Change::added('1', true)));
41
42
        $checker2
43
            ->expects(self::once())
44
            ->method('__invoke')
45
            ->with($from, $to)
46
            ->willReturn(Changes::fromList(Change::added('2', true)));
47
48
        $checker3
49
            ->expects(self::once())
50
            ->method('__invoke')
51
            ->with($from, $to)
52
            ->willReturn(Changes::fromList(Change::added('3', true)));
53
54
        $this->assertEquals(
55
            Changes::fromList(
56
                Change::added('1', true),
57
                Change::added('2', true),
58
                Change::added('3', true)
59
            ),
60
            $multiCheck->__invoke($from, $to)
61
        );
62
    }
63
}
64