MultipleChecksOnAFunctionTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testChecksAllGivenCheckers() 0 36 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\BackwardCompatibility\DetectChanges\BCBreak\FunctionBased;
6
7
use PHPUnit\Framework\TestCase;
8
use Roave\BackwardCompatibility\Change;
9
use Roave\BackwardCompatibility\Changes;
10
use Roave\BackwardCompatibility\DetectChanges\BCBreak\FunctionBased\FunctionBased;
11
use Roave\BackwardCompatibility\DetectChanges\BCBreak\FunctionBased\MultipleChecksOnAFunction;
12
use Roave\BetterReflection\Reflection\ReflectionFunctionAbstract;
13
use RoaveTest\BackwardCompatibility\Assertion;
14
15
/**
16
 * @covers \Roave\BackwardCompatibility\DetectChanges\BCBreak\FunctionBased\MultipleChecksOnAFunction
17
 */
18
final class MultipleChecksOnAFunctionTest extends TestCase
19
{
20
    public function testChecksAllGivenCheckers() : void
21
    {
22
        $checker1 = $this->createMock(FunctionBased::class);
23
        $checker2 = $this->createMock(FunctionBased::class);
24
        $checker3 = $this->createMock(FunctionBased::class);
25
26
        $multiCheck = new MultipleChecksOnAFunction($checker1, $checker2, $checker3);
27
28
        $from = $this->createMock(ReflectionFunctionAbstract::class);
29
        $to   = $this->createMock(ReflectionFunctionAbstract::class);
30
31
        $checker1
32
            ->expects(self::once())
33
            ->method('__invoke')
34
            ->with($from, $to)
35
            ->willReturn(Changes::fromList(Change::added('1', true)));
36
37
        $checker2
38
            ->expects(self::once())
39
            ->method('__invoke')
40
            ->with($from, $to)
41
            ->willReturn(Changes::fromList(Change::added('2', true)));
42
43
        $checker3
44
            ->expects(self::once())
45
            ->method('__invoke')
46
            ->with($from, $to)
47
            ->willReturn(Changes::fromList(Change::added('3', true)));
48
49
        Assertion::assertChangesEqual(
50
            Changes::fromList(
51
                Change::added('1', true),
52
                Change::added('2', true),
53
                Change::added('3', true)
54
            ),
55
            $multiCheck->__invoke($from, $to)
56
        );
57
    }
58
}
59