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