PHPUnit_Util_Test::parseTestMethodAnnotations PHP Method

parseTestMethodAnnotations() public static method

public static parseTestMethodAnnotations ( string $className, string $methodName = '' ) : array
$className string
$methodName string
return array
    public static function parseTestMethodAnnotations($className, $methodName = '')
    {
        if (!isset(self::$annotationCache[$className])) {
            $class = new ReflectionClass($className);
            $traits = $class->getTraits();
            $annotations = [];
            foreach ($traits as $trait) {
                $annotations = array_merge($annotations, self::parseAnnotations($trait->getDocComment()));
            }
            self::$annotationCache[$className] = array_merge($annotations, self::parseAnnotations($class->getDocComment()));
        }
        if (!empty($methodName) && !isset(self::$annotationCache[$className . '::' . $methodName])) {
            try {
                $method = new ReflectionMethod($className, $methodName);
                $annotations = self::parseAnnotations($method->getDocComment());
            } catch (ReflectionException $e) {
                $annotations = [];
            }
            self::$annotationCache[$className . '::' . $methodName] = $annotations;
        }
        return ['class' => self::$annotationCache[$className], 'method' => !empty($methodName) ? self::$annotationCache[$className . '::' . $methodName] : []];
    }

Usage Example

 /**
  * Start and clear caching proxy server if test is annotated with @clearCache
  */
 protected function setUp()
 {
     $annotations = \PHPUnit_Util_Test::parseTestMethodAnnotations(get_class($this), $this->getName());
     if (isset($annotations['class']['clearCache']) || isset($annotations['method']['clearCache'])) {
         $this->getProxy()->clear();
     }
 }
All Usage Examples Of PHPUnit_Util_Test::parseTestMethodAnnotations