Mercurial > hg > isophonics-drupal-site
comparison vendor/phpunit/phpunit-mock-objects/tests/MockObject/interface.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', array(), 'MockFoo', TRUE, TRUE) | |
3 --FILE-- | |
4 <?php | |
5 interface Foo | |
6 { | |
7 public function bar(Foo $foo); | |
8 } | |
9 | |
10 require __DIR__ . '/../../vendor/autoload.php'; | |
11 | |
12 $generator = new PHPUnit_Framework_MockObject_Generator; | |
13 | |
14 $mock = $generator->generate( | |
15 'Foo', | |
16 array(), | |
17 'MockFoo', | |
18 TRUE, | |
19 TRUE | |
20 ); | |
21 | |
22 print $mock['code']; | |
23 ?> | |
24 --EXPECTF-- | |
25 class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo | |
26 { | |
27 private $__phpunit_invocationMocker; | |
28 private $__phpunit_originalObject; | |
29 | |
30 public function __clone() | |
31 { | |
32 $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); | |
33 } | |
34 | |
35 public function bar(Foo $foo) | |
36 { | |
37 $arguments = array($foo); | |
38 $count = func_num_args(); | |
39 | |
40 if ($count > 1) { | |
41 $_arguments = func_get_args(); | |
42 | |
43 for ($i = 1; $i < $count; $i++) { | |
44 $arguments[] = $_arguments[$i]; | |
45 } | |
46 } | |
47 | |
48 $result = $this->__phpunit_getInvocationMocker()->invoke( | |
49 new PHPUnit_Framework_MockObject_Invocation_Object( | |
50 'Foo', 'bar', $arguments, $this, TRUE | |
51 ) | |
52 ); | |
53 | |
54 return $result; | |
55 } | |
56 | |
57 public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) | |
58 { | |
59 return $this->__phpunit_getInvocationMocker()->expects($matcher); | |
60 } | |
61 | |
62 public function method() | |
63 { | |
64 $any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount; | |
65 $expects = $this->expects($any); | |
66 return call_user_func_array(array($expects, 'method'), func_get_args()); | |
67 } | |
68 | |
69 public function __phpunit_setOriginalObject($originalObject) | |
70 { | |
71 $this->__phpunit_originalObject = $originalObject; | |
72 } | |
73 | |
74 public function __phpunit_getInvocationMocker() | |
75 { | |
76 if ($this->__phpunit_invocationMocker === NULL) { | |
77 $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker; | |
78 } | |
79 | |
80 return $this->__phpunit_invocationMocker; | |
81 } | |
82 | |
83 public function __phpunit_hasMatchers() | |
84 { | |
85 return $this->__phpunit_getInvocationMocker()->hasMatchers(); | |
86 } | |
87 | |
88 public function __phpunit_verify() | |
89 { | |
90 $this->__phpunit_getInvocationMocker()->verify(); | |
91 $this->__phpunit_invocationMocker = NULL; | |
92 } | |
93 } |