You are here

public static function PHPUnit_Util_Test::getHookMethods in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Util/Test.php \PHPUnit_Util_Test::getHookMethods()

@since Method available since Release 4.0.8

Parameters

string $className:

Return value

array

2 calls to PHPUnit_Util_Test::getHookMethods()
PHPUnit_Framework_TestCase::runBare in vendor/phpunit/phpunit/src/Framework/TestCase.php
Runs the bare test sequence.
PHPUnit_Framework_TestSuite::run in vendor/phpunit/phpunit/src/Framework/TestSuite.php
Runs the tests and collects their result in a TestResult.

File

vendor/phpunit/phpunit/src/Util/Test.php, line 756

Class

PHPUnit_Util_Test
Test helpers.

Code

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)) {
          self::$hookMethods[$className]['beforeClass'][] = $method
            ->getName();
        }
        if (self::isBeforeMethod($method)) {
          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];
}