Esempio n. 1
0
 public function testBasicApi()
 {
     $options = new Ergo_Console_Options(array('testscript.php', '-v', '--after', '2008-01-01'));
     $options->define(array('--after=2009-01-01', '-v', '--flag'));
     $this->assertTrue($options->has('-v'));
     $this->assertFalse($options->has('--flag'));
     $this->assertTrue($options->has('--after'));
     $this->assertEqual($options->value('--after'), '2008-01-01');
     $this->assertEqual($options->values('--after'), array('2008-01-01'));
 }
Esempio n. 2
0
$classloader->register()->includePaths(array(BASEDIR . "/classes", BASEDIR . "/lib/simpletest"));
$options = new Ergo_Console_Options($argv, array('--file=false', '--dir=false', '--help', '-h'));
// show usage
if ($options->has('--help', '-h')) {
    echo <<<EOM

CLI test runner, defaults to running Ergo tests

  --file <path>\t\tadds a specific test file
  --dir <path>    \tadds a directory containing classes/ and tests/
  --help            this documentation.

EOM;
    exit(0);
}
$testFiles = array_filter($options->values('--file'));
$dirs = array_filter($options->values('--dir'));
// default to this app's tests
if (!$options->has('--file', '--dir')) {
    $dirs[] = BASEDIR;
}
// add all directories
foreach ($dirs as $dir) {
    $classloader->includePaths(array($dir . '/classes', $dir . '/tests'));
}
// write an include path
$classloader->export();
require_once 'autorun.php';
$suite = new TestSuite('Tests');
if ($testFiles) {
    foreach ($testFiles as $test) {