Skip to content

Commit

Permalink
Fix a few small issues when the type is 'controller'.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Mar 31, 2014
1 parent cd2d0a6 commit 59f9f34
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Console/Command/Task/TestTask.php
Expand Up @@ -512,6 +512,7 @@ public function getOptionParser() {
'help' => __d('cake_console', 'CamelCased name of the plugin to bake tests for.')
])->addOption('force', [
'short' => 'f',
'boolean' => true,
'help' => __d('cake_console', 'Force overwriting existing files without prompting.')
])->addOption('fixtures', [
'help' => __d('cake_console', 'A comma separated list of fixture names you want to include.')
Expand Down
5 changes: 3 additions & 2 deletions src/Console/Templates/default/classes/test.ctp
Expand Up @@ -16,14 +16,15 @@
*/
use Cake\Utility\Inflector;

$isController = strtolower($type) === 'controller';
echo "<?php\n";
?>
namespace <?= $baseNamespace; ?>\Test\TestCase\<?= $subNamespace ?>;

<?php foreach ($uses as $dependency): ?>
use <?= $dependency; ?>;
<?php endforeach; ?>
<?php if ($type === 'Controller'): ?>
<?php if ($isController): ?>
use Cake\TestSuite\ControllerTestCase;
<?php else: ?>
use Cake\TestSuite\TestCase;
Expand All @@ -32,7 +33,7 @@ use Cake\TestSuite\TestCase;
/**
* <?= $fullClassName; ?> Test Case
*/
<?php if ($type === 'Controller'): ?>
<?php if ($isController): ?>
class <?= $className; ?>Test extends ControllerTestCase {
<?php else: ?>
class <?= $className; ?>Test extends TestCase {
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Console/Command/Task/TestTaskTest.php
Expand Up @@ -384,7 +384,7 @@ public function testBakePrefixControllerTest() {
->method('createFile')
->will($this->returnValue(true));

$result = $this->Task->bake('Controller', 'Admin\Posts');
$result = $this->Task->bake('controller', 'Admin\Posts');

$this->assertContains("use TestApp\Controller\Admin\PostsController", $result);
$this->assertContains('class PostsControllerTest extends ControllerTestCase', $result);
Expand Down

0 comments on commit 59f9f34

Please sign in to comment.