/** * To find all existing PHPUnit results xml-files. * * @param string $targetPath (Option) new path to PHPUnit results xml-files. * @return hash Array of testSuites structure: * @code * Array ( [someFile.xml] => Array ( [@attributes] => Array ( [name] => someTest [file] => someFile.xml [tests] => [assertions] => [failures] => 1 [errors] => [time] => [base] => basePath ) [testcase] => Array ( [0] => Array ( [@attributes] => Array ( [name] => [class] => [file] => [line] => [assertions] => [time] => ) [failure] => some failure ) ) [someFile2.xml] => Array( ... ) ... * @endcode */ public function findAll($targetPath = NULL) { //--- Find all xml files of results: $targetPath = $this->getTargetPath($targetPath); $files = Files::globFiles($targetPath, "\\.xml\$", NULL, true); $this->testsStructure = Files::getFilesTree($files); $testSuites = array(); //--- Load results to common array: if (is_array($files)) { foreach ($files as $fileName => $basePath) { $data = Data::load($fileName, false); if (!empty($data["testsuite"]["@attributes"])) { $data["testsuite"]["@attributes"]["base"] = $basePath; $testSuites[$fileName] = $data["testsuite"]; } } } //echo "<listing>"; print_r($testSuites); exit; $this->testSuites = $testSuites; return $this->testSuites; }
/** * Returns HTML code list contains tree of files spesified by class properties. * * @return string HTML code */ public function getNavigation() { //--- Create real path: $this->path = realpath($this->path); //--- Create filePatterns from given stripExtention: if ($this->stripExtention && !$this->filePatterns) { $this->filePatterns = '.*' . preg_quote($this->stripExtention) . '$'; } //--- Select all files by patterns: $files = Files::globFiles($this->path, $this->filePatterns, $this->excludePatterns, $this->recursive); //--- Get requested file: $activeFile = $_REQUEST[$this->routerPrefix]; //--- Add file extention: if ($activeFile && $this->stripExtention) { $activeFile .= $this->stripExtention; } //--- Check: Is it my file?: if (!isset($files[rtrim($this->path, '/') . '/' . $activeFile])) { $activeFile = ''; } //--- Get default file (first): if (!$activeFile) { $name = array_keys($files)[0]; $base = array_values($files)[0]; $activeFile = preg_replace('/^' . preg_quote($base . '/', '/') . '/', '', $name); } //--- Set current item: $this->currentItem = $activeFile; //--- Create HTML code of tree: return Html::arrayToList(Files::getFilesTree($files), $this->listType, null, function (&$tag, &$body, &$attr) { if ($tag == 'li' && preg_match('/(.*)\\.\\w+$/', $body, $m)) { if ($body == $this->currentItem) { $attr['class'] = $this->cssActive; } if ($this->stripExtention) { $body = preg_replace('/' . preg_quote($this->stripExtention) . '$/', '', $body); } $body = Html::getElement('a', basename($m[1]), ['href' => '?' . $this->routerPrefix . '=' . $body]); } }); }