* @license MIT * * @group Coverage */ class MagicIssetTest extends PHPUnit_Framework_TestCase { /** * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicIsset::__construct */ public function testBodyStructure() { $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); $magicGet = new MagicIsset( $reflection, $prefixInterceptors, $suffixInterceptors ); $this->assertSame('__isset', $magicGet->getName()); $this->assertCount(1, $magicGet->getParameters()); $this->assertStringMatchesFormat('%a$returnValue = $accessor();%a', $magicGet->getBody()); } /** * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicIsset::__construct */ public function testBodyStructureWithInheritedMethod() { $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); $magicGet = new MagicIsset( $reflection, $prefixInterceptors, $suffixInterceptors ); $this->assertSame('__isset', $magicGet->getName()); $this->assertCount(1, $magicGet->getParameters()); $this->assertStringMatchesFormat('%a$returnValue = & parent::__isset($name);%a', $magicGet->getBody()); } }