Exemplo n.º 1
0
 public function testArgumentOptions()
 {
     $this->specify("CLI Console doesn't work with options set in arguments", function () {
         $di = new CliFactoryDefault();
         $di->setShared('router', function () {
             $router = new Router(true);
             return $router;
         });
         $console = new Console();
         $console->setDI($di);
         $dispatcher = $console->getDI()->getShared('dispatcher');
         $console->setArgument(array('php', '-opt1', '--option2', '--option3=hoge', 'main', 'hello', 'World', '######'))->handle();
         expect($dispatcher->getTaskName())->equals('main');
         expect($dispatcher->getActionName())->equals('hello');
         expect($dispatcher->getParams())->equals(array('World', '######'));
         expect($dispatcher->getReturnedValue())->equals('Hello World######');
         expect($dispatcher->getOptions())->equals(array('opt1' => true, 'option2' => true, 'option3' => 'hoge'));
         $console->setArgument(array('php', 'main', '-opt1', 'hello', '--option2', 'World', '--option3=hoge', '######'))->handle();
         expect($dispatcher->getTaskName())->equals('main');
         expect($dispatcher->getActionName())->equals('hello');
         expect($dispatcher->getParams())->equals(array('World', '######'));
         expect($dispatcher->getReturnedValue())->equals('Hello World######');
         expect($dispatcher->getOptions())->equals(array('opt1' => true, 'option2' => true, 'option3' => 'hoge'));
     });
 }