1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace RoaveTest\ApiCompare\Comparator\BackwardsCompatibility\MethodBased; |
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\MethodBased\MethodBased; |
12
|
|
|
use Roave\ApiCompare\Comparator\BackwardsCompatibility\MethodBased\MultiMethodBased; |
13
|
|
|
use Roave\BetterReflection\Reflection\ReflectionMethod; |
14
|
|
|
|
15
|
|
|
final class MultiMethodBasedTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
public function testChecksAllGivenCheckers() : void |
18
|
|
|
{ |
19
|
|
|
/** @var MethodBased|MockObject $checker1 */ |
20
|
|
|
$checker1 = $this->createMock(MethodBased::class); |
21
|
|
|
/** @var MethodBased|MockObject $checker2 */ |
22
|
|
|
$checker2 = $this->createMock(MethodBased::class); |
23
|
|
|
/** @var MethodBased|MockObject $checker3 */ |
24
|
|
|
$checker3 = $this->createMock(MethodBased::class); |
25
|
|
|
|
26
|
|
|
$multiCheck = new MultiMethodBased($checker1, $checker2, $checker3); |
27
|
|
|
|
28
|
|
|
/** @var ReflectionMethod|MockObject $from */ |
29
|
|
|
$from = $this->createMock(ReflectionMethod::class); |
30
|
|
|
/** @var ReflectionMethod|MockObject $to */ |
31
|
|
|
$to = $this->createMock(ReflectionMethod::class); |
32
|
|
|
|
33
|
|
|
$checker1 |
34
|
|
|
->expects(self::once()) |
|
|
|
|
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
|
|
|
|
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.