PHPUnit_Util_Test::getHookMethods PHP Method

getHookMethods() public static method

public static getHookMethods ( string $className ) : array
$className string
return array
    public static function getHookMethods($className)
    {
        if (!class_exists($className, false)) {
            return self::emptyHookMethodsArray();
        }
        if (!isset(self::$hookMethods[$className])) {
            self::$hookMethods[$className] = self::emptyHookMethodsArray();
            try {
                $class = new ReflectionClass($className);
                foreach ($class->getMethods() as $method) {
                    if (self::isBeforeClassMethod($method)) {
                        array_unshift(self::$hookMethods[$className]['beforeClass'], $method->getName());
                    }
                    if (self::isBeforeMethod($method)) {
                        array_unshift(self::$hookMethods[$className]['before'], $method->getName());
                    }
                    if (self::isAfterMethod($method)) {
                        self::$hookMethods[$className]['after'][] = $method->getName();
                    }
                    if (self::isAfterClassMethod($method)) {
                        self::$hookMethods[$className]['afterClass'][] = $method->getName();
                    }
                }
            } catch (ReflectionException $e) {
            }
        }
        return self::$hookMethods[$className];
    }

Usage Example

Example #1
0
 public function beforeClass(SuiteEvent $e)
 {
     foreach ($e->getSuite()->tests() as $test) {
         /** @var $test \PHPUnit_Framework_Test  * */
         $testClass = get_class($test);
         $this->hooks[$testClass] = \PHPUnit_Util_Test::getHookMethods($testClass);
     }
     $this->runHooks('beforeClass');
 }
All Usage Examples Of PHPUnit_Util_Test::getHookMethods