add myCalendar into
[awl.git] / vendor / phpunit / phpunit-mock-objects / Tests / MockObject / invocation_static_clone_object.phpt
blob469b0b3c793e65aa1016ab0f68705c3ab2925cc2
1 --TEST--
2 PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE, TRUE)
3 --FILE--
4 <?php
5 class Foo
7     public static function bar(Foo $foo)
8     {
9     }
11     public static function baz(Foo $foo)
12     {
13     }
16 require_once 'PHPUnit/Autoload.php';
17 require_once 'Text/Template.php';
19 $mock = PHPUnit_Framework_MockObject_Generator::generate(
20   'Foo',
21   array(),
22   'MockFoo',
23   TRUE,
24   TRUE,
25   TRUE
28 print $mock['code'];
30 --EXPECTF--
31 class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
33     private static $__phpunit_staticInvocationMocker;
34     private $__phpunit_invocationMocker;
36     public function __clone()
37     {
38         $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
39     }
41     public static function bar(Foo $foo)
42     {
43         $arguments = array($foo);
44         $count     = func_num_args();
46         if ($count > 1) {
47             $_arguments = func_get_args();
49             for ($i = 1; $i < $count; $i++) {
50                 $arguments[] = $_arguments[$i];
51             }
52         }
54         $result = self::__phpunit_getStaticInvocationMocker()->invoke(
55           new PHPUnit_Framework_MockObject_Invocation_Static(
56             'Foo', 'bar', $arguments, TRUE
57           )
58         );
60         return $result;
61     }
63     public static function baz(Foo $foo)
64     {
65         $arguments = array($foo);
66         $count     = func_num_args();
68         if ($count > 1) {
69             $_arguments = func_get_args();
71             for ($i = 1; $i < $count; $i++) {
72                 $arguments[] = $_arguments[$i];
73             }
74         }
76         $result = self::__phpunit_getStaticInvocationMocker()->invoke(
77           new PHPUnit_Framework_MockObject_Invocation_Static(
78             'Foo', 'baz', $arguments, TRUE
79           )
80         );
82         return $result;
83     }
85     public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
86     {
87         return $this->__phpunit_getInvocationMocker()->expects($matcher);
88     }
90     public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
91     {
92         return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
93     }
95     public function __phpunit_getInvocationMocker()
96     {
97         if ($this->__phpunit_invocationMocker === NULL) {
98             $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
99         }
101         return $this->__phpunit_invocationMocker;
102     }
104     public static function __phpunit_getStaticInvocationMocker()
105     {
106         if (self::$__phpunit_staticInvocationMocker === NULL) {
107             self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
108         }
110         return self::$__phpunit_staticInvocationMocker;
111     }
113     public function __phpunit_hasMatchers()
114     {
115         return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
116                $this->__phpunit_getInvocationMocker()->hasMatchers();
117     }
119     public function __phpunit_verify()
120     {
121         self::__phpunit_getStaticInvocationMocker()->verify();
122         $this->__phpunit_getInvocationMocker()->verify();
123     }
125     public function __phpunit_cleanup()
126     {
127         self::$__phpunit_staticInvocationMocker = NULL;
128         $this->__phpunit_invocationMocker       = NULL;
129     }