comparison vendor/phpunit/phpunit-mock-objects/tests/Generator/397.phpt @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents
children c2387f117808
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
1 --TEST--
2 https://github.com/sebastianbergmann/phpunit-mock-objects/issues/397
3 --FILE--
4 <?php
5 class C
6 {
7 public function m(?self $other): self
8 {
9 }
10 }
11
12 require __DIR__ . '/../../vendor/autoload.php';
13
14 $generator = new \PHPUnit\Framework\MockObject\Generator;
15
16 $mock = $generator->generate(
17 C::class,
18 [],
19 'MockC',
20 true,
21 true
22 );
23
24 print $mock['code'];
25 --EXPECTF--
26 class MockC extends C implements PHPUnit\Framework\MockObject\MockObject
27 {
28 private $__phpunit_invocationMocker;
29 private $__phpunit_originalObject;
30 private $__phpunit_configurable = ['m'];
31
32 public function __clone()
33 {
34 $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
35 }
36
37 public function m(?C $other): C
38 {
39 $arguments = array($other);
40 $count = func_num_args();
41
42 if ($count > 1) {
43 $_arguments = func_get_args();
44
45 for ($i = 1; $i < $count; $i++) {
46 $arguments[] = $_arguments[$i];
47 }
48 }
49
50 $result = $this->__phpunit_getInvocationMocker()->invoke(
51 new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
52 'C', 'm', $arguments, 'C', $this, true
53 )
54 );
55
56 return $result;
57 }
58
59 public function expects(\PHPUnit\Framework\MockObject\Matcher\Invocation $matcher)
60 {
61 return $this->__phpunit_getInvocationMocker()->expects($matcher);
62 }
63
64 public function method()
65 {
66 $any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
67 $expects = $this->expects($any);
68 return call_user_func_array(array($expects, 'method'), func_get_args());
69 }
70
71 public function __phpunit_setOriginalObject($originalObject)
72 {
73 $this->__phpunit_originalObject = $originalObject;
74 }
75
76 public function __phpunit_getInvocationMocker()
77 {
78 if ($this->__phpunit_invocationMocker === null) {
79 $this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
80 }
81
82 return $this->__phpunit_invocationMocker;
83 }
84
85 public function __phpunit_hasMatchers()
86 {
87 return $this->__phpunit_getInvocationMocker()->hasMatchers();
88 }
89
90 public function __phpunit_verify($unsetInvocationMocker = true)
91 {
92 $this->__phpunit_getInvocationMocker()->verify();
93
94 if ($unsetInvocationMocker) {
95 $this->__phpunit_invocationMocker = null;
96 }
97 }
98 }