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