You are here

public static function PHPUnit_Util_Test::getRequirements in Zircon Profile 8

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

Returns the requirements for a test.

@since Method available since Release 3.6.0

Parameters

string $className:

string $methodName:

Return value

array

3 calls to PHPUnit_Util_Test::getRequirements()
PHPUnit_Util_Test::getMissingRequirements in vendor/phpunit/phpunit/src/Util/Test.php
Returns the missing requirements for a test.
Util_TestTest::testGetRequirements in vendor/phpunit/phpunit/tests/Util/TestTest.php
@covers PHPUnit_Util_Test::getRequirements @dataProvider requirementsProvider
Util_TestTest::testGetRequirementsMergesClassAndMethodDocBlocks in vendor/phpunit/phpunit/tests/Util/TestTest.php
@covers PHPUnit_Util_Test::getRequirements

File

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

Class

PHPUnit_Util_Test
Test helpers.

Code

public static function getRequirements($className, $methodName) {
  $reflector = new ReflectionClass($className);
  $docComment = $reflector
    ->getDocComment();
  $reflector = new ReflectionMethod($className, $methodName);
  $docComment .= "\n" . $reflector
    ->getDocComment();
  $requires = array();
  if ($count = preg_match_all(self::REGEX_REQUIRES_OS, $docComment, $matches)) {
    $requires['OS'] = sprintf('/%s/i', addcslashes($matches['value'][$count - 1], '/'));
  }
  if ($count = preg_match_all(self::REGEX_REQUIRES_VERSION, $docComment, $matches)) {
    for ($i = 0; $i < $count; $i++) {
      $requires[$matches['name'][$i]] = $matches['value'][$i];
    }
  }

  // https://bugs.php.net/bug.php?id=63055
  $matches = array();
  if ($count = preg_match_all(self::REGEX_REQUIRES, $docComment, $matches)) {
    for ($i = 0; $i < $count; $i++) {
      $name = $matches['name'][$i] . 's';
      if (!isset($requires[$name])) {
        $requires[$name] = array();
      }
      $requires[$name][] = $matches['value'][$i];
    }
  }
  return $requires;
}