1--TEST--
2PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true, true)
3--FILE--
4<?php
5namespace NS;
6
7interface Foo
8{
9    public function bar(Foo $foo);
10}
11
12require __DIR__ . '/../../../vendor/autoload.php';
13
14$generator = new \PHPUnit_Framework_MockObject_Generator;
15
16$mock = $generator->generate(
17    'NS\Foo',
18    array(),
19    'MockFoo',
20    true,
21    true
22);
23
24print $mock['code'];
25?>
26--EXPECTF--
27class MockFoo implements PHPUnit_Framework_MockObject_MockObject, NS\Foo
28{
29    private $__phpunit_invocationMocker;
30    private $__phpunit_originalObject;
31    private $__phpunit_configurable = ['bar'];
32
33    public function __clone()
34    {
35        $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
36    }
37
38    public function bar(NS\Foo $foo)
39    {
40        $arguments = array($foo);
41        $count     = func_num_args();
42
43        if ($count > 1) {
44            $_arguments = func_get_args();
45
46            for ($i = 1; $i < $count; $i++) {
47                $arguments[] = $_arguments[$i];
48            }
49        }
50
51        $result = $this->__phpunit_getInvocationMocker()->invoke(
52            new PHPUnit_Framework_MockObject_Invocation_Object(
53                'NS\Foo', 'bar', $arguments, '', $this, true
54            )
55        );
56
57        return $result;
58    }
59
60    public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
61    {
62        return $this->__phpunit_getInvocationMocker()->expects($matcher);
63    }
64
65    public function method()
66    {
67        $any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
68        $expects = $this->expects($any);
69        return call_user_func_array(array($expects, 'method'), func_get_args());
70    }
71
72    public function __phpunit_setOriginalObject($originalObject)
73    {
74        $this->__phpunit_originalObject = $originalObject;
75    }
76
77    public function __phpunit_getInvocationMocker()
78    {
79        if ($this->__phpunit_invocationMocker === null) {
80            $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
81        }
82
83        return $this->__phpunit_invocationMocker;
84    }
85
86    public function __phpunit_hasMatchers()
87    {
88        return $this->__phpunit_getInvocationMocker()->hasMatchers();
89    }
90
91    public function __phpunit_verify($unsetInvocationMocker = true)
92    {
93        $this->__phpunit_getInvocationMocker()->verify();
94
95        if ($unsetInvocationMocker) {
96            $this->__phpunit_invocationMocker = null;
97        }
98    }
99}
100