Beispiel #1
0
 /**
  * Test the add argument method.
  *
  * @return void
  *
  * @since  1.0
  *
  * @covers Joomla\Console\Command\AbstractCommand::addCommand
  */
 public function testaddCommand()
 {
     $this->instance->addCommand('bar', 'bar desc', array(new Option('a', 0, 'a desc'), new Option('b', 0, 'b desc')), function ($command) {
         if ($command->getOption('a')) {
             return 56;
         } else {
             return 65;
         }
     });
     $command = $this->instance->getChild('bar');
     $this->assertEquals(65, $command->execute(), 'Wrong exit code returned.');
     // Test option
     $this->instance->getInput()->set('a', 1);
     $this->assertEquals(56, $command->execute(), 'Wrong exit code returned.');
     // Test send an instance
     $this->instance->addCommand(new FooCommand());
     $this->assertInstanceOf('Joomla\\Console\\Tests\\Stubs\\FooCommand', $this->instance->getChild('foo'), 'Argument not FooCommand.');
 }