/**
  * Run a full system test based on phpcs output.
  *
  * @return void
  */
 public function testMain()
 {
     $controller = new CLIController(null, array(PHPCB_SOURCE_DIR), PHPCB_TEST_OUTPUT, array(), array(), array(), new IOHelper(), new Logger('PHPCodeBrowser'), array('php'));
     $controller->addErrorPlugins(array('ErrorCheckstyle', 'ErrorPMD', 'ErrorCPD', 'ErrorPadawan', 'ErrorCoverage', 'ErrorCRAP'));
     $controller->run();
     $this->assertFileExists(PHPCB_TEST_OUTPUT . '/index.html');
     $this->assertFileExists(PHPCB_TEST_OUTPUT . '/CLIController.php.html');
     $this->assertFileExists(PHPCB_TEST_OUTPUT . '/css');
 }
Example #2
0
    /**
     * Executes the current command.
     *
     * @param InputInterface $input An InputInterface instance
     * @param OutputInterface $output
     *
     * @return null|integer null or 0 if everything went fine, or an error code
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->checkErrors($input);
        $extensions = $this->handleBackwardCompatibility($input->getOption('extensions'));
        $ignore = $this->handleBackwardCompatibility($input->getOption('ignore'));
        $excludePCRE = $input->getOption('excludePCRE');
        $excludePCRE = $this->convertIgnores($ignore, $excludePCRE);
        $logger = new Logger('PHPCodeBrowser');
        if (!$input->getOption('debugExcludes')) {
            $logger->pushHandler(new NullHandler());
        }
        // init new CLIController
        $controller = new CLIController($input->getOption('log'), $input->getOption('source'), $input->getOption('output'), $excludePCRE, $input->getOption('exclude'), array('CRAP' => array('threshold' => $input->getOption('crapThreshold'))), new IOHelper(), $logger, array_merge($extensions, array('php')), (bool) $input->getOption('excludeOK'));
        $plugins = $this->getAvailablePlugins();
        $plugins = $this->disablePlugins($input->getOption('disablePlugin'), $plugins);
        $controller->addErrorPlugins($plugins);
        try {
            $controller->run();
        } catch (Exception $e) {
            error_log(<<<HERE
                [Error] {$e->getMessage()}

{$e->getTraceAsString()}
HERE
);
        }
        return 0;
    }