Skip to content

Instantly share code, notes, and snippets.

@nguyentienlong
Last active May 12, 2016 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nguyentienlong/8891835d7a1cd5a8522bd71a8b7d83e6 to your computer and use it in GitHub Desktop.
Save nguyentienlong/8891835d7a1cd5a8522bd71a8b7d83e6 to your computer and use it in GitHub Desktop.
PHP Test private, protected function
/**
* Helper function to call protected method
*
* @param stdObject $obj
* @param string $methodName
* @param array[] $args
*
* @return null
*/
protected function callMethod($obj, $methodName, array $args) {
$class = new \ReflectionClass($obj);
$method = $class->getMethod($methodName);
$method->setAccessible(true);
return $method->invokeArgs($obj, $args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment