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