1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace RoaveTest\BackwardCompatibility\DetectChanges\BCBreak\MethodBased; |
6
|
|
|
|
7
|
|
|
use Exception; |
8
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
use Roave\BackwardCompatibility\Change; |
11
|
|
|
use Roave\BackwardCompatibility\Changes; |
12
|
|
|
use Roave\BackwardCompatibility\DetectChanges\BCBreak\MethodBased\MethodBased; |
13
|
|
|
use Roave\BackwardCompatibility\DetectChanges\BCBreak\MethodBased\SkipMethodBasedErrors; |
14
|
|
|
use Roave\BetterReflection\Reflection\ReflectionMethod; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @covers \Roave\BackwardCompatibility\DetectChanges\BCBreak\MethodBased\SkipMethodBasedErrors |
18
|
|
|
*/ |
19
|
|
|
final class SkipMethodBasedErrorsTest extends TestCase |
20
|
|
|
{ |
21
|
|
|
/** @var MethodBased|MockObject */ |
22
|
|
|
private $next; |
23
|
|
|
|
24
|
|
|
/** @var SkipMethodBasedErrors */ |
25
|
|
|
private $check; |
26
|
|
|
|
27
|
|
|
protected function setUp() : void |
28
|
|
|
{ |
29
|
|
|
$this->next = $this->createMock(MethodBased::class); |
30
|
|
|
$this->check = new SkipMethodBasedErrors($this->next); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testWillForwardChecks() : void |
34
|
|
|
{ |
35
|
|
|
$fromMethod = $this->createMock(ReflectionMethod::class); |
36
|
|
|
$toMethod = $this->createMock(ReflectionMethod::class); |
37
|
|
|
$expectedChanges = Changes::fromList(Change::added( |
38
|
|
|
uniqid('foo', true), |
39
|
|
|
true |
40
|
|
|
)); |
41
|
|
|
|
42
|
|
|
$this |
43
|
|
|
->next |
44
|
|
|
->expects(self::once()) |
|
|
|
|
45
|
|
|
->method('__invoke') |
46
|
|
|
->with($fromMethod, $toMethod) |
47
|
|
|
->willReturn($expectedChanges); |
48
|
|
|
|
49
|
|
|
self::assertEquals($expectedChanges, $this->check->__invoke($fromMethod, $toMethod)); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testWillCollectFailures() : void |
53
|
|
|
{ |
54
|
|
|
$fromMethod = $this->createMock(ReflectionMethod::class); |
55
|
|
|
$toMethod = $this->createMock(ReflectionMethod::class); |
56
|
|
|
$exception = new Exception(); |
57
|
|
|
|
58
|
|
|
$this |
59
|
|
|
->next |
60
|
|
|
->expects(self::once()) |
61
|
|
|
->method('__invoke') |
62
|
|
|
->with($fromMethod, $toMethod) |
63
|
|
|
->willThrowException($exception); |
64
|
|
|
|
65
|
|
|
self::assertEquals( |
66
|
|
|
Changes::fromList(Change::skippedDueToFailure($exception)), |
67
|
|
|
$this->check->__invoke($fromMethod, $toMethod) |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
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.