Inheritance: extends Phalcon\Cli\Task
Beispiel #1
0
 public function testTasks()
 {
     $di = new \Phalcon\DI\FactoryDefault\CLI();
     $di->set('data', function () {
         return "data";
     });
     $task = new MainTask();
     $task->setDI($di);
     $this->assertEquals($task->requestDiAction(), 'data');
     $this->assertEquals($task->helloAction(), 'Hello !');
     $this->assertEquals($task->helloAction('World'), 'Hello World!');
     $task2 = new EchoTask();
     $task2->setDI($di);
     $this->assertEquals($task2->mainAction(), 'echoMainAction');
 }
Beispiel #2
0
 public function testTasks()
 {
     $di = new \Phalcon\DI\FactoryDefault\CLI();
     $di['registry'] = function () {
         $registry = new \Phalcon\Registry();
         $registry->data = 'data';
         return $registry;
     };
     $task = new MainTask();
     $task->setDI($di);
     $this->assertEquals($task->requestRegistryAction(), 'data');
     $this->assertEquals($task->helloAction(), 'Hello !');
     $this->assertEquals($task->helloAction(array('World')), 'Hello World!');
     $task2 = new EchoTask();
     $task2->setDI($di);
     $this->assertEquals($task2->mainAction(), 'echoMainAction');
 }
Beispiel #3
0
 public function testTasks()
 {
     $this->specify("CLI Tasks don't return the expected results", function () {
         $di = new CliFactoryDefault();
         $di["registry"] = function () {
             $registry = new Registry();
             $registry->data = "data";
             return $registry;
         };
         $task = new \MainTask();
         $task->setDI($di);
         expect($task->requestRegistryAction())->equals("data");
         expect($task->helloAction())->equals("Hello !");
         expect($task->helloAction(["World"]))->equals("Hello World!");
         $task2 = new \EchoTask();
         $task2->setDI($di);
         expect($task2->mainAction())->equals("echoMainAction");
     });
 }
Beispiel #4
0
 public function testCallActionMethod()
 {
     $this->specify("CLI Dispatcher's callActionMethod doesn't work as expected", function () {
         $di = new CliFactoryDefault();
         $dispatcher = new Dispatcher();
         $di->setShared("dispatcher", $dispatcher);
         $dispatcher->setDI($di);
         $mainTask = new \MainTask();
         $mainTask->setDI($di);
         expect($dispatcher->callActionMethod($mainTask, 'mainAction', []))->equals('mainAction');
         expect($dispatcher->callActionMethod($mainTask, 'helloAction', ['World']))->equals('Hello World!');
         expect($dispatcher->callActionMethod($mainTask, 'helloAction', ['World', '.']))->equals('Hello World.');
     });
 }
 public function testCallActionMethod()
 {
     $di = new \Phalcon\DI\FactoryDefault\CLI();
     $dispatcher = new \Phalcon\CLI\Dispatcher();
     $di->setShared("dispatcher", $dispatcher);
     $dispatcher->setDI($di);
     $mainTask = new MainTask();
     $mainTask->setDI($di);
     $this->assertEquals($dispatcher->callActionMethod($mainTask, 'mainAction', []), 'mainAction');
     $this->assertEquals($dispatcher->callActionMethod($mainTask, 'helloAction', ['World']), 'Hello World!');
     $this->assertEquals($dispatcher->callActionMethod($mainTask, 'helloAction', ['World', '.']), 'Hello World.');
 }