1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ProxyManagerTest\Exception; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use ProxyManager\Exception\InvalidProxiedClassException; |
9
|
|
|
use ProxyManagerTestAsset\BaseInterface; |
10
|
|
|
use ProxyManagerTestAsset\ClassWithAbstractProtectedMethod; |
11
|
|
|
use ProxyManagerTestAsset\ClassWithAbstractPublicMethod; |
12
|
|
|
use ProxyManagerTestAsset\ClassWithProtectedMethod; |
13
|
|
|
use ProxyManagerTestAsset\FinalClass; |
14
|
|
|
use ReflectionClass; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Tests for {@see \ProxyManager\Exception\InvalidProxiedClassException} |
18
|
|
|
* |
19
|
|
|
* @covers \ProxyManager\Exception\InvalidProxiedClassException |
20
|
|
|
* @group Coverage |
21
|
|
|
*/ |
22
|
|
|
final class InvalidProxiedClassExceptionTest extends TestCase |
23
|
|
|
{ |
24
|
|
|
public function testInterfaceNotSupported() : void |
25
|
|
|
{ |
26
|
|
|
self::assertSame( |
|
|
|
|
27
|
|
|
'Provided interface "ProxyManagerTestAsset\BaseInterface" cannot be proxied', |
28
|
|
|
InvalidProxiedClassException::interfaceNotSupported( |
29
|
|
|
new ReflectionClass(BaseInterface::class) |
30
|
|
|
)->getMessage() |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testFinalClassNotSupported() : void |
35
|
|
|
{ |
36
|
|
|
self::assertSame( |
|
|
|
|
37
|
|
|
'Provided class "ProxyManagerTestAsset\FinalClass" is final and cannot be proxied', |
38
|
|
|
InvalidProxiedClassException::finalClassNotSupported( |
39
|
|
|
new ReflectionClass(FinalClass::class) |
40
|
|
|
)->getMessage() |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testAbstractProtectedMethodsNotSupported() : void |
45
|
|
|
{ |
46
|
|
|
self::assertSame( |
|
|
|
|
47
|
|
|
'Provided class "ProxyManagerTestAsset\ClassWithAbstractProtectedMethod" has following protected abstract' |
48
|
|
|
. ' methods, and therefore cannot be proxied:' . "\n" |
49
|
|
|
. 'ProxyManagerTestAsset\ClassWithAbstractProtectedMethod::protectedAbstractMethod', |
50
|
|
|
InvalidProxiedClassException::abstractProtectedMethodsNotSupported( |
51
|
|
|
new ReflectionClass(ClassWithAbstractProtectedMethod::class) |
52
|
|
|
)->getMessage() |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testProtectedMethodsNotSupported() : void |
57
|
|
|
{ |
58
|
|
|
self::assertSame( |
|
|
|
|
59
|
|
|
'Provided class "ProxyManagerTestAsset\ClassWithProtectedMethod" has following protected abstract' |
60
|
|
|
. ' methods, and therefore cannot be proxied:' . "\n", |
61
|
|
|
InvalidProxiedClassException::abstractProtectedMethodsNotSupported( |
62
|
|
|
new ReflectionClass(ClassWithProtectedMethod::class) |
63
|
|
|
)->getMessage() |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function testAbstractPublicMethodsNotSupported() : void |
68
|
|
|
{ |
69
|
|
|
self::assertSame( |
|
|
|
|
70
|
|
|
'Provided class "ProxyManagerTestAsset\ClassWithAbstractPublicMethod" has following protected abstract' |
71
|
|
|
. ' methods, and therefore cannot be proxied:' . "\n", |
72
|
|
|
InvalidProxiedClassException::abstractProtectedMethodsNotSupported( |
73
|
|
|
new ReflectionClass(ClassWithAbstractPublicMethod::class) |
74
|
|
|
)->getMessage() |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
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.