-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
call_original_with_argument_variadic.phpt
47 lines (36 loc) · 1.18 KB
/
call_original_with_argument_variadic.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--TEST--
Mock method and call original method with variadic argument
--FILE--
<?php
class Foo
{
private function bar(...$args){}
}
require __DIR__ . '/../../../../vendor/autoload.php';
$class = new ReflectionClass('Foo');
$mockMethod = \PHPUnit\Framework\MockObject\MockMethod::fromReflection(
$class->getMethod('bar'),
true,
false
);
$code = $mockMethod->generateCode();
print $code;
?>
--EXPECT--
private function bar(...$args)
{
$__phpunit_arguments = [];
$__phpunit_count = func_num_args();
if ($__phpunit_count > 0) {
$__phpunit_arguments_tmp = func_get_args();
for ($__phpunit_i = 0; $__phpunit_i < $__phpunit_count; $__phpunit_i++) {
$__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i];
}
}
$invocation = new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
'Foo', 'bar', $__phpunit_arguments, '', $this, false
);
$invocation->setProxiedCall();
$this->__phpunit_getInvocationMocker()->invoke($invocation);
return call_user_func_array(array($this->__phpunit_originalObject, "bar"), $__phpunit_arguments);
}