Skip to content
This repository
Browse code

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
@@ -133,18 +133,17 @@ public function run() {
133 133 /**
134 134 * Collects Results from the test filters and aggregates them.
135 135 *
136   - * @param string $class Fully namespaced classname of the filter
137   - * for which to aggregate results.
138   - * @param array $results Array of the filter results packaged for
  136 + * @param string $class Classname of the filter for which to aggregate results.
  137 + * @param array $results Array of the filter results for
139 138 * later analysis by the filter itself.
140 139 * @return void
141 140 */
142 141 public function collectFilterResults($class, $results) {
143   - $testClass = key($results);
144   - if(!isset($this->results['filters'][$class][$testClass])) {
145   - $this->results['filters'][$class][$testClass] = array();
  142 + //$testClass = key($results);
  143 + if(!isset($this->results['filters'][$class])) {
  144 + $this->results['filters'][$class] = array();
146 145 }
147   - $this->results['filters'][$class][$testClass] = $results[$testClass];
  146 + $this->results['filters'][$class][] = $results;
148 147 }
149 148
150 149 /**
4 libraries/lithium/test/filter/Affected.php
@@ -26,8 +26,8 @@ class Affected extends \lithium\test\filter\Base {
26 26 /**
27 27 * Holds metrics for this filter.
28 28 *
29   - * @see lihtium\test\filter\Affected::apply()
30   - * @see lihtium\test\filter\Affected::output()
  29 + * @see lithium\test\filter\Affected::apply()
  30 + * @see lithium\test\filter\Affected::output()
31 31 * @var array Keys are affected classes, values (if available) corresponding test case classes.
32 32 */
33 33 protected static $_metrics = array();
35 libraries/lithium/test/filter/Coverage.php
@@ -47,7 +47,7 @@ public static function apply($report, $tests, $options = array()) {
47 47 $chain->next($self, $params, $chain);
48 48 $results = xdebug_get_code_coverage();
49 49 xdebug_stop_code_coverage();
50   - $report->collectFilterResults(__CLASS__, Coverage::collect($self->subject(), $results, $options));
  50 + $report->collectFilterResults(__CLASS__, array( $self->subject() => $results ));
51 51 }));
52 52 return $tests;
53 53 }
@@ -63,6 +63,7 @@ public static function apply($report, $tests, $options = array()) {
63 63 * instances each line was called.
64 64 */
65 65 public static function analyze($results, $filterResults, $classes = array()) {
  66 + $filterResults = static::collect($filterResults);
66 67 $classes = $classes ?: array_filter(get_declared_classes(), function($class) {
67 68 return (!is_subclass_of($class, 'lithium\test\Unit'));
68 69 });
@@ -168,30 +169,36 @@ public static function output($format, $analysis) {
168 169 /**
169 170 * Collects code coverage analysis results from `xdebug_get_code_coverage()`.
170 171 *
171   - * @param string $class Class name that these test results correspond to.
172   - * @param array $results A results array from `xdebug_get_code_coverage()`.
  172 + * @param array $filterResults An array of results arrays from `xdebug_get_code_coverage()`.
173 173 * @param array $options Set of options defining how results should be collected.
174 174 * @return array The packaged filter results.
175 175 * @see lithium\test\Coverage::analyze()
176 176 * @todo Implement $options['merging']
177 177 */
178   - public static function collect($class, $results, $options = array()) {
  178 + public static function collect($filterResults, $options = array()) {
179 179 $defaults = array('merging' => 'class');
180 180 $options += $defaults;
181   - $filterResults[$class] = array();
  181 + $packagedResults = array();
182 182
183   - foreach ($results as $file => $lines) {
184   - unset($results[$file][0]);
185   - }
  183 + foreach ($filterResults as $results) {
  184 + $class = key($results);
  185 + $results = $results[$class];
  186 + foreach ($results as $file => $lines) {
  187 + unset($results[$file][0]);
  188 + }
186 189
187   - switch ($options['merging']) {
188   - case 'class':
189   - default:
190   - $filterResults[$class][] = $results;
191   - break;
  190 + switch ($options['merging']) {
  191 + case 'class':
  192 + default:
  193 + if (!isset($packagedResults[$class])) {
  194 + $packagedResults[$class] = array();
  195 + }
  196 + $packagedResults[$class][] = $results;
  197 + break;
  198 + }
192 199 }
193 200
194   - return $filterResults;
  201 + return $packagedResults;
195 202 }
196 203
197 204 /**

0 comments on commit 0fddf6c

Please sign in to comment.
Something went wrong with that request. Please try again.