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
|
<?php
declare(strict_types=1);
namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator;
use Laminas\Code\Generator\PropertyGenerator;
use PHPUnit\Framework\TestCase;
use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicUnset;
use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap;
use ProxyManagerTestAsset\EmptyClass;
use ReflectionClass;
use function strpos;
/**
* Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicUnset}
*
* @group Coverage
*/
final class MagicUnsetTest extends TestCase
{
/**
* @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicUnset::__construct
*/
public function testBodyStructure(): void
{
$reflection = new ReflectionClass(EmptyClass::class);
$valueHolder = $this->createMock(PropertyGenerator::class);
$prefixInterceptors = $this->createMock(PropertyGenerator::class);
$suffixInterceptors = $this->createMock(PropertyGenerator::class);
$publicProperties = $this->createMock(PublicPropertiesMap::class);
$valueHolder->method('getName')->willReturn('bar');
$prefixInterceptors->method('getName')->willReturn('pre');
$suffixInterceptors->method('getName')->willReturn('post');
$publicProperties->method('isEmpty')->willReturn(false);
$magicUnset = new MagicUnset(
$reflection,
$valueHolder,
$prefixInterceptors,
$suffixInterceptors,
$publicProperties
);
self::assertSame('__unset', $magicUnset->getName());
self::assertCount(1, $magicUnset->getParameters());
self::assertGreaterThan(
0,
strpos($magicUnset->getBody(), 'unset($this->bar->$name);')
);
}
}
|