* @license MIT * * @group Coverage */ class RemoteObjectMethodTest extends PHPUnit_Framework_TestCase { /** * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod */ public function testBodyStructureWithParameters() { $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); $reflectionMethod = new MethodReflection( 'ProxyManagerTestAsset\\BaseClass', 'publicByReferenceParameterMethod' ); $method = RemoteObjectMethod::generateMethod( $reflectionMethod, $adapter, new ReflectionClass('Zend\\Code\\Generator\\PropertyGenerator') ); $this->assertSame('publicByReferenceParameterMethod', $method->getName()); $this->assertCount(2, $method->getParameters()); $this->assertSame( '$return = $this->adapter->call(\'Zend\\\Code\\\Generator\\\PropertyGenerator\', ' . '\'publicByReferenceParameterMethod\', array($param, $byRefParam));' . "\n\nreturn \$return;", $method->getBody() ); } /** * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod */ public function testBodyStructureWithArrayParameter() { $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); $reflectionMethod = new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicArrayHintedMethod'); $method = RemoteObjectMethod::generateMethod( $reflectionMethod, $adapter, new ReflectionClass('Zend\\Code\\Generator\\PropertyGenerator') ); $this->assertSame('publicArrayHintedMethod', $method->getName()); $this->assertCount(1, $method->getParameters()); $this->assertSame( '$return = $this->adapter->call(\'Zend\\\Code\\\Generator\\\PropertyGenerator\', ' . '\'publicArrayHintedMethod\', array($param));' . "\n\nreturn \$return;", $method->getBody() ); } /** * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod */ public function testBodyStructureWithoutParameters() { $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); $reflectionMethod = new MethodReflection(__CLASS__, 'testBodyStructureWithoutParameters'); $method = RemoteObjectMethod::generateMethod( $reflectionMethod, $adapter, new ReflectionClass('Zend\\Code\\Generator\\PropertyGenerator') ); $this->assertSame('testBodyStructureWithoutParameters', $method->getName()); $this->assertCount(0, $method->getParameters()); $this->assertSame( '$return = $this->adapter->call(\'Zend\\\Code\\\Generator\\\PropertyGenerator\', ' . '\'testBodyStructureWithoutParameters\', array());' . "\n\nreturn \$return;", $method->getBody() ); } }