lithium\test\filter\Profiler::analyze()

public static method

Analyzes the results of a test run and returns the result of the analysis.

Parameters

  • object $report

    The report instance running this filter and aggregating results

  • array $options

    Not used.

Returns

array

The results of the analysis.

Source

	public static function analyze($report, array $options = []) {
		$results = $report->results['group'];
		$collectedResults = static::collect($report->results['filters'][__CLASS__]);
		extract($collectedResults, EXTR_OVERWRITE);
		$metrics = [];

		foreach ($results as $testCase) {
			foreach ((array) $testCase as $assertion) {
				if ($assertion['result'] !== 'pass' && $assertion['result'] !== 'fail') {
					continue;
				}
				$class = $classMap[$assertion['class']];

				if (!isset($metrics[$class])) {
					$metrics[$class] = ['assertions' => 0];
				}
				$metrics[$class]['assertions']++;
			}
		}

		foreach ($filterResults as $class => $methods) {
			foreach ($methods as $methodName => $timers) {
				foreach ($timers as $title => $value) {
					if (!isset($metrics[$class][$title])) {
						$metrics[$class][$title] = 0;
					}
					$metrics[$class][$title] += $value;
				}
			}
		}

		$totals = [];
		foreach ($metrics as $class => $data) {
			foreach ($data as $title => $value) {
				if (isset(static::$_metrics[$title])) {
					if (isset($totals[$title]['value'])) {
						$totals[$title]['value'] += $value;
					} else {
						$totals[$title]['value'] = $value;
					}

					if (!isset($totals[$title]['format'])) {
						$format = static::$_metrics[$title]['format'];
						$totals[$title]['formatter'] = static::$_formatters[$format];
					}
				}
			}
		}

		$metrics['totals'] = $totals;
		return $metrics;
	}