Created
April 28, 2016 05:20
-
-
Save lovelock/422211343fd330ea2ae401888ee8ec30 to your computer and use it in GitHub Desktop.
method to test private or protected methods of class
This file contains hidden or 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 PseudoUserTest extends PHPUnit_Framework_TestCase | |
{ | |
public function invokeMethod(&$object, $methodName, $parameters = array()) | |
{ | |
$reflection = new ReflectionClass(get_class($object)); | |
$method = $reflection->getMethod($methodName); | |
$method->setAccessible(true); | |
return $method->invokeArgs($object, $parameters); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment