public function testCompleteXmlGeneration()
 {
     $this->tempDir = TestUtil::extractToTemp(__DIR__ . '/data/singlestepResults.zip');
     $testInfo = TestInfo::fromFiles($this->tempDir . '/singlestepResults');
     $imitatedPath = $this->imitatedResultPath($testInfo->getId());
     // we need to move the results to a directory structure that equal to the real one.
     // Then, we can go into the parent directory, so the relatece "testRoot" is the same as it would be in production
     // This is important, as during XML generation, some URLs contain the test path
     mkdir($this->tempDir . $imitatedPath, 0777, true);
     rename($this->tempDir . '/singlestepResults', $this->tempDir . $imitatedPath);
     $this->orgDir = getcwd();
     chdir($this->tempDir);
     $testRoot = "." . $imitatedPath;
     $testInfo = TestInfo::fromFiles($testRoot);
     $expectedXmlFile = __DIR__ . '/data/singlestepXmlResult.xml.gz';
     $testResults = TestResults::fromFiles($testInfo);
     $xmlGenerator = new XmlResultGenerator($testInfo, "http://wpt-test-vm", new FileHandler(), $this->allAdditionalInfo, true);
     $xmlGenerator->printAllResults($testResults, "loadTime", null);
     $this->assertThat(ob_get_contents(), IsCompatibleXMLConstraint::fromFile($expectedXmlFile));
 }
Beispiel #2
0
         $additionalInfo[] = XmlResultGenerator::INFO_DOMAIN_BREAKDOWN;
     }
     if (!isset($_GET['console']) || $_GET['console'] != 0) {
         $additionalInfo[] = XmlResultGenerator::INFO_CONSOLE;
     }
     $urlStart = "{$protocol}://{$host}{$uri}";
     header('Content-type: text/xml');
     header("Cache-Control: no-cache, must-revalidate");
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     $requestId = empty($_REQUEST['r']) ? "" : $_REQUEST['r'];
     $xmlGenerator = new XmlResultGenerator($testInfo, $urlStart, new FileHandler(), $additionalInfo, FRIENDLY_URLS);
     if (!empty($_REQUEST["multistepFormat"])) {
         $xmlGenerator->forceMultistepFormat(true);
     }
     $medianFvOnly = array_key_exists('rvmedian', $_REQUEST) && $_REQUEST['rvmedian'] == 'fv';
     $xmlGenerator->printAllResults($testResults, $median_metric, $requestId, $medianFvOnly);
     $msElapsed = number_format(microtime(true) - $msStart, 3);
     $msElapsedLoad = number_format($msLoad - $msStart, 3);
     logMsg("xmlResult ({$id}): {$msElapsed}s ({$msElapsedLoad}s to load page data)");
     ArchiveApi($id);
 } else {
     header('Content-type: text/xml');
     header("Cache-Control: no-cache, must-revalidate");
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
     echo "<response>\n";
     if (strlen($_REQUEST['r'])) {
         echo "<requestId>{$_REQUEST['r']}</requestId>\n";
     }
     // see if it was a valid test
     if ($test['test']['runs']) {