/**
  * @test
  */
 public function addingSectionsIsPossible()
 {
     $environment = PHP_ConfigReport_Analyzer::PRODUCTION;
     $report = new PHP_ConfigReport_Report($environment, PHP_VERSION);
     $section1 = new PHP_ConfigReport_Report_Section('Test1');
     $report->addSection($section1);
     $this->assertSame(array($section1), $report->getSections());
     $section2 = new PHP_ConfigReport_Report_Section('Test2');
     $report->addSection($section2);
     $this->assertSame(array($section1, $section2), $report->getSections());
 }
Beispiel #2
0
 /**
  * Displays report or generates its files
  *
  * @param PHP_ConfigReport_Report $report Report
  * @return void
  */
 public function render(PHP_ConfigReport_Report $report)
 {
     $consoleOutput = new ezcConsoleOutput();
     $consoleOutput->formats->extensionName->style = array('bold');
     $consoleOutput->formats->columnTitle->style = array('bold');
     $consoleOutput->formats->error->bgcolor = 'red';
     $consoleOutput->formats->warning->bgcolor = 'yellow';
     $consoleOutput->outputLine('PHP version: ' . $report->getPhpVersion());
     $consoleOutput->outputLine('Environment: ' . $report->getEnvironment());
     $noIssue = true;
     foreach ($report->getSections() as $section) {
         if ($section->hasIssues()) {
             $noIssue = false;
             $consoleOutput->outputLine();
             $consoleOutput->outputLine($section->getExtensionName(), 'extensionName');
             $table = new ezcConsoleTable($consoleOutput, $this->_width);
             $table[0]->format = 'columnTitle';
             $table[0][0]->content = 'Directive';
             $table[0][1]->content = 'Level';
             $table[0][2]->content = 'Type';
             $table[0][3]->content = 'Value';
             $table[0][4]->content = 'Suggested value';
             $table[0][5]->content = 'Comments';
             foreach ($section->getIssues() as $index => $issue) {
                 $table[$index + 1]->format = $issue->getLevel();
                 $directiveName = $issue->getDirectiveName();
                 if (is_array($directiveName)) {
                     $directiveName = implode(' / ', $directiveName);
                 }
                 $table[$index + 1][0]->content = $directiveName;
                 $table[$index + 1][1]->content = $issue->getLevel();
                 $table[$index + 1][2]->content = $issue->getType();
                 $directiveActualValue = $issue->getDirectiveActualValue();
                 if (is_array($directiveActualValue)) {
                     $directiveActualValue = implode(' / ', $directiveActualValue);
                 }
                 $table[$index + 1][3]->content = $directiveActualValue;
                 $directiveSuggestedValue = $issue->getDirectiveSuggestedValue();
                 if (is_array($directiveSuggestedValue)) {
                     $directiveSuggestedValue = implode(' / ', $directiveSuggestedValue);
                 }
                 $table[$index + 1][4]->content = $directiveSuggestedValue;
                 $table[$index + 1][5]->content = $issue->getComments();
             }
             $table->outputTable();
             $consoleOutput->outputLine();
         }
     }
     if ($noIssue) {
         $consoleOutput->outputLine('No issue found.');
         $consoleOutput->outputLine();
     }
 }
 /**
  * Generates and returns report
  *
  * @return PHP_ConfigReport_Report Report
  */
 public function getReport()
 {
     $report = new PHP_ConfigReport_Report($this->_environment, $this->_phpVersion);
     $extensions = array();
     $path = dirname(__FILE__) . '/Analyzer';
     $iterator = new DirectoryIterator($path);
     foreach ($iterator as $item) {
         if ($item->isFile() && !$item->isDot() && 'Abstract.php' != substr($item->getFilename(), -12)) {
             $extensions[] = substr($item->getFilename(), 0, -4);
         }
     }
     sort($extensions);
     foreach ($extensions as $extension) {
         $class = "PHP_ConfigReport_Analyzer_{$extension}";
         $instance = new $class($this->_config, $this->_environment, $this->_phpVersion, $this->_loadedExtensions);
         $report->addSection($instance->getReportSection());
     }
     return $report;
 }