Skip to content

Commit

Permalink
Merge pull request #378 from cakephp/issue-289
Browse files Browse the repository at this point in the history
Fix task tests not working
  • Loading branch information
markstory authored Nov 23, 2017
2 parents 0ba0910 + 4551fbe commit 3c3c512
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/Shell/Task/TestTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -158,7 +158,7 @@ public function outputClassChoices($type)
$this->out(++$i . '. ' . $option);
}
$this->out('');
$this->out('Re-run your command as `cake bake ' . $type . ' <classname>`');
$this->out('Re-run your command as `cake bake ' . $typeName . ' <classname>`');

return $options;
}
Expand Down Expand Up @@ -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', [
Expand Down
9 changes: 9 additions & 0 deletions tests/TestCase/Shell/Task/TestTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <classname>`']
);
$choices = $this->Task->outputClassChoices('Table');
$this->assertSame($expected, $choices);
}
Expand Down

0 comments on commit 3c3c512

Please sign in to comment.