Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactored test filter interface to better handle raw filter results …

…prior to analysis
  • Loading branch information...
commit 0fddf6c557c4440b47b46afba975e41877bd27a7 1 parent ab4d940
Marke Hallowell indiefan authored gwoo committed
13 libraries/lithium/test/Report.php
View
@@ -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;
}
/**
4 libraries/lithium/test/filter/Affected.php
View
@@ -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();
35 libraries/lithium/test/filter/Coverage.php
View
@@ -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;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.