ProxyObjectTest.php (1124B)
1 <?php 2 /* 3 * This file is part of the PHPUnit_MockObject package. 4 * 5 * (c) Sebastian Bergmann <sebastian@phpunit.de> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11 /** 12 * @since Class available since Release 2.0.0 13 */ 14 class Framework_ProxyObjectTest extends PHPUnit_Framework_TestCase 15 { 16 public function testMockedMethodIsProxiedToOriginalMethod() 17 { 18 $proxy = $this->getMockBuilder('Bar') 19 ->enableProxyingToOriginalMethods() 20 ->getMock(); 21 22 $proxy->expects($this->once()) 23 ->method('doSomethingElse'); 24 25 $foo = new Foo; 26 $this->assertEquals('result', $foo->doSomething($proxy)); 27 } 28 29 public function testMockedMethodWithReferenceIsProxiedToOriginalMethod() 30 { 31 $proxy = $this->getMockBuilder('MethodCallbackByReference') 32 ->enableProxyingToOriginalMethods() 33 ->getMock(); 34 $a = $b = $c = 0; 35 36 $proxy->callback($a, $b, $c); 37 38 $this->assertEquals(1, $b); 39 } 40 }