/**
  * Run a full system test based on phpcs output.
  *
  * @return void
  */
 public function test__main()
 {
     $controller = new CbCLIController(null, array(PHPCB_SOURCE), PHPCB_TEST_OUTPUT, array(), array(), array(), new CbIOHelper(), Log::singleton('null'), array('php'));
     $controller->addErrorPlugins(array('CbErrorCheckstyle', 'CbErrorPMD', 'CbErrorCPD', 'CbErrorPadawan', 'CbErrorCoverage', 'CbErrorCRAP'));
     $controller->run();
     $this->assertFileExists(PHPCB_TEST_OUTPUT . '/index.html');
     $this->assertFileExists(PHPCB_TEST_OUTPUT . '/CLIController.php.html');
     $this->assertFileExists(PHPCB_TEST_OUTPUT . '/css');
 }
예제 #2
0
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * @category  PHP_CodeBrowser
 * @package   PHP_CodeBrowser
 * @author    Elger Thiele <*****@*****.**>
 * @copyright 2007-2009 Mayflower GmbH
 * @license   http://www.opensource.org/licenses/bsd-license.php  BSD License
 * @version   SVN: $Id$
 * @link      http://www.phpunit.de/
 * @since     File available since 1.0
 */
if (strpos('@php_dir@', '@php_dir') === 0) {
    require_once dirname(__FILE__) . '/../src/CLIController.php';
} else {
    require_once '@php_dir@/PHP_CodeBrowser/CLIController.php';
}
CbCLIController::main();
예제 #3
0
    /**
     * Main method called by script
     *
     * @return void
     */
    public static function main()
    {
        $parser = self::createCommandLineParser();
        try {
            $opts = $parser->parse()->options;
        } catch (Exception $e) {
            $parser->displayError($e->getMessage());
        }
        $errors = self::errorsForOpts($opts);
        if ($errors) {
            foreach ($errors as $e) {
                error_log("[Error] {$e}\n");
            }
            exit(1);
        }
        // Convert the --ignore arguments to patterns
        if (null !== $opts['ignore']) {
            $dirSep = preg_quote(DIRECTORY_SEPARATOR, '/');
            foreach (explode(',', $opts['ignore']) as $ignore) {
                $ig = realpath($ignore);
                if (!$ig) {
                    error_log("[Warning] {$ignore} does not exists");
                } else {
                    $ig = preg_quote($ig, '/');
                    $opts['excludePCRE'][] = "/^{$ig}({$dirSep}|\$)/";
                }
            }
        }
        // init new CLIController
        $controller = new CbCLIController($opts['log'], $opts['source'] ? $opts['source'] : array(), $opts['output'], $opts['excludePCRE'] ? $opts['excludePCRE'] : array(), $opts['excludePattern'] ? $opts['excludePattern'] : array(), $opts['crapThreshold'] ? array('CRAP' => array('threshold' => $opts['crapThreshold'])) : array(), new CbIOHelper(), $opts['debugExcludes'] ? Log::factory('console', '', 'PHPCB') : Log::factory('null'), $opts['phpSuffixes'] ? explode(',', $opts['phpSuffixes']) : array('php'), $opts['excludeOK'] ? $opts['excludeOK'] : false);
        $plugins = self::getAvailablePlugins();
        if ($opts['disablePlugin']) {
            foreach ($opts['disablePlugin'] as $idx => $val) {
                $opts['disablePlugin'][$idx] = strtolower($val);
            }
            foreach ($plugins as $pluginKey => $plugin) {
                $name = substr($plugin, strlen('CbError'));
                if (in_array(strtolower($name), $opts['disablePlugin'])) {
                    // Remove it from the plugins list
                    unset($plugins[$pluginKey]);
                }
            }
        }
        $controller->addErrorPlugins($plugins);
        try {
            $controller->run();
        } catch (Exception $e) {
            error_log(<<<HERE
[Error] {$e->getMessage()}

{$e->getTraceAsString()}
HERE
);
        }
    }
예제 #4
0
    /**
     * Main method called by script
     *
     * @return void
     */
    public static function main()
    {
        // register autoloader
        spl_autoload_register(array(new CbAutoloader(), 'autoload'));
        $parser = self::createCommandLineParser();
        try {
            $opts = $parser->parse()->options;
        } catch (Exception $e) {
            $parser->displayError($e->getMessage());
        }
        $errors = self::errorsForOpts($opts);
        if ($errors) {
            foreach ($errors as $e) {
                error_log("[Error] {$e}\n");
            }
            exit(1);
        }
        // init new CLIController
        $controller = new CbCLIController($opts['log'], isset($opts['source']) ? $opts['source'] : array(), $opts['output'], isset($opts['excludePCRE']) ? $opts['excludePCRE'] : array(), isset($opts['excludePattern']) ? $opts['excludePattern'] : array(), new CbIOHelper());
        $controller->addErrorPlugins(array('CbErrorCheckstyle', 'CbErrorPMD', 'CbErrorCPD', 'CbErrorPadawan', 'CbErrorCoverage', 'CbErrorCRAP'));
        try {
            $controller->run();
        } catch (Exception $e) {
            error_log(<<<HERE
[Error] {$e->getMessage()}

{$e->getTraceAsString()}
HERE
);
        }
    }
예제 #5
0
 /**
  * Main method called by script
  *
  * @return void
  */
 public static function main()
 {
     $xmlLogDir = null;
     $sourceFolder = null;
     $htmlOutput = null;
     $xmlFileName = 'cbCodeBrowser.xml';
     // register autoloader
     spl_autoload_register(array(new CbAutoloader(), 'autoload'));
     $argv = $_SERVER['argv'];
     foreach ($argv as $key => $argument) {
         switch ($argument) {
             case '--log':
                 $xmlLogDir = $argv[$key + 1];
                 break;
             case '--source':
                 $sourceFolder = isset($argv[$key + 1]) ? $argv[$key + 1] : NULL;
                 break;
             case '--output':
                 $htmlOutput = $argv[$key + 1];
                 break;
             case '--help':
             case '-h':
                 self::printHelp();
                 break;
             case '--version':
                 self::printVersion();
                 break;
         }
     }
     // Check for directories
     if (!is_dir($xmlLogDir) || !is_dir($htmlOutput) || isset($sourceFolder) && !is_dir($sourceFolder)) {
         printf("Error: \n%s%s%s\n", !is_dir($xmlLogDir) ? "- xml log directory [{$xmlLogDir}] not found\n" : '', isset($sourceFolder) && !is_dir($sourceFolder) ? "- project source directory [{$sourceFolder}] not found\n" : '', !is_dir($htmlOutput) ? "- output directory [{$htmlOutput}] not found\n" : '');
         self::printHelp();
     }
     printf("Generating PHP_CodeBrowser files\n");
     // init new CLIController
     $controller = new CbCLIController($xmlLogDir, $sourceFolder, $htmlOutput, $htmlOutput . '/' . $xmlFileName);
     $controller->addErrorPlugins(array('CbErrorCheckstyle', 'CbErrorPMD', 'CbErrorCPD', 'CbErrorPadawan'));
     try {
         $controller->run();
     } catch (Exception $e) {
         printf("PHP-CodeBrowser Error: \n%s\n", $e->getMessage());
     }
     print "\n" . PHP_Timer::resourceUsage() . "\n";
 }