diff --git a/libraries/lithium/test/Report.php b/libraries/lithium/test/Report.php index 9035a9a803..3c06b43220 100644 --- a/libraries/lithium/test/Report.php +++ b/libraries/lithium/test/Report.php @@ -133,18 +133,17 @@ public function run() { /** * Collects Results from the test filters and aggregates them. * - * @param string $class Fully namespaced classname of the filter - * for which to aggregate results. - * @param array $results Array of the filter results packaged for + * @param string $class Classname of the filter for which to aggregate results. + * @param array $results Array of the filter results for * later analysis by the filter itself. * @return void */ public function collectFilterResults($class, $results) { - $testClass = key($results); - if(!isset($this->results['filters'][$class][$testClass])) { - $this->results['filters'][$class][$testClass] = array(); + //$testClass = key($results); + if(!isset($this->results['filters'][$class])) { + $this->results['filters'][$class] = array(); } - $this->results['filters'][$class][$testClass] = $results[$testClass]; + $this->results['filters'][$class][] = $results; } /** diff --git a/libraries/lithium/test/filter/Affected.php b/libraries/lithium/test/filter/Affected.php index 5fa2b384fa..e97a4af576 100644 --- a/libraries/lithium/test/filter/Affected.php +++ b/libraries/lithium/test/filter/Affected.php @@ -26,8 +26,8 @@ class Affected extends \lithium\test\filter\Base { /** * Holds metrics for this filter. * - * @see lihtium\test\filter\Affected::apply() - * @see lihtium\test\filter\Affected::output() + * @see lithium\test\filter\Affected::apply() + * @see lithium\test\filter\Affected::output() * @var array Keys are affected classes, values (if available) corresponding test case classes. */ protected static $_metrics = array(); diff --git a/libraries/lithium/test/filter/Coverage.php b/libraries/lithium/test/filter/Coverage.php index 5b2702c16a..bba1ab36c5 100644 --- a/libraries/lithium/test/filter/Coverage.php +++ b/libraries/lithium/test/filter/Coverage.php @@ -47,7 +47,7 @@ public static function apply($report, $tests, $options = array()) { $chain->next($self, $params, $chain); $results = xdebug_get_code_coverage(); xdebug_stop_code_coverage(); - $report->collectFilterResults(__CLASS__, Coverage::collect($self->subject(), $results, $options)); + $report->collectFilterResults(__CLASS__, array( $self->subject() => $results )); })); return $tests; } @@ -63,6 +63,7 @@ public static function apply($report, $tests, $options = array()) { * instances each line was called. */ public static function analyze($results, $filterResults, $classes = array()) { + $filterResults = static::collect($filterResults); $classes = $classes ?: array_filter(get_declared_classes(), function($class) { return (!is_subclass_of($class, 'lithium\test\Unit')); }); @@ -168,30 +169,36 @@ public static function output($format, $analysis) { /** * Collects code coverage analysis results from `xdebug_get_code_coverage()`. * - * @param string $class Class name that these test results correspond to. - * @param array $results A results array from `xdebug_get_code_coverage()`. + * @param array $filterResults An array of results arrays from `xdebug_get_code_coverage()`. * @param array $options Set of options defining how results should be collected. * @return array The packaged filter results. * @see lithium\test\Coverage::analyze() * @todo Implement $options['merging'] */ - public static function collect($class, $results, $options = array()) { + public static function collect($filterResults, $options = array()) { $defaults = array('merging' => 'class'); $options += $defaults; - $filterResults[$class] = array(); + $packagedResults = array(); - foreach ($results as $file => $lines) { - unset($results[$file][0]); - } + foreach ($filterResults as $results) { + $class = key($results); + $results = $results[$class]; + foreach ($results as $file => $lines) { + unset($results[$file][0]); + } - switch ($options['merging']) { - case 'class': - default: - $filterResults[$class][] = $results; - break; + switch ($options['merging']) { + case 'class': + default: + if (!isset($packagedResults[$class])) { + $packagedResults[$class] = array(); + } + $packagedResults[$class][] = $results; + break; + } } - return $filterResults; + return $packagedResults; } /**