/** * Test the add argument method. * * @return void * * @since 2.0 * * @covers Windwalker\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->getIO()->setOption('a', 1); $this->assertEquals(56, $command->execute(), 'Wrong exit code returned.'); // Test send an instance $this->instance->addCommand(new FooCommand()); $this->assertInstanceOf('Windwalker\\Console\\Test\\Stubs\\FooCommand', $this->instance->getChild('foo'), 'Argument not FooCommand.'); }