Skip to content

Commit 6ce59fa

Browse files
author
Dan Revah
committed
Added test for magic methods
1 parent 472953d commit 6ce59fa

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/ShortifyPunitTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,22 @@ final class FinalClassForMocking
3939

4040
interface 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

4560
class 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
}

0 commit comments

Comments
 (0)