|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace RoaveTest\BackwardCompatibility\DetectChanges\BCBreak\ClassBased; |
|
6
|
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
|
8
|
|
|
use Roave\BackwardCompatibility\Change; |
|
9
|
|
|
use Roave\BackwardCompatibility\DetectChanges\BCBreak\ClassBased\MethodRemoved; |
|
10
|
|
|
use Roave\BetterReflection\BetterReflection; |
|
11
|
|
|
use Roave\BetterReflection\Reflection\ReflectionClass; |
|
12
|
|
|
use Roave\BetterReflection\Reflector\ClassReflector; |
|
13
|
|
|
use Roave\BetterReflection\SourceLocator\Type\SingleFileSourceLocator; |
|
14
|
|
|
use function array_map; |
|
15
|
|
|
use function iterator_to_array; |
|
16
|
|
|
|
|
17
|
|
|
final class MethodRemovedTest extends TestCase |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @dataProvider classesToBeTested |
|
21
|
|
|
* |
|
22
|
|
|
* @param string[] $expectedMessages |
|
23
|
|
|
*/ |
|
24
|
|
|
public function testDiffs( |
|
25
|
|
|
ReflectionClass $fromClass, |
|
26
|
|
|
ReflectionClass $toClass, |
|
27
|
|
|
array $expectedMessages |
|
28
|
|
|
) : void { |
|
29
|
|
|
$changes = (new MethodRemoved()) |
|
30
|
|
|
->__invoke($fromClass, $toClass); |
|
31
|
|
|
|
|
32
|
|
|
self::assertSame( |
|
33
|
|
|
$expectedMessages, |
|
34
|
|
|
array_map(function (Change $change) : string { |
|
35
|
|
|
return $change->__toString(); |
|
36
|
|
|
}, iterator_to_array($changes)) |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** @return (string[]|ReflectionClass)[][] */ |
|
41
|
|
|
public function classesToBeTested() : array |
|
42
|
|
|
{ |
|
43
|
|
|
$locator = (new BetterReflection())->astLocator(); |
|
44
|
|
|
|
|
45
|
|
|
return [ |
|
46
|
|
|
'RoaveTestAsset\\ClassWithMethodsBeingRemoved' => [ |
|
47
|
|
|
(new ClassReflector(new SingleFileSourceLocator( |
|
48
|
|
|
__DIR__ . '/../../../../asset/api/old/ClassWithMethodsBeingRemoved.php', |
|
49
|
|
|
$locator |
|
50
|
|
|
)))->reflect('RoaveTestAsset\\ClassWithMethodsBeingRemoved'), |
|
51
|
|
|
(new ClassReflector(new SingleFileSourceLocator( |
|
52
|
|
|
__DIR__ . '/../../../../asset/api/new/ClassWithMethodsBeingRemoved.php', |
|
53
|
|
|
$locator |
|
54
|
|
|
)))->reflect('RoaveTestAsset\\ClassWithMethodsBeingRemoved'), |
|
55
|
|
|
[ |
|
56
|
|
|
'[BC] REMOVED: Method RoaveTestAsset\ClassWithMethodsBeingRemoved#removedPublicMethod() was removed', |
|
57
|
|
|
'[BC] REMOVED: Method RoaveTestAsset\ClassWithMethodsBeingRemoved#removedProtectedMethod() was removed', |
|
58
|
|
|
], |
|
59
|
|
|
], |
|
60
|
|
|
]; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|