public function testOverrideDescription() { $container = new Container(); $task = new DefinedTask(); $task->setName("test"); $task->setDescription("custom description"); $application = new Application($container); $application->setAutoExit(false); $application->add(new TestCommand($task)); $command = $application->find("test"); $this->assertEquals("custom description", $command->getDescription()); }
protected function setUp() { $this->container = new Container(); $this->definedTask = DefinedTask::newInstance("test", $this->container); $this->input = new ArrayInput(array("command" => "test")); $this->output = new BufferedOutput(); }
public function testDefault() { $container = new Container(); $task = new DefinedTask(); $task->setName("test"); $task->setDescription("Description of the test task"); $task->setClosure(function ($task) { $task->getOutput()->write("test message for closure task command"); }); $application = new Application($container); $application->setAutoExit(false); $application->add(new ClosureTaskCommand($task)); $command = $application->find("test"); $commandTester = new CommandTester($command); $commandTester->execute(array("command" => $command->getName())); $this->assertEquals("test message for closure task command", $commandTester->getDisplay()); }
public function testDefault() { $container = new Container(); $task = new DefinedTask(); $task->setName("test001"); $application = new Application($container); $application->setAutoExit(false); $application->add(new ServerCommand($task)); $command = $application->find("test"); $commandTester = new CommandTester($command); // Don't test. This command blocks function. Don't return. /* $commandTester->execute( array("command" => $command->getName()) ); echo $commandTester->getDisplay(); */ }
public function register() { $args = func_get_args(); if (count($args) < 2) { throw new \RuntimeException("Missing argument. Must 2 arguments at minimum."); } $task = DefinedTask::newInstance($args[0], $this->getContainer()); if ($args[1] instanceof \Closure) { // Task is a closure $task->setClosure($args[1]); } elseif (is_string($args[1])) { // Task is a command class. $task->setCommandClass($args[1]); } $this->container->set("tasks/" . $task->getName(), $task); return $task; }
public function testConfig() { $task = DefinedTask::newInstance("test", $this->container); $task->config(array("a" => "b")); $this->assertSame(array("a" => "b"), $task->getConfig()); }