Esempio n. 1
0
 /**
  * Represents testSuites structure in HTML format.
  * 
  * @return string HTML code:
  * @code
  * 
  * <div class='$cssContainerDivClass'>
  *  ...
  *  <ul>
  *      <li class='$testsuite'><span>TestClassName1</span> <em>--> FileName1</em> </span>
  *           <ul>
  *               <li><div class='$testname'> test_methodName1 </div> </li>
  *               <li><div class='$testname'> test_methodName2 </div> <div class='$description'> ... fail description ... </div></li>
  *                 ...
  *           </ul>
  *      </li>
  *       ...
  *  </ul>
  * </div>
  * 
  * @endcode
  */
 public function toHtml()
 {
     if (!is_array($this->testSuites)) {
         return false;
     }
     //--- Generate HTML:
     $out = Html::arrayToList($this->testsStructure, 'ul', null, function (&$tag, &$body, &$attr) {
         if ($tag == 'li' && preg_match('/(.*)\\.\\w+$/', $body)) {
             $suiteFile = $this->targetPath . '/' . $body;
             $suite = $this->testSuites[$suiteFile];
             //--------------------------------
             if (is_array($suite["@attributes"])) {
                 $sa = $suite["@attributes"];
                 $fileName = $body;
                 $testsList = [];
                 if (is_array($suite["testcase"])) {
                     if (isset($suite["testcase"][0])) {
                         foreach ($suite["testcase"] as $testcase) {
                             $testsList[] = $this->toHtmlTestcase($testcase);
                         }
                     } else {
                         $testsList[] = $this->toHtmlTestcase($suite["testcase"]);
                     }
                 }
                 $testsList = Html::arrayToList($testsList);
                 $body = "<span>" . $sa["name"] . "</span> <em> --> {$fileName}</em>" . $testsList;
                 $attr['class'] = $this->cssTestSuite;
             } else {
                 $body .= ' --' . _('file error') . '!';
                 $attr['class'] = $this->cssStatusError;
             }
             //--------------------------------
         }
     });
     return "<div class='" . $this->cssContainerDivClass . "'>{$out}</div>";
 }
Esempio n. 2
0
 /**
  * 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]);
         }
     });
 }