Mercurial > hg > isophonics-drupal-site
comparison vendor/phpunit/phpunit-mock-objects/tests/MockObject/proxy.phpt @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 --TEST-- | |
2 PHPUnit_Framework_MockObject_Generator::generate('Foo', NULL, 'ProxyFoo', TRUE, TRUE, TRUE, TRUE) | |
3 --FILE-- | |
4 <?php | |
5 class Foo | |
6 { | |
7 public function bar(Foo $foo) | |
8 { | |
9 } | |
10 | |
11 public function baz(Foo $foo) | |
12 { | |
13 } | |
14 } | |
15 | |
16 require __DIR__ . '/../../vendor/autoload.php'; | |
17 | |
18 $generator = new PHPUnit_Framework_MockObject_Generator; | |
19 | |
20 $mock = $generator->generate( | |
21 'Foo', array(), 'ProxyFoo', TRUE, TRUE, TRUE, TRUE | |
22 ); | |
23 | |
24 print $mock['code']; | |
25 ?> | |
26 --EXPECTF-- | |
27 class ProxyFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject | |
28 { | |
29 private $__phpunit_invocationMocker; | |
30 private $__phpunit_originalObject; | |
31 | |
32 public function __clone() | |
33 { | |
34 $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); | |
35 } | |
36 | |
37 public function bar(Foo $foo) | |
38 { | |
39 $arguments = array($foo); | |
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 $this->__phpunit_getInvocationMocker()->invoke( | |
51 new PHPUnit_Framework_MockObject_Invocation_Object( | |
52 'Foo', 'bar', $arguments, $this, TRUE | |
53 ) | |
54 ); | |
55 | |
56 return call_user_func_array(array($this->__phpunit_originalObject, "bar"), $arguments); | |
57 } | |
58 | |
59 public function baz(Foo $foo) | |
60 { | |
61 $arguments = array($foo); | |
62 $count = func_num_args(); | |
63 | |
64 if ($count > 1) { | |
65 $_arguments = func_get_args(); | |
66 | |
67 for ($i = 1; $i < $count; $i++) { | |
68 $arguments[] = $_arguments[$i]; | |
69 } | |
70 } | |
71 | |
72 $this->__phpunit_getInvocationMocker()->invoke( | |
73 new PHPUnit_Framework_MockObject_Invocation_Object( | |
74 'Foo', 'baz', $arguments, $this, TRUE | |
75 ) | |
76 ); | |
77 | |
78 return call_user_func_array(array($this->__phpunit_originalObject, "baz"), $arguments); | |
79 } | |
80 | |
81 public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) | |
82 { | |
83 return $this->__phpunit_getInvocationMocker()->expects($matcher); | |
84 } | |
85 | |
86 public function method() | |
87 { | |
88 $any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount; | |
89 $expects = $this->expects($any); | |
90 return call_user_func_array(array($expects, 'method'), func_get_args()); | |
91 } | |
92 | |
93 public function __phpunit_setOriginalObject($originalObject) | |
94 { | |
95 $this->__phpunit_originalObject = $originalObject; | |
96 } | |
97 | |
98 public function __phpunit_getInvocationMocker() | |
99 { | |
100 if ($this->__phpunit_invocationMocker === NULL) { | |
101 $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; | |
102 } | |
103 | |
104 return $this->__phpunit_invocationMocker; | |
105 } | |
106 | |
107 public function __phpunit_hasMatchers() | |
108 { | |
109 return $this->__phpunit_getInvocationMocker()->hasMatchers(); | |
110 } | |
111 | |
112 public function __phpunit_verify() | |
113 { | |
114 $this->__phpunit_getInvocationMocker()->verify(); | |
115 $this->__phpunit_invocationMocker = NULL; | |
116 } | |
117 } |