/** * Parse the page data and load the optimization-specific details for one step * * @param TestInfo $testInfo Test information * @param TestStepResult $testStepResult Results of the step to get the grades for * @return array|null An array with all labels, scores, grades, weights, etc per score */ function getOptimizationGradesForStep($testInfo, $testStepResult) { // The function getOptimizationGradesForRun is more powerful as it can compute averages. // With one step, it will do exactly what we want, so we create an artificial run $singlestepRunResult = TestRunResults::fromStepResults($testInfo, $testStepResult->getRunNumber(), $testStepResult->isCachedRun(), array($testStepResult)); return getOptimizationGradesForRun($singlestepRunResult); }
private function getTestRunResultsWithInvalid() { $step4 = array('result' => 404, 'TTFB' => 500, 'loadTime' => 1000); // result is error $steps = $this->getTestStepArray(); $steps[] = TestStepResult::fromPageData($this->testInfo, $step4, 2, false, 4); return TestRunResults::fromStepResults($this->testInfo, 2, false, $steps); }
private static function singlestepRunFromPageData($testInfo, $runNumber, $cached, &$runs) { $cacheIdx = $cached ? 1 : 0; if (empty($runs[$cacheIdx])) { return null; } $step = TestStepResult::fromPageData($testInfo, $runs[$cacheIdx], $runNumber, $cached, 1); return TestRunResults::fromStepResults($testInfo, $runNumber, $cached, array($step)); }
private function getTestRunResults($numSteps) { $steps = $this->getTestStepArray(); return TestRunResults::fromStepResults($this->testInfo, 2, true, array_slice($steps, 0, $numSteps)); }
private function getSinglestepTestRunResultMock() { global $SINGLESTEP_RUN_RESULT_DATA; $mock = $this->getMockBuilder("TestStepResult")->disableOriginalConstructor()->getMock(); foreach ($SINGLESTEP_RUN_RESULT_DATA as $key => &$value) { $mock->method($key)->willReturn($value); } $mock->method("isCachedRun")->willReturn(false); $mock->method("getRunNumber")->willReturn(1); return TestRunResults::fromStepResults($this->testInfoMock, 1, false, array($mock)); }