2 PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE, TRUE)
7 public static function bar(Foo $foo)
11 public static function baz(Foo $foo)
16 require_once 'PHPUnit/Autoload.php';
17 require_once 'Text/Template.php';
19 $mock = PHPUnit_Framework_MockObject_Generator::generate(
31 class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
33 private static $__phpunit_staticInvocationMocker;
34 private $__phpunit_invocationMocker;
36 public function __clone()
38 $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
41 public static function bar(Foo $foo)
43 $arguments = array($foo);
44 $count = func_num_args();
47 $_arguments = func_get_args();
49 for ($i = 1; $i < $count; $i++) {
50 $arguments[] = $_arguments[$i];
54 $result = self::__phpunit_getStaticInvocationMocker()->invoke(
55 new PHPUnit_Framework_MockObject_Invocation_Static(
56 'Foo', 'bar', $arguments, TRUE
63 public static function baz(Foo $foo)
65 $arguments = array($foo);
66 $count = func_num_args();
69 $_arguments = func_get_args();
71 for ($i = 1; $i < $count; $i++) {
72 $arguments[] = $_arguments[$i];
76 $result = self::__phpunit_getStaticInvocationMocker()->invoke(
77 new PHPUnit_Framework_MockObject_Invocation_Static(
78 'Foo', 'baz', $arguments, TRUE
85 public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
87 return $this->__phpunit_getInvocationMocker()->expects($matcher);
90 public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
92 return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
95 public function __phpunit_getInvocationMocker()
97 if ($this->__phpunit_invocationMocker === NULL) {
98 $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
101 return $this->__phpunit_invocationMocker;
104 public static function __phpunit_getStaticInvocationMocker()
106 if (self::$__phpunit_staticInvocationMocker === NULL) {
107 self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
110 return self::$__phpunit_staticInvocationMocker;
113 public function __phpunit_hasMatchers()
115 return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
116 $this->__phpunit_getInvocationMocker()->hasMatchers();
119 public function __phpunit_verify()
121 self::__phpunit_getStaticInvocationMocker()->verify();
122 $this->__phpunit_getInvocationMocker()->verify();
125 public function __phpunit_cleanup()
127 self::$__phpunit_staticInvocationMocker = NULL;
128 $this->__phpunit_invocationMocker = NULL;