$testName, 'method' => $method, 'time' => $time, ]; parent::endTest($test, $time); } /** * @param \PHPUnit\Framework\TestResult $result TestResult * @return void */ public function printFooter(\PHPUnit\Framework\TestResult $result) { $timers = collection(self::$timers) ->sortBy('time', SORT_DESC, SORT_NUMERIC) ->take(10) ->groupBy('test'); if ($this->verbose) { $this->writeTimersVerbose($timers); } else { $this->writeTimers($timers); } parent::printFooter($result); } /** * @param Collection $timers Timers */ private function writeTimersVerbose(Collection $timers) { foreach ($timers as $testClassName => $methodTimers) { $this->write($testClassName); $this->writeNewLine(); foreach ($methodTimers as $methodResults) { $timeAsString = number_format($methodResults['time'] * 1000) . 'ms'; $classParts = namespaceSplit($methodResults['test']); $methodName = substr($classParts[1] . '::' . $methodResults['method'], 0, 70); $pad = 78 - (strlen($methodName) + strlen($timeAsString)); $this->write(' ' . $methodName . str_pad('', $pad, '.') . $timeAsString); $this->writeNewLine(); } } $this->writeNewLine(); } /** * @param Collection $timers Timers */ private function writeTimers(Collection $timers) { foreach ($timers as $testClassName => $methodTimers) { $totalTime = (new Collection($methodTimers))->sumOf('time'); $timeAsString = number_format($totalTime * 1000) . 'ms'; $testClassName = substr($testClassName, 0, 70); $pad = 80 - (strlen($testClassName) + strlen($timeAsString)); $this->write($testClassName . str_pad('', $pad, '.') . $timeAsString); $this->writeNewLine(); } $this->writeNewLine(); } }