1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
<?php
declare(strict_types=1);
namespace ProxyManagerTest\Exception;
use PHPUnit\Framework\TestCase;
use ProxyManager\Exception\UnsupportedProxiedClassException;
use ProxyManager\ProxyGenerator\Util\Properties;
use ProxyManagerTestAsset\ClassWithMixedTypedProperties;
use ProxyManagerTestAsset\ClassWithPrivateProperties;
use ReflectionClass;
use ReflectionProperty;
/**
* Tests for {@see \ProxyManager\Exception\UnsupportedProxiedClassException}
*
* @covers \ProxyManager\Exception\UnsupportedProxiedClassException
* @group Coverage
*/
final class UnsupportedProxiedClassExceptionTest extends TestCase
{
public function testUnsupportedLocalizedReflectionProperty(): void
{
self::assertSame(
'Provided reflection property "property0" of class "' . ClassWithPrivateProperties::class
. '" is private and cannot be localized in PHP 5.3',
UnsupportedProxiedClassException::unsupportedLocalizedReflectionProperty(
new ReflectionProperty(ClassWithPrivateProperties::class, 'property0')
)->getMessage()
);
}
/**
* @requires PHP 7.4
*/
public function testNonReferenceableLocalizedReflectionProperties(): void
{
$reflectionClass = new ReflectionClass(ClassWithMixedTypedProperties::class);
self::assertSame(
'Cannot create references for following properties of class '
. ClassWithMixedTypedProperties::class
. ': publicBoolPropertyWithoutDefaultValue, '
. 'publicIntPropertyWithoutDefaultValue, '
. 'publicFloatPropertyWithoutDefaultValue, '
. 'publicStringPropertyWithoutDefaultValue, '
. 'publicArrayPropertyWithoutDefaultValue, '
. 'publicIterablePropertyWithoutDefaultValue, '
. 'publicObjectProperty, publicClassProperty, '
. 'protectedBoolPropertyWithoutDefaultValue, '
. 'protectedIntPropertyWithoutDefaultValue, '
. 'protectedFloatPropertyWithoutDefaultValue, '
. 'protectedStringPropertyWithoutDefaultValue, '
. 'protectedArrayPropertyWithoutDefaultValue, '
. 'protectedIterablePropertyWithoutDefaultValue, '
. 'protectedObjectProperty, protectedClassProperty, '
. 'privateBoolPropertyWithoutDefaultValue, '
. 'privateIntPropertyWithoutDefaultValue, '
. 'privateFloatPropertyWithoutDefaultValue, '
. 'privateStringPropertyWithoutDefaultValue, '
. 'privateArrayPropertyWithoutDefaultValue, '
. 'privateIterablePropertyWithoutDefaultValue, '
. 'privateObjectProperty, '
. 'privateClassProperty',
UnsupportedProxiedClassException::nonReferenceableLocalizedReflectionProperties(
$reflectionClass,
Properties::fromReflectionClass($reflectionClass)
->onlyNonReferenceableProperties()
->onlyInstanceProperties()
)->getMessage()
);
}
}
|