public function command($nameOrCommand, $callable = null) { if ($nameOrCommand instanceof Command) { $command = $nameOrCommand; } else { if (!is_callable($callable)) { throw new \InvalidArgumentException('$callable must be a valid callable with the command\'s code'); } $command = new Command($nameOrCommand); $command->setCode($callable); } $this['console']->add($command); return $command; }
/** * Tests the command method to see if the command is properly set and the * Cilex application is added as container. */ public function testCommand() { $this->assertFalse($this->fixture['console']->has('demo:greet')); $this->fixture->command(new \Cilex\Command\GreetCommand()); $this->assertTrue($this->fixture['console']->has('demo:greet')); $this->assertSame($this->fixture, $this->fixture['console']->get('demo:greet')->getContainer()); }