/** * Test that a long set of arguments doesn't make useless output. * * @return void */ public function testHelpWithLotsOfArguments() { $parser = new ConsoleOptionParser('mycommand', false); $parser->addArgument('test', ['help' => 'A test option.'])->addArgument('test2', ['help' => 'A test option.'])->addArgument('test3', ['help' => 'A test option.'])->addArgument('test4', ['help' => 'A test option.'])->addArgument('test5', ['help' => 'A test option.'])->addArgument('test6', ['help' => 'A test option.'])->addArgument('test7', ['help' => 'A test option.'])->addArgument('model', ['help' => 'The model to make.', 'required' => true])->addArgument('other_longer', ['help' => 'Another argument.']); $formatter = new HelpFormatter($parser); $result = $formatter->text(); $expected = 'cake mycommand [-h] [arguments]'; $this->assertContains($expected, $result); }
/** * test that arguments with choices enforce them. * * @expectedException \Cake\Console\Exception\ConsoleException * @return void */ public function testPositionalArgWithChoices() { $parser = new ConsoleOptionParser('test', false); $parser->addArgument('name', ['choices' => ['mark', 'jose']])->addArgument('alias', ['choices' => ['cowboy', 'samurai']])->addArgument('weapon', ['choices' => ['gun', 'sword']]); $result = $parser->parse(['mark', 'samurai', 'sword']); $expected = ['mark', 'samurai', 'sword']; $this->assertEquals($expected, $result[1], 'Got the correct value.'); $result = $parser->parse(['jose', 'coder']); }