Exemplo n.º 1
0
 public function testPresistenceOfOptions()
 {
     $config = new \CodeReview\Config(array(), array($this, 'getLatestVersion'));
     $config->parseInput(array());
     $this->assertEquals('/', $config->getSubPath());
     $this->assertEquals('11.22', $config->getMaxVersion());
     $this->assertEquals(false, $config->isIncludeDisabledPluginsEnabled());
     $this->assertEquals(true, $config->isSkipInactivePluginsEnabled());
     $this->assertEquals(true, $config->isDeprecatedFunctionsTestEnabled());
     $this->assertEquals(true, $config->isPrivateFunctionsTestEnabled());
     $this->assertEquals(false, $config->isFixProblemsEnabled());
     //change stuff
     $config->subPath = '//test/invalid/path';
     $this->assertEquals('//test/invalid/path', $config->getSubPath());
     $config->maxVersion = '10.24';
     $this->assertEquals('10.24', $config->getMaxVersion());
     $config->includeDisabledPlugins = true;
     $this->assertEquals(true, $config->isIncludeDisabledPluginsEnabled());
     $this->assertEquals(false, $config->isSkipInactivePluginsEnabled());
     $config->includeDisabledPlugins = false;
     $this->assertEquals(false, $config->isIncludeDisabledPluginsEnabled());
     $this->assertEquals(true, $config->isSkipInactivePluginsEnabled());
     $config->findDeprecatedFunctions = true;
     $this->assertEquals(true, $config->isDeprecatedFunctionsTestEnabled());
     $config->findDeprecatedFunctions = false;
     $this->assertEquals(false, $config->isDeprecatedFunctionsTestEnabled());
     $config->findPrivateFunctions = true;
     $this->assertEquals(true, $config->isPrivateFunctionsTestEnabled());
     $config->findPrivateFunctions = false;
     $this->assertEquals(false, $config->isPrivateFunctionsTestEnabled());
     $config->fixProblems = true;
     $this->assertEquals(true, $config->isFixProblemsEnabled());
     $config->fixProblems = false;
     $this->assertEquals(false, $config->isFixProblemsEnabled());
 }
Exemplo n.º 2
0
 public function testAnalysisAllPluginsPrivate11()
 {
     $config = new \CodeReview\Config(array(), array($this, 'getLatestVersion'));
     $config->parseInput(array('subpath' => '', 'version' => '1.1', 'include_disabled_plugins' => true, 'find_deprecated_functions' => true, 'find_private_functions' => true, 'fix_problems' => false));
     $analyzer = new \CodeReview\Analyzer($config);
     $analyzer->analyze();
     $stringOutput = $analyzer->outputReport();
     $this->assertContains("Subpath selected <strong>/</strong>", $stringOutput);
     $this->assertContains("Max version: 1.1", $stringOutput);
     $this->assertContains("Skipped inactive plugins: no", $stringOutput);
     $this->assertContains("Search for deprecated functions usage: yes", $stringOutput);
     $this->assertContains("Search for private functions usage: yes", $stringOutput);
     $this->assertContains("Attempt to fix problems: no", $stringOutput);
     $this->assertContains("Found 1 problems in 1 files", $stringOutput);
     $this->assertContains("Found 0 fixes in 1 files", $stringOutput);
     $this->assertContains("Processed 13 files total", $stringOutput);
     $this->assertNotContains("Time taken: ", $stringOutput);
     $ds = DIRECTORY_SEPARATOR;
     $errorMessage2 = 'Function call: foobar_private_api (use of function marked private is unsafe)';
     $instance2Path = 'test_files/fake_elgg/' . $ds . 'mod' . $ds . 'ugly_plugin' . $ds . 'classes' . $ds . 'ugly_plugin.php';
     $this->assertContains($instance2Path . "\n    Line 13:\t" . $errorMessage2, $stringOutput);
 }
Exemplo n.º 3
0
<?php

admin_gatekeeper();
ini_set('max_execution_time', 0);
$options = new \CodeReview\Config();
$options->parseInput($vars);
/*
 * Produce output
 */
echo '<pre>';
$body = '';
$mt = microtime(true);
try {
    $analyzer = new \CodeReview\Analyzer($options);
    $analyzer->analyze();
    $body .= $analyzer->outputReport();
} catch (\CodeReview\IOException $e) {
    echo "*** Error: " . $e->getMessage() . " ***\n";
}
$body .= sprintf("Time taken: %.4fs\n", microtime(true) - $mt);
echo $body;
echo '</pre>';