File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,22 @@ final class FinalClassForMocking
3939
4040interface InterfaceTest
4141{
42+ }
43+
44+ /**
45+ * Class MagicClass
46+ */
47+ class MagicClass
48+ {
49+ public function __call ($ method , $ arguments )
50+ {
51+ return '__call ' ;
52+ }
4253
54+ public function __toString ()
55+ {
56+ return '__toString ' ;
57+ }
4358}
4459
4560class ShortifyPunitTest extends \PHPUnit_Framework_TestCase
@@ -402,4 +417,17 @@ public function testHamcrestWithNormalParam()
402417 $ this ->assertEquals ($ mock ->first_method ('anything... ' , 'a ' ), 1 );
403418 $ this ->assertEquals ($ mock ->first_method ('anything... ' , 'b ' ), 2 );
404419 }
420+
421+ /**
422+ * Stubbing magic methods
423+ */
424+ public function testStubbingMagicMethods ()
425+ {
426+ $ mock = ShortifyPunit::mock ('MagicClass ' );
427+
428+ ShortifyPunit::when ($ mock )->__toString ()->returns ('mockString ' );
429+
430+ $ this ->assertEquals ($ mock ->__toString (), 'mockString ' );
431+ $ this ->assertEquals ($ mock , 'mockString ' );
432+ }
405433}
You can’t perform that action at this time.
0 commit comments