Adding some i18n strings.

Moving test creation to TestTask.
This commit is contained in:
mark_story 2009-05-20 00:46:09 -04:00
parent e8eaf97dcf
commit de1b495afb
2 changed files with 40 additions and 29 deletions

View file

@ -215,9 +215,9 @@ class ControllerTask extends Shell {
function confirmController($controllerName, $useDynamicScaffold, $helpers, $components) { function confirmController($controllerName, $useDynamicScaffold, $helpers, $components) {
$this->out(''); $this->out('');
$this->hr(); $this->hr();
$this->out('The following controller will be created:'); $this->out(__('The following controller will be created:', true));
$this->hr(); $this->hr();
$this->out("Controller Name:\n\t$controllerName"); $this->out(sprintf(__("Controller Name:\n\t%s", true), $controllerName));
if (strtolower($useDynamicScaffold) == 'y') { if (strtolower($useDynamicScaffold) == 'y') {
$this->out("var \$scaffold;"); $this->out("var \$scaffold;");
@ -325,33 +325,9 @@ class ControllerTask extends Shell {
* @access private * @access private
*/ */
function bakeTest($className) { function bakeTest($className) {
$import = $className; $this->Test->plugin = $this->plugin;
if ($this->plugin) { $this->Test->connection = $this->connection;
$import = $this->plugin . '.' . $className; return $this->Test->bake('Controller', $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 = "<?php \n/* SVN FILE: $header$ */\n/* ". $className ."Controller Test cases generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
return $this->createFile($path . $filename, $content);
} }
/** /**

View file

@ -260,5 +260,40 @@ class TestTask extends Shell {
$content = "<?php \n/* SVN FILE: $header$ */\n/* ". $className ." Test cases generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>"; $content = "<?php \n/* SVN FILE: $header$ */\n/* ". $className ." Test cases generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
return $this->createFile($path . $filename, $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 = "<?php \n/* SVN FILE: $header$ */\n/* ". $className ."Controller Test cases generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
return $this->createFile($path . $filename, $content);
}
} }
?> ?>