@@ -167,6 +167,13 @@ public function testStubbedReturnValue()
167
167
->will ($ this ->returnValue ('something ' ));
168
168
169
169
$ this ->assertEquals ('something ' , $ mock ->doSomething ());
170
+
171
+ $ mock = $ this ->getMock ('AnInterface ' );
172
+ $ mock ->expects ($ this ->any ())
173
+ ->method ('doSomething ' )
174
+ ->willReturn ('something ' );
175
+
176
+ $ this ->assertEquals ('something ' , $ mock ->doSomething ());
170
177
}
171
178
172
179
public function testStubbedReturnValueMap ()
@@ -184,6 +191,15 @@ public function testStubbedReturnValueMap()
184
191
$ this ->assertEquals ('d ' , $ mock ->doSomething ('a ' , 'b ' , 'c ' ));
185
192
$ this ->assertEquals ('h ' , $ mock ->doSomething ('e ' , 'f ' , 'g ' ));
186
193
$ this ->assertEquals (NULL , $ mock ->doSomething ('foo ' , 'bar ' ));
194
+
195
+ $ mock = $ this ->getMock ('AnInterface ' );
196
+ $ mock ->expects ($ this ->any ())
197
+ ->method ('doSomething ' )
198
+ ->willReturnMap ($ map );
199
+
200
+ $ this ->assertEquals ('d ' , $ mock ->doSomething ('a ' , 'b ' , 'c ' ));
201
+ $ this ->assertEquals ('h ' , $ mock ->doSomething ('e ' , 'f ' , 'g ' ));
202
+ $ this ->assertEquals (NULL , $ mock ->doSomething ('foo ' , 'bar ' ));
187
203
}
188
204
189
205
public function testFunctionCallback ()
@@ -194,6 +210,13 @@ public function testFunctionCallback()
194
210
->will ($ this ->returnCallback ('functionCallback ' ));
195
211
196
212
$ this ->assertEquals ('pass ' , $ mock ->doSomething ('foo ' , 'bar ' ));
213
+
214
+ $ mock = $ this ->getMock ('SomeClass ' , array ('doSomething ' ), array (), '' , FALSE );
215
+ $ mock ->expects ($ this ->once ())
216
+ ->method ('doSomething ' )
217
+ ->willReturnCallback ('functionCallback ' );
218
+
219
+ $ this ->assertEquals ('pass ' , $ mock ->doSomething ('foo ' , 'bar ' ));
197
220
}
198
221
199
222
public function testStaticMethodCallback ()
@@ -304,6 +327,21 @@ public function testStubbedReturnValueForStaticMethod()
304
327
$ this ->assertEquals (
305
328
'something ' , StaticMockTestClassMock::doSomething ()
306
329
);
330
+
331
+ $ this ->getMockClass (
332
+ 'StaticMockTestClass ' ,
333
+ array ('doSomething ' ),
334
+ array (),
335
+ 'StaticMockTestClassMock '
336
+ );
337
+
338
+ StaticMockTestClassMock::staticExpects ($ this ->any ())
339
+ ->method ('doSomething ' )
340
+ ->willReturn ('something ' );
341
+
342
+ $ this ->assertEquals (
343
+ 'something ' , StaticMockTestClassMock::doSomething ()
344
+ );
307
345
}
308
346
309
347
public function testStubbedReturnValueForStaticMethod2 ()
@@ -322,6 +360,21 @@ public function testStubbedReturnValueForStaticMethod2()
322
360
$ this ->assertEquals (
323
361
'something ' , StaticMockTestClassMock2::doSomethingElse ()
324
362
);
363
+
364
+ $ this ->getMockClass (
365
+ 'StaticMockTestClass ' ,
366
+ array ('doSomething ' ),
367
+ array (),
368
+ 'StaticMockTestClassMock2 '
369
+ );
370
+
371
+ StaticMockTestClassMock2::staticExpects ($ this ->any ())
372
+ ->method ('doSomething ' )
373
+ ->willReturn ('something ' );
374
+
375
+ $ this ->assertEquals (
376
+ 'something ' , StaticMockTestClassMock2::doSomethingElse ()
377
+ );
325
378
}
326
379
327
380
public function testGetMockForAbstractClass ()
0 commit comments