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