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