/** * Test get arg. * * @return void * * @since 2.0 * * @covers Windwalker\Console\Command\AbstractCommand::getArgument */ public function testGetArgument() { $this->instance->getIO()->setArguments(array('flower', 'sakura')); $this->assertEquals('flower', $this->instance->getArgument(0), 'First arg not matched.'); $this->assertEquals('rose', $this->instance->getArgument(2, 'rose'), 'Default value not matched.'); $callback = function () { return 'Morning Glory'; }; $this->assertEquals('Morning Glory', $this->instance->getArgument(2, $callback), 'Default value not matched.'); }
/** * Test prompter ask. * * @return void * * @since 2.0 */ public function testAsk() { $this->setStream("y"); $this->instance->ask(); $this->assertEquals(trim($this->io->getTestOutput()), trim('Tell me something: ')); // Ask by invoke $this->setStream("n"); /** @var $prompter AbstractPrompter */ $prompter = $this->instance; $in = $prompter(); $this->assertEquals($in, 'n'); // Set as default in command getArgument $command = new Command('test', $prompter->getIO()); $this->setStream("fly"); $this->io->setTestOutput(''); $in = $command->getArgument(9, $this->instance); $this->assertEquals(trim($this->io->getTestOutput()), trim('Tell me something: ')); $this->assertEquals($in, 'fly'); }
/** * getArgument * * @param string $offset * @param string $default * * @return mixed */ public function getArgument($offset, $default = null) { return $this->command->getArgument($offset, $default); }