You are here

private static function PHPUnit_Util_Test::getLinesToBeCoveredOrUsed in Zircon Profile 8

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

@since Method available since Release 4.2.0

Parameters

string $className:

string $methodName:

string $mode:

Return value

array

Throws

PHPUnit_Framework_CodeCoverageException

2 calls to PHPUnit_Util_Test::getLinesToBeCoveredOrUsed()
PHPUnit_Util_Test::getLinesToBeCovered in vendor/phpunit/phpunit/src/Util/Test.php
@since Method available since Release 4.0.0
PHPUnit_Util_Test::getLinesToBeUsed in vendor/phpunit/phpunit/src/Util/Test.php
Returns lines of code specified with the @uses annotation.

File

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

Class

PHPUnit_Util_Test
Test helpers.

Code

private static function getLinesToBeCoveredOrUsed($className, $methodName, $mode) {
  $annotations = self::parseTestMethodAnnotations($className, $methodName);
  $classShortcut = null;
  if (!empty($annotations['class'][$mode . 'DefaultClass'])) {
    if (count($annotations['class'][$mode . 'DefaultClass']) > 1) {
      throw new PHPUnit_Framework_CodeCoverageException(sprintf('More than one @%sClass annotation in class or interface "%s".', $mode, $className));
    }
    $classShortcut = $annotations['class'][$mode . 'DefaultClass'][0];
  }
  $list = array();
  if (isset($annotations['class'][$mode])) {
    $list = $annotations['class'][$mode];
  }
  if (isset($annotations['method'][$mode])) {
    $list = array_merge($list, $annotations['method'][$mode]);
  }
  $codeList = array();
  foreach (array_unique($list) as $element) {
    if ($classShortcut && strncmp($element, '::', 2) === 0) {
      $element = $classShortcut . $element;
    }
    $element = preg_replace('/[\\s()]+$/', '', $element);
    $element = explode(' ', $element);
    $element = $element[0];
    $codeList = array_merge($codeList, self::resolveElementToReflectionObjects($element));
  }
  return self::resolveReflectionObjectsToLines($codeList);
}