Skip to content

Instantly share code, notes, and snippets.

@fabeat
Created December 7, 2010 15:34
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 fabeat/731908 to your computer and use it in GitHub Desktop.
Save fabeat/731908 to your computer and use it in GitHub Desktop.
Unit tests of protected methods in PHP
<?php
class Foo
{
protected function bar($test)
{
echo $test;
}
}
$foo = new Foo();
$bar = new ReflectionMethod($foo, 'bar');
$bar->setAccessible(true);
$bar->invoke($foo, 'TEST');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment