Ejemplo n.º 1
0
 public function setup()
 {
     vfsStream::setup('std');
     $this->stdin = vfsStream::url('std/input');
     $this->stdout = vfsStream::url('std/output');
     $this->stderr = vfsStream::url('std/error');
     ClearIce::setStreamUrl('input', $this->stdin);
     ClearIce::setStreamUrl('output', $this->stdout);
     ClearIce::setStreamUrl('error', $this->stderr);
 }
Ejemplo n.º 2
0
 public function testStringCommandDeclaration()
 {
     global $argv;
     $argv = ['test', 'mycommand'];
     ClearIce::reset();
     ClearIce::setStreamUrl('output', vfsStream::url('std/output'));
     ClearIce::addCommands('mycommand');
     $options = ClearIce::parse();
     $this->assertEquals('mycommand', $options['__command__']);
 }
Ejemplo n.º 3
0
 function testHelpCommandUsage()
 {
     global $argv;
     $argv = array('test', 'help', 'generate');
     vfsStream::setup('std');
     $stdout = vfsStream::url('std/output');
     ClearIce::setStreamUrl('output', $stdout);
     ClearIce::setUsage("[input] [options]..");
     ClearIce::setDescription("Simple Wiki version 1.0\nA sample or should I say dummy wiki app to help explain ClearIce. This app practically does nothing.");
     ClearIce::setFootnote("Hope you had a nice time learning about ClearIce. We're pretty sure your cli apps would no longer be boring to work with.\n\nReport bugs to bugs@clearice.tld");
     ClearIce::addHelp();
     ClearIce::parse();
     $this->assertFileEquals('tests/data/help_for_command_usage.txt', vfsStream::url('std/output'));
 }
Ejemplo n.º 4
0
 public function testInterractive()
 {
     ClearIce::setStreamUrl('error', vfsStream::url("home/error.out"));
     ClearIce::setStreamUrl('output', vfsStream::url("home/standard.out"));
     ClearIce::setStreamUrl('input', vfsStream::url("home/responses.in"));
     // Write the input for the interractive test
     if (getenv('YENTU_HOST') === false) {
         file_put_contents(vfsStream::url("home/responses.in"), "{$GLOBALS['DRIVER']}\n" . "{$GLOBALS['DB_FILE']}\n");
     } else {
         file_put_contents(vfsStream::url("home/responses.in"), "{$GLOBALS['DRIVER']}\n" . "{$GLOBALS['DB_HOST']}\n" . "\n" . "{$GLOBALS['DB_NAME']}\n" . "{$GLOBALS['DB_USER']}\n" . "{$GLOBALS['DB_PASSWORD']}\n");
     }
     $initCommand = new \yentu\commands\Init();
     \yentu\Yentu::setDefaultHome(vfsStream::url('home/yentu'));
     ob_start();
     $initCommand->run(array('interractive' => true));
     $this->runAssertions();
 }
Ejemplo n.º 5
0
 protected function setupStreams()
 {
     vfsStream::setup('home');
     \yentu\Yentu::setDefaultHome(vfsStream::url('home/yentu'));
     \clearice\ClearIce::setStreamUrl('output', vfsStream::url('home/output.txt'));
 }
Ejemplo n.º 6
0
 public function testStrictWithHelp()
 {
     global $argv;
     $argv = array("test.php", '--an-unknown');
     vfsStream::setup('std');
     $stderr = vfsStream::url('std/error');
     ClearIce::addOptions('a-known');
     ClearIce::setStrict(true);
     ClearIce::setStreamUrl('error', $stderr);
     ClearIce::addHelp();
     ClearIce::parse();
     $this->assertStringEqualsFile($stderr, "test.php: invalid option -- an-unknown\nTry `test.php --help` for more information\n");
 }