mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding some i18n strings.
Moving test creation to TestTask.
This commit is contained in:
parent
e8eaf97dcf
commit
de1b495afb
2 changed files with 40 additions and 29 deletions
|
@ -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 = "<?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);
|
||||
$this->Test->plugin = $this->plugin;
|
||||
$this->Test->connection = $this->connection;
|
||||
return $this->Test->bake('Controller', $className);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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}?>";
|
||||
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);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue