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