diff --git a/tests/ShortifyPunitTest.php b/tests/ShortifyPunitTest.php index b33d14b..4107241 100644 --- a/tests/ShortifyPunitTest.php +++ b/tests/ShortifyPunitTest.php @@ -39,7 +39,22 @@ final class FinalClassForMocking interface InterfaceTest { +} + +/** + * Class MagicClass + */ +class MagicClass +{ + public function __call($method, $arguments) + { + return '__call'; + } + public function __toString() + { + return '__toString'; + } } class ShortifyPunitTest extends \PHPUnit_Framework_TestCase @@ -402,4 +417,17 @@ public function testHamcrestWithNormalParam() $this->assertEquals($mock->first_method('anything...', 'a'), 1); $this->assertEquals($mock->first_method('anything...', 'b'), 2); } + + /** + * Stubbing magic methods + */ + public function testStubbingMagicMethods() + { + $mock = ShortifyPunit::mock('MagicClass'); + + ShortifyPunit::when($mock)->__toString()->returns('mockString'); + + $this->assertEquals($mock->__toString(), 'mockString'); + $this->assertEquals($mock, 'mockString'); + } } \ No newline at end of file