Created
December 31, 2010 11:27
-
-
Save benmatselby/760944 to your computer and use it in GitHub Desktop.
Mocking of the __call function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PhakeClass | |
{ | |
public function __call($method, $args) | |
{ | |
return '__call'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'Phake.php'; | |
require_once 'PhakeClass.php'; | |
class PhakeClassTest extends PHPUnit_Framework_TestCase | |
{ | |
public function testMockingOfMagicCallMethod() | |
{ | |
$expected = 'magicCalled'; | |
$obj = Phake::Mock('PhakeClass'); | |
Phake::when($obj)->__call('__call', array('magicCall', array()))->thenReturn($expected); | |
$value = $obj->magicCall(); | |
$this->assertEquals($expected, $value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment