From de1b495afbab6fddb2176a87f9f3d3c02ad0b9b6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 20 May 2009 00:46:09 -0400 Subject: [PATCH] Adding some i18n strings. Moving test creation to TestTask. --- cake/console/libs/tasks/controller.php | 34 ++++--------------------- cake/console/libs/tasks/test.php | 35 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/cake/console/libs/tasks/controller.php b/cake/console/libs/tasks/controller.php index 5e42a53d8..2cf5ad343 100644 --- a/cake/console/libs/tasks/controller.php +++ b/cake/console/libs/tasks/controller.php @@ -215,9 +215,9 @@ class ControllerTask extends Shell { function confirmController($controllerName, $useDynamicScaffold, $helpers, $components) { $this->out(''); $this->hr(); - $this->out('The following controller will be created:'); + $this->out(__('The following controller will be created:', true)); $this->hr(); - $this->out("Controller Name:\n\t$controllerName"); + $this->out(sprintf(__("Controller Name:\n\t%s", true), $controllerName)); if (strtolower($useDynamicScaffold) == 'y') { $this->out("var \$scaffold;"); @@ -325,33 +325,9 @@ class ControllerTask extends Shell { * @access private */ function bakeTest($className) { - $import = $className; - if ($this->plugin) { - $import = $this->plugin . '.' . $className; - } - $out = "App::import('Controller', '$import');\n\n"; - $out .= "class Test{$className} extends {$className}Controller {\n"; - $out .= "\tvar \$autoRender = false;\n}\n\n"; - $out .= "class {$className}ControllerTest extends CakeTestCase {\n"; - $out .= "\tvar \${$className} = null;\n\n"; - $out .= "\tfunction startTest() {\n\t\t\$this->{$className} = new Test{$className}();"; - $out .= "\n\t\t\$this->{$className}->constructClasses();\n\t}\n\n"; - $out .= "\tfunction test{$className}ControllerInstance() {\n"; - $out .= "\t\t\$this->assertTrue(is_a(\$this->{$className}, '{$className}Controller'));\n\t}\n\n"; - $out .= "\tfunction endTest() {\n\t\tunset(\$this->{$className});\n\t}\n}\n"; - - $path = CONTROLLER_TESTS; - if (isset($this->plugin)) { - $pluginPath = 'plugins' . DS . Inflector::underscore($this->plugin) . DS; - $path = APP . $pluginPath . 'tests' . DS . 'cases' . DS . 'controllers' . DS; - } - - $filename = Inflector::underscore($className).'_controller.test.php'; - $this->out("\nBaking unit test for $className..."); - - $header = '$Id'; - $content = ""; - return $this->createFile($path . $filename, $content); + $this->Test->plugin = $this->plugin; + $this->Test->connection = $this->connection; + return $this->Test->bake('Controller', $className); } /** diff --git a/cake/console/libs/tasks/test.php b/cake/console/libs/tasks/test.php index 5d35acba4..879e80349 100644 --- a/cake/console/libs/tasks/test.php +++ b/cake/console/libs/tasks/test.php @@ -260,5 +260,40 @@ class TestTask extends Shell { $content = ""; return $this->createFile($path . $filename, $content); } + +/** + * Create a test case for a controller. + * + * @return void + **/ + function bakeControllerTest() { + $import = $className; + if ($this->plugin) { + $import = $this->plugin . '.' . $className; + } + $out = "App::import('Controller', '$import');\n\n"; + $out .= "class Test{$className} extends {$className}Controller {\n"; + $out .= "\tvar \$autoRender = false;\n}\n\n"; + $out .= "class {$className}ControllerTest extends CakeTestCase {\n"; + $out .= "\tvar \${$className} = null;\n\n"; + $out .= "\tfunction startTest() {\n\t\t\$this->{$className} = new Test{$className}();"; + $out .= "\n\t\t\$this->{$className}->constructClasses();\n\t}\n\n"; + $out .= "\tfunction test{$className}ControllerInstance() {\n"; + $out .= "\t\t\$this->assertTrue(is_a(\$this->{$className}, '{$className}Controller'));\n\t}\n\n"; + $out .= "\tfunction endTest() {\n\t\tunset(\$this->{$className});\n\t}\n}\n"; + + $path = CONTROLLER_TESTS; + if (isset($this->plugin)) { + $pluginPath = 'plugins' . DS . Inflector::underscore($this->plugin) . DS; + $path = APP . $pluginPath . 'tests' . DS . 'cases' . DS . 'controllers' . DS; + } + + $filename = Inflector::underscore($className).'_controller.test.php'; + $this->out("\nBaking unit test for $className..."); + + $header = '$Id'; + $content = ""; + return $this->createFile($path . $filename, $content); + } } ?> \ No newline at end of file