Correl Roush
08bc427e4a
git-svn-id: file:///srv/svn/scanner/trunk@19 a0501263-5b7a-4423-a8ba-1edf086583e7
34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
require_once 'PHPUnit/Framework.php';
|
|
|
|
class ScannerTests extends PHPUnit_Framework_TestCase {
|
|
private function run_scanner($options = array(), $files = array()) {
|
|
$modules = array_key_exists('modules', $options) ? (is_array($options['modules']) ? $options['modules'] : explode(',', $options['modules'])) : array();
|
|
$base = array_key_exists('base', $options) ? $options['base'] : false;
|
|
$files = is_array($files) ? $files : array($files);
|
|
|
|
$command = 'php ../scanner.php -q';
|
|
if (count($modules) > 0)
|
|
$command .= ' -m ' . implode(',', $modules);
|
|
if ($base)
|
|
$command .= ' -b ' . $base;
|
|
$command .= ' ' . implode(' ', $files);
|
|
return shell_exec($command);
|
|
}
|
|
|
|
public function testModuleLint() {
|
|
$result = $this->run_scanner(
|
|
array('modules' => 'lint'),
|
|
'samples/lint_failure.php'
|
|
);
|
|
$this->assertEquals(file_get_contents('samples/lint_failure.txt'), $result);
|
|
}
|
|
public function testModulePatterns() {
|
|
$result = $this->run_scanner(
|
|
array('modules' => 'pattern'),
|
|
'samples/patterns.php'
|
|
);
|
|
$this->assertEquals(file_get_contents('samples/patterns.txt'), $result);
|
|
}
|
|
}
|
|
?>
|