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