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