Currently I try to integrate PHPUnit in my project. To ensure a 100% test coverage over time, I want to check if all methods that exist in the class to be tested in the testclass. So I thought I could write something like
class MyClassTest extends PHPUnit_Framework_TestCase {
private function _getClassFunctions($class) {
$class = new ReflectionClass($class);
return $class->getMethods();
}
public function testCompareFunctionCount() {
$this->assertEquals($this->_getClassFunctions('MyClass'), $this->_getClassFunctions(__CLASS__));
}
}
It seems, however, that ReflectionClass::getMethods() counts not only the methods of the class itself, but also all of the extended classes.
Is there a way to prevent this behaviour? Or did I get something totally wrong? I read in older articles that ReflectionClass::getMethods() doesn't work correctly on older PHP-Versions, but I thought it might be fixed by now (those articles are 4+ years old...)
I use PHP 5.4.5.