comparison vendor/phpunit/phpunit-mock-objects/tests/MockObject/namespaced_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('NS\Foo', array(), 'MockFoo', TRUE, TRUE)
3 --FILE--
4 <?php
5 namespace NS;
6
7 interface Foo
8 {
9 public function bar(Foo $foo);
10 }
11
12 require __DIR__ . '/../../vendor/autoload.php';
13
14 $generator = new \PHPUnit_Framework_MockObject_Generator;
15
16 $mock = $generator->generate(
17 'NS\Foo',
18 array(),
19 'MockFoo',
20 TRUE,
21 TRUE
22 );
23
24 print $mock['code'];
25 ?>
26 --EXPECTF--
27 class MockFoo implements PHPUnit_Framework_MockObject_MockObject, NS\Foo
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(NS\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 $result = $this->__phpunit_getInvocationMocker()->invoke(
51 new PHPUnit_Framework_MockObject_Invocation_Object(
52 'NS\Foo', 'bar', $arguments, $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;
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()
91 {
92 $this->__phpunit_getInvocationMocker()->verify();
93 $this->__phpunit_invocationMocker = NULL;
94 }
95 }