[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
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 namespace ProxyManagerTest\ProxyGenerator\RemoteObject\MethodGenerator; 20 21 use PHPUnit_Framework_TestCase; 22 use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod; 23 use Zend\Code\Reflection\MethodReflection; 24 use ReflectionClass; 25 26 /** 27 * Tests for {@see \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod} 28 * 29 * @author Vincent Blanchon <blanchon.vincent@gmail.com> 30 * @license MIT 31 * 32 * @group Coverage 33 */ 34 class RemoteObjectMethodTest extends PHPUnit_Framework_TestCase 35 { 36 /** 37 * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod 38 */ 39 public function testBodyStructureWithParameters() 40 { 41 $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); 42 $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); 43 44 $reflectionMethod = new MethodReflection( 45 'ProxyManagerTestAsset\\BaseClass', 46 'publicByReferenceParameterMethod' 47 ); 48 49 $method = RemoteObjectMethod::generateMethod( 50 $reflectionMethod, 51 $adapter, 52 new ReflectionClass('Zend\\Code\\Generator\\PropertyGenerator') 53 ); 54 55 $this->assertSame('publicByReferenceParameterMethod', $method->getName()); 56 $this->assertCount(2, $method->getParameters()); 57 $this->assertSame( 58 '$return = $this->adapter->call(\'Zend\\\Code\\\Generator\\\PropertyGenerator\', ' 59 . '\'publicByReferenceParameterMethod\', array($param, $byRefParam));' 60 . "\n\nreturn \$return;", 61 $method->getBody() 62 ); 63 } 64 65 /** 66 * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod 67 */ 68 public function testBodyStructureWithArrayParameter() 69 { 70 $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); 71 $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); 72 73 $reflectionMethod = new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicArrayHintedMethod'); 74 75 $method = RemoteObjectMethod::generateMethod( 76 $reflectionMethod, 77 $adapter, 78 new ReflectionClass('Zend\\Code\\Generator\\PropertyGenerator') 79 ); 80 81 $this->assertSame('publicArrayHintedMethod', $method->getName()); 82 $this->assertCount(1, $method->getParameters()); 83 $this->assertSame( 84 '$return = $this->adapter->call(\'Zend\\\Code\\\Generator\\\PropertyGenerator\', ' 85 . '\'publicArrayHintedMethod\', array($param));' 86 . "\n\nreturn \$return;", 87 $method->getBody() 88 ); 89 } 90 91 /** 92 * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod 93 */ 94 public function testBodyStructureWithoutParameters() 95 { 96 $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); 97 $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); 98 99 $reflectionMethod = new MethodReflection(__CLASS__, 'testBodyStructureWithoutParameters'); 100 101 $method = RemoteObjectMethod::generateMethod( 102 $reflectionMethod, 103 $adapter, 104 new ReflectionClass('Zend\\Code\\Generator\\PropertyGenerator') 105 ); 106 107 $this->assertSame('testBodyStructureWithoutParameters', $method->getName()); 108 $this->assertCount(0, $method->getParameters()); 109 $this->assertSame( 110 '$return = $this->adapter->call(\'Zend\\\Code\\\Generator\\\PropertyGenerator\', ' 111 . '\'testBodyStructureWithoutParameters\', array());' 112 . "\n\nreturn \$return;", 113 $method->getBody() 114 ); 115 } 116 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |