diff --git a/src/Shell/Task/TestTask.php b/src/Shell/Task/TestTask.php index 3057d0f61..1b5180cf3 100644 --- a/src/Shell/Task/TestTask.php +++ b/src/Shell/Task/TestTask.php @@ -142,12 +142,12 @@ public function outputTypeChoices() /** * Output a list of possible classnames you might want to generate a test for. * - * @param string $type The typename to get classes for. + * @param string $typeName The typename to get classes for. * @return array */ - public function outputClassChoices($type) + public function outputClassChoices($typeName) { - $type = $this->mapType($type); + $type = $this->mapType($typeName); $this->out( 'You must provide a class to bake a test for. Some possible options are:', 2 @@ -158,7 +158,7 @@ public function outputClassChoices($type) $this->out(++$i . '. ' . $option); } $this->out(''); - $this->out('Re-run your command as `cake bake ' . $type . ' `'); + $this->out('Re-run your command as `cake bake ' . $typeName . ' `'); return $options; } @@ -708,24 +708,15 @@ public function getOptionParser() { $parser = parent::getOptionParser(); + $types = array_keys($this->classTypes); + $types = array_merge($types, array_map('strtolower', $types)); + $parser->setDescription( 'Bake test case skeletons for classes.' )->addArgument('type', [ 'help' => 'Type of class to bake, can be any of the following:' . ' controller, model, helper, component or behavior.', - 'choices' => [ - 'Controller', 'controller', - 'Table', 'table', - 'Entity', 'entity', - 'Helper', 'helper', - 'Component', 'component', - 'Behavior', 'behavior', - 'Shell', 'shell', - 'shell_helper', - 'Cell', 'cell', - 'Form', 'form', - 'Mailer', 'mailer', - ] + 'choices' => $types, ])->addArgument('name', [ 'help' => 'An existing class to bake tests for.' ])->addOption('fixtures', [ diff --git a/tests/TestCase/Shell/Task/TestTaskTest.php b/tests/TestCase/Shell/Task/TestTaskTest.php index b08a71a4c..7c8489f99 100644 --- a/tests/TestCase/Shell/Task/TestTaskTest.php +++ b/tests/TestCase/Shell/Task/TestTaskTest.php @@ -197,6 +197,15 @@ public function testOutputClassOptionsForTable() 'CategoryThreadsTable' ]; + $this->io->expects($this->exactly(5)) + ->method('out') + ->withConsecutive( + ['You must provide a class to bake a test for. Some possible options are:', 2], + ['1. ArticlesTable'], + ['2. CategoryThreadsTable'], + [''], + ['Re-run your command as `cake bake Table `'] + ); $choices = $this->Task->outputClassChoices('Table'); $this->assertSame($expected, $choices); }