예제 #1
0
 /**
  * Test highlighting of unknown code files.
  *
  * @return void
  */
 public function testGenerateUnknownType()
 {
     $expectedFile = PHPCB_TEST_OUTPUT . DIRECTORY_SEPARATOR . basename(self::$xmlBasic) . '.html';
     $this->ioMock->expects($this->once())->method('createFile')->with($this->equalTo($expectedFile));
     $issueList = array(new Issue(self::$xmlBasic, 5, 5, 'finder', 'description', 'severity'));
     $this->viewReview->generate($issueList, self::$xmlBasic, dirname(self::$xmlBasic) . DIRECTORY_SEPARATOR);
 }
예제 #2
0
 /**
  * Main execute function for PHP_CodeBrowser.
  *
  * Following steps are resolved:
  * 1. Clean-up output directory
  * 2. Merge xml log files
  * 3. Generate XML file via error list from plugins
  * 4. Save the ErrorList as XML file
  * 5. Generate HTML output from XML
  * 6. Copy resources (css, js, images) from template directory to output
  *
  * @return void
  */
 public function run()
 {
     // clear and create output directory
     if (is_dir($this->htmlOutputDir)) {
         $this->ioHelper->deleteDirectory($this->htmlOutputDir);
     } elseif (is_file($this->htmlOutputDir)) {
         $this->ioHelper->deleteFile($this->htmlOutputDir);
     }
     $this->ioHelper->createDirectory($this->htmlOutputDir);
     // init needed classes
     $viewReview = new ViewReview(PHPCB_TEMPLATE_DIR, $this->htmlOutputDir, $this->ioHelper, $this->phpSuffixes);
     $sourceHandler = new SourceHandler($this->debugLog);
     if (isset($this->logDir)) {
         $issueXml = new IssueXml();
         // merge xml files
         $issueXml->addDirectory($this->logDir);
         // conversion of XML file cc to cb format
         foreach ($this->registeredPlugins as $className) {
             if (array_key_exists($className, $this->pluginOptions)) {
                 $plugin = new $className($issueXml, $this->pluginOptions[$className]);
             } else {
                 $plugin = new $className($issueXml);
             }
             $sourceHandler->addPlugin($plugin);
         }
     }
     if (isset($this->projectSource)) {
         foreach ($this->projectSource as $source) {
             if (is_dir($source)) {
                 $factory = new File_Iterator_Factory();
                 $suffixes = array_merge($this->phpSuffixes, array('php', 'js', 'css', 'html'));
                 $sourceHandler->addSourceFiles($factory->getFileIterator($source, $suffixes));
             } else {
                 $sourceHandler->addSourceFile($source);
             }
         }
     }
     array_walk($this->excludeExpressions, array($sourceHandler, 'excludeMatchingPCRE'));
     array_walk($this->excludePatterns, array($sourceHandler, 'excludeMatchingPattern'));
     $files = $sourceHandler->getFiles();
     if (!$files) {
         $viewReview->copyNoErrorsIndex();
     } else {
         // Get the path prefix all files have in common
         $commonPathPrefix = $sourceHandler->getCommonPathPrefix();
         foreach ($files as $file) {
             $viewReview->generate($file->getIssues(), $file->name(), $commonPathPrefix, $this->excludeOK);
         }
         // Copy needed resources (eg js libraries) to output directory
         $viewReview->copyResourceFolders();
         $viewReview->generateIndex($files, $this->excludeOK);
     }
 }