1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace UsageFinder\Tests; |
6
|
|
|
|
7
|
|
|
use InvalidArgumentException; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
use UsageFinder\ClassMethodReference; |
10
|
|
|
|
11
|
|
|
final class ClassMethodReferenceTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
public function testGetName() : void |
14
|
|
|
{ |
15
|
|
|
self::assertSame( |
|
|
|
|
16
|
|
|
'Doctrine\Common\Collections\Collection::slice', |
|
|
|
|
17
|
|
|
(new ClassMethodReference('Doctrine\Common\Collections\Collection::slice'))->getName() |
18
|
|
|
); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function testGetClassName() : void |
22
|
|
|
{ |
23
|
|
|
self::assertSame( |
|
|
|
|
24
|
|
|
'Doctrine\Common\Collections\Collection', |
|
|
|
|
25
|
|
|
(new ClassMethodReference('Doctrine\Common\Collections\Collection::slice'))->getClassName() |
26
|
|
|
); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testGetMethodName() : void |
30
|
|
|
{ |
31
|
|
|
self::assertSame( |
|
|
|
|
32
|
|
|
'slice', |
|
|
|
|
33
|
|
|
(new ClassMethodReference('Doctrine\Common\Collections\Collection::slice'))->getMethodName() |
34
|
|
|
); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @dataProvider provideForTestInvalidClassMethodReference |
39
|
|
|
*/ |
40
|
|
|
public function testInvalidClassMethodReference(string $input, string $message) : void |
41
|
|
|
{ |
42
|
|
|
self::expectException(InvalidArgumentException::class); |
|
|
|
|
43
|
|
|
self::expectExceptionMessage($message); |
|
|
|
|
44
|
|
|
|
45
|
|
|
new ClassMethodReference($input); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return array<int, array<int, string>> |
50
|
|
|
*/ |
51
|
|
|
public function provideForTestInvalidClassMethodReference() : array |
52
|
|
|
{ |
53
|
|
|
return [ |
54
|
|
|
[ |
55
|
|
|
'', |
56
|
|
|
'Invalid ClassMethodReference, empty string given. Format must be ClassName::methodName.', |
57
|
|
|
], |
58
|
|
|
[ |
59
|
|
|
'Doctrine\Common\Collections\Collection::', |
60
|
|
|
'You must specify a method name to find. "Doctrine\Common\Collections\Collection::" given.', |
61
|
|
|
], |
62
|
|
|
[ |
63
|
|
|
'Doctrine\Common\Collections\Collection:: ', |
64
|
|
|
'You must specify a method name to find. "Doctrine\Common\Collections\Collection:: " given.', |
65
|
|
|
], |
66
|
|
|
[ |
67
|
|
|
'Doctrine\Common\Collections\Collection', |
68
|
|
|
'Invalid ClassMethodReference, "Doctrine\Common\Collections\Collection" given. Format must be ClassName::methodName.', |
69
|
|
|
], |
70
|
|
|
]; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|