Пример #1
0
function ArrayToXML($array)
{
    $ret = '';
    if (is_array($array)) {
        foreach ($array as $key => $val) {
            if (is_numeric($key)) {
                $key = 'value';
            }
            $key = preg_replace('/[^a-zA-Z0-9\\.\\-_]/', '_', $key);
            $ret .= "<{$key}>";
            if (is_array($val)) {
                $ret .= "\n" . ArrayToXML($val);
            } else {
                $ret .= xml_entities($val);
            }
            $ret .= "</{$key}>\n";
        }
    }
    return $ret;
}
Пример #2
0
function Arr2XML($data, $parent = "") {
	return ArrayToXML($data, $parent);
}
Пример #3
0
 /**
  * @param TestStepResult $stepResult Results for the step to be printed
  */
 private function printStepResults($stepResult)
 {
     if (empty($stepResult)) {
         return;
     }
     $run = $stepResult->getRunNumber();
     $cached = $stepResult->isCachedRun() ? 1 : 0;
     $step = $stepResult->getStepNumber();
     $testRoot = $this->testInfo->getRootDirectory();
     $testId = $this->testInfo->getId();
     $localPaths = new TestPaths($testRoot, $run, $cached, $step);
     $nameOnlyPaths = new TestPaths("", $run, $cached, $step);
     $urlPaths = new TestPaths($this->baseUrl . substr($testRoot, 1), $run, $cached, $step);
     echo "<results>\n";
     echo ArrayToXML($stepResult->getRawResults());
     $this->printPageSpeed($stepResult);
     echo "</results>\n";
     // links to the relevant pages
     $urlGenerator = UrlGenerator::create($this->friendlyUrls, $this->baseUrl, $testId, $run, $cached, $step);
     echo "<pages>\n";
     echo "<details>" . htmlspecialchars($urlGenerator->resultPage("details")) . "</details>\n";
     echo "<checklist>" . htmlspecialchars($urlGenerator->resultPage("performance_optimization")) . "</checklist>\n";
     echo "<breakdown>" . htmlspecialchars($urlGenerator->resultPage("breakdown")) . "</breakdown>\n";
     echo "<domains>" . htmlspecialchars($urlGenerator->resultPage("domains")) . "</domains>\n";
     echo "<screenShot>" . htmlspecialchars($urlGenerator->resultPage("screen_shot")) . "</screenShot>\n";
     echo "</pages>\n";
     // urls for the relevant images
     echo "<thumbnails>\n";
     echo "<waterfall>" . htmlspecialchars($urlGenerator->thumbnail("waterfall.png")) . "</waterfall>\n";
     echo "<checklist>" . htmlspecialchars($urlGenerator->thumbnail("optimization.png")) . "</checklist>\n";
     if ($this->fileHandler->fileExists($localPaths->screenShotFile())) {
         echo "<screenShot>" . htmlspecialchars($urlGenerator->thumbnail("screen.jpg")) . "</screenShot>\n";
     }
     echo "</thumbnails>\n";
     echo "<images>\n";
     echo "<waterfall>" . htmlspecialchars($urlGenerator->generatedImage("waterfall")) . "</waterfall>\n";
     echo "<connectionView>" . htmlspecialchars($urlGenerator->generatedImage("connection")) . "</connectionView>\n";
     echo "<checklist>" . htmlspecialchars($urlGenerator->optimizationChecklistImage()) . "</checklist>\n";
     if ($this->fileHandler->fileExists($localPaths->screenShotFile())) {
         echo "<screenShot>" . htmlspecialchars($urlGenerator->getFile($nameOnlyPaths->screenShotFile())) . "</screenShot>\n";
     }
     if ($this->fileHandler->fileExists($localPaths->screenShotPngFile())) {
         echo "<screenShotPng>" . htmlspecialchars($urlGenerator->getFile($nameOnlyPaths->screenShotPngFile())) . "</screenShotPng>\n";
     }
     echo "</images>\n";
     // raw results (files accessed directly on the file system, but via URL)
     echo "<rawData>\n";
     if ($this->fileHandler->gzFileExists($localPaths->devtoolsScriptTimingFile())) {
         echo "<scriptTiming>" . htmlspecialchars($urlGenerator->getGZip($nameOnlyPaths->devtoolsScriptTimingFile())) . "</scriptTiming>\n";
     }
     if ($this->fileHandler->gzFileExists($localPaths->headersFile())) {
         echo "<headers>" . $urlPaths->headersFile() . "</headers>\n";
     }
     if ($this->fileHandler->gzFileExists($localPaths->bodiesFile())) {
         echo "<bodies>" . $urlPaths->bodiesFile() . "</bodies>\n";
     }
     if ($this->fileHandler->gzFileExists($localPaths->pageDataFile())) {
         echo "<pageData>" . $urlPaths->pageDataFile() . "</pageData>\n";
     }
     if ($this->fileHandler->gzFileExists($localPaths->requestDataFile())) {
         echo "<requestsData>" . $urlPaths->requestDataFile() . "</requestsData>\n";
     }
     if ($this->fileHandler->gzFileExists($localPaths->utilizationFile())) {
         echo "<utilization>" . $urlPaths->utilizationFile() . "</utilization>\n";
     }
     $this->printPageSpeedData($stepResult);
     echo "</rawData>\n";
     // video frames
     $progress = $stepResult->getVisualProgress();
     if (array_key_exists('frames', $progress) && is_array($progress['frames']) && count($progress['frames'])) {
         echo "<videoFrames>\n";
         foreach ($progress['frames'] as $ms => $frame) {
             echo "<frame>\n";
             echo "<time>{$ms}</time>\n";
             echo "<image>" . htmlspecialchars($urlGenerator->getFile($frame['file'], $nameOnlyPaths->videoDir())) . "</image>\n";
             echo "<VisuallyComplete>{$frame['progress']}</VisuallyComplete>\n";
             echo "</frame>\n";
         }
         echo "</videoFrames>\n";
     }
     $this->printAdditionalInformation($stepResult, false);
 }