1--TEST--
2PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
3--FILE--
4<?php
5abstract class Foo
6{
7    public function one()
8    {
9    }
10
11    abstract public function two();
12
13    abstract protected function three();
14}
15
16require __DIR__ . '/../../../vendor/autoload.php';
17
18$generator = new PHPUnit_Framework_MockObject_Generator;
19
20$mock = $generator->generate(
21    'Foo',
22    array(),
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 = ['one', 'two', 'three'];
36
37    public function __clone()
38    {
39        $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
40    }
41
42    public function one()
43    {
44        $arguments = array();
45        $count     = func_num_args();
46
47        if ($count > 0) {
48            $_arguments = func_get_args();
49
50            for ($i = 0; $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', 'one', $arguments, '', $this, true
58            )
59        );
60
61        return $result;
62    }
63
64    public function two()
65    {
66        $arguments = array();
67        $count     = func_num_args();
68
69        if ($count > 0) {
70            $_arguments = func_get_args();
71
72            for ($i = 0; $i < $count; $i++) {
73                $arguments[] = $_arguments[$i];
74            }
75        }
76
77        $result = $this->__phpunit_getInvocationMocker()->invoke(
78            new PHPUnit_Framework_MockObject_Invocation_Object(
79                'Foo', 'two', $arguments, '', $this, true
80            )
81        );
82
83        return $result;
84    }
85
86    protected function three()
87    {
88        $arguments = array();
89        $count     = func_num_args();
90
91        if ($count > 0) {
92            $_arguments = func_get_args();
93
94            for ($i = 0; $i < $count; $i++) {
95                $arguments[] = $_arguments[$i];
96            }
97        }
98
99        $result = $this->__phpunit_getInvocationMocker()->invoke(
100            new PHPUnit_Framework_MockObject_Invocation_Object(
101                'Foo', 'three', $arguments, '', $this, true
102            )
103        );
104
105        return $result;
106    }
107
108    public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
109    {
110        return $this->__phpunit_getInvocationMocker()->expects($matcher);
111    }
112
113    public function method()
114    {
115        $any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
116        $expects = $this->expects($any);
117        return call_user_func_array(array($expects, 'method'), func_get_args());
118    }
119
120    public function __phpunit_setOriginalObject($originalObject)
121    {
122        $this->__phpunit_originalObject = $originalObject;
123    }
124
125    public function __phpunit_getInvocationMocker()
126    {
127        if ($this->__phpunit_invocationMocker === null) {
128            $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
129        }
130
131        return $this->__phpunit_invocationMocker;
132    }
133
134    public function __phpunit_hasMatchers()
135    {
136        return $this->__phpunit_getInvocationMocker()->hasMatchers();
137    }
138
139    public function __phpunit_verify($unsetInvocationMocker = true)
140    {
141        $this->__phpunit_getInvocationMocker()->verify();
142
143        if ($unsetInvocationMocker) {
144            $this->__phpunit_invocationMocker = null;
145        }
146    }
147}
148