Completed
Pull Request — master (#348)
by Marco
04:48
created

testProtectedMethodsNotSupported()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license.
17
 */
18
19
declare(strict_types=1);
20
21
namespace ProxyManagerTest\Exception;
22
23
use PHPUnit_Framework_TestCase;
24
use ProxyManager\Exception\InvalidProxiedClassException;
25
use ProxyManagerTestAsset\BaseInterface;
26
use ProxyManagerTestAsset\ClassWithAbstractProtectedMethod;
27
use ProxyManagerTestAsset\ClassWithAbstractPublicMethod;
28
use ProxyManagerTestAsset\ClassWithProtectedMethod;
29
use ProxyManagerTestAsset\FinalClass;
30
use ReflectionClass;
31
32
/**
33
 * Tests for {@see \ProxyManager\Exception\InvalidProxiedClassException}
34
 *
35
 * @author Marco Pivetta <[email protected]>
36
 * @license MIT
37
 *
38
 * @covers \ProxyManager\Exception\InvalidProxiedClassException
39
 * @group Coverage
40
 */
41
class InvalidProxiedClassExceptionTest extends PHPUnit_Framework_TestCase
42
{
43
    public function testInterfaceNotSupported() : void
44
    {
45
        self::assertSame(
46
            'Provided interface "ProxyManagerTestAsset\BaseInterface" cannot be proxied',
47
            InvalidProxiedClassException::interfaceNotSupported(
48
                new ReflectionClass(BaseInterface::class)
49
            )->getMessage()
50
        );
51
    }
52
53
    public function testFinalClassNotSupported() : void
54
    {
55
        self::assertSame(
56
            'Provided class "ProxyManagerTestAsset\FinalClass" is final and cannot be proxied',
57
            InvalidProxiedClassException::finalClassNotSupported(
58
                new ReflectionClass(FinalClass::class)
59
            )->getMessage()
60
        );
61
    }
62
63
    public function testAbstractProtectedMethodsNotSupported() : void
64
    {
65
        self::assertSame(
66
            'Provided class "ProxyManagerTestAsset\ClassWithAbstractProtectedMethod" has following protected abstract'
67
            . ' methods, and therefore cannot be proxied:' . "\n"
68
            . 'ProxyManagerTestAsset\ClassWithAbstractProtectedMethod::protectedAbstractMethod',
69
            InvalidProxiedClassException::abstractProtectedMethodsNotSupported(
70
                new ReflectionClass(ClassWithAbstractProtectedMethod::class)
71
            )->getMessage()
72
        );
73
    }
74
75
    public function testProtectedMethodsNotSupported() : void
76
    {
77
        self::assertSame(
78
            'Provided class "ProxyManagerTestAsset\ClassWithProtectedMethod" has following protected abstract'
79
            . ' methods, and therefore cannot be proxied:' . "\n",
80
            InvalidProxiedClassException::abstractProtectedMethodsNotSupported(
81
                new ReflectionClass(ClassWithProtectedMethod::class)
82
            )->getMessage()
83
        );
84
    }
85
86
    public function testAbstractPublicMethodsNotSupported() : void
87
    {
88
        self::assertSame(
89
            'Provided class "ProxyManagerTestAsset\ClassWithAbstractPublicMethod" has following protected abstract'
90
            . ' methods, and therefore cannot be proxied:' . "\n",
91
            InvalidProxiedClassException::abstractProtectedMethodsNotSupported(
92
                new ReflectionClass(ClassWithAbstractPublicMethod::class)
93
            )->getMessage()
94
        );
95
    }
96
}
97