Applies the @covers annotation filtering.
array $data:
mixed $id:
protected function applyCoversAnnotationFilter(&$data, $id) {
if ($id instanceof PHPUnit_Framework_TestCase) {
$testClassName = get_class($id);
$linesToBeCovered = $this
->getLinesToBeCovered($testClassName, $id
->getName());
if ($linesToBeCovered === FALSE) {
$data = array();
return;
}
if ($this->mapTestClassNameToCoveredClassName && empty($linesToBeCovered)) {
$testedClass = substr($testClassName, 0, -4);
if (class_exists($testedClass)) {
$class = new ReflectionClass($testedClass);
$linesToBeCovered = array(
$class
->getFileName() => range($class
->getStartLine(), $class
->getEndLine()),
);
}
}
}
else {
$linesToBeCovered = array();
}
if (!empty($linesToBeCovered)) {
$data = array_intersect_key($data, $linesToBeCovered);
foreach (array_keys($data) as $filename) {
$data[$filename] = array_intersect_key($data[$filename], array_flip($linesToBeCovered[$filename]));
}
}
else {
if ($this->forceCoversAnnotation) {
$data = array();
}
}
}