ProxyObjectTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. class Framework_ProxyObjectTest extends PHPUnit_Framework_TestCase
  11. {
  12. public function testMockedMethodIsProxiedToOriginalMethod()
  13. {
  14. $proxy = $this->getMockBuilder(Bar::class)
  15. ->enableProxyingToOriginalMethods()
  16. ->getMock();
  17. $proxy->expects($this->once())
  18. ->method('doSomethingElse');
  19. $foo = new Foo;
  20. $this->assertEquals('result', $foo->doSomething($proxy));
  21. }
  22. public function testMockedMethodWithReferenceIsProxiedToOriginalMethod()
  23. {
  24. $proxy = $this->getMockBuilder(MethodCallbackByReference::class)
  25. ->enableProxyingToOriginalMethods()
  26. ->getMock();
  27. $a = $b = $c = 0;
  28. $proxy->callback($a, $b, $c);
  29. $this->assertEquals(1, $b);
  30. }
  31. }