diff --git a/library/aik099/PHPUnit/TestSuite/AbstractTestSuite.php b/library/aik099/PHPUnit/TestSuite/AbstractTestSuite.php index 3dab462..b4c0d63 100644 --- a/library/aik099/PHPUnit/TestSuite/AbstractTestSuite.php +++ b/library/aik099/PHPUnit/TestSuite/AbstractTestSuite.php @@ -47,13 +47,13 @@ public function addTestMethods($class_name) if ( \method_exists($this, 'isTestMethod') ) { // PHPUnit < 8.0 is calling "isTestMethod" inside "TestSuite::addTestMethod". - foreach ( $class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method ) { + foreach ( $this->getTestMethods($class) as $method ) { $this->addTestMethod($class, $method); } } else { // PHPUnit >= 8.0 is calling "TestUtil::isTestMethod" outside of "TestSuite::addTestMethod". - foreach ( $class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method ) { + foreach ( $this->getTestMethods($class) as $method ) { if ( TestUtil::isTestMethod($method) ) { $this->addTestMethod($class, $method); } @@ -63,6 +63,22 @@ public function addTestMethods($class_name) return $this; } + /** + * Returns test methods. + * + * @param \ReflectionClass $class Reflection class. + * + * @return \ReflectionMethod[] + */ + protected function getTestMethods(\ReflectionClass $class) + { + $ret = $class->getMethods(\ReflectionMethod::IS_PUBLIC); + + return \array_filter($ret, function (\ReflectionMethod $method) { + return !$method->isStatic(); + }); + } + /** * Sets session strategy manager recursively to all tests. *