mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
Fixing several problems related to creating unit tests (ticket #1624)
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3829 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
4cfafba726
commit
a1be115dd1
1 changed files with 6 additions and 5 deletions
|
@ -1175,7 +1175,7 @@ class Bake {
|
||||||
if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') {
|
if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') {
|
||||||
$wannaDoAdmin = $this->getInput("Would you like to create the methods for admin routing?", array('y','n'), 'n');
|
$wannaDoAdmin = $this->getInput("Would you like to create the methods for admin routing?", array('y','n'), 'n');
|
||||||
} else {
|
} else {
|
||||||
$wannaUseScaffold = $this->getInput("Would you like to use scaaffolding?", array('y','n'), 'y');
|
$wannaUseScaffold = $this->getInput("Would you like to use scaffolding?", array('y','n'), 'y');
|
||||||
}
|
}
|
||||||
|
|
||||||
$admin = null;
|
$admin = null;
|
||||||
|
@ -1463,7 +1463,7 @@ class Bake {
|
||||||
* @return Success
|
* @return Success
|
||||||
*/
|
*/
|
||||||
function doUnitTest() {
|
function doUnitTest() {
|
||||||
if (is_dir('vendors'.DS.'simpletest') || is_dir(APP_DIR.DS.'vendors'.DS.'simpletest')) {
|
if (is_dir(VENDORS.'simpletest') || is_dir(ROOT.DS.APP_DIR.DS.'vendors'.DS.'simpletest')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$unitTest = $this->getInput('Cake test suite not installed. Do you want to bake unit test files anyway?', array('y','n'), 'y');
|
$unitTest = $this->getInput('Cake test suite not installed. Do you want to bake unit test files anyway?', array('y','n'), 'y');
|
||||||
|
@ -1715,19 +1715,20 @@ class Bake {
|
||||||
$out .= "\n\t/*\n\tfunction testMe()\n\t{\n";
|
$out .= "\n\t/*\n\tfunction testMe()\n\t{\n";
|
||||||
$out .= "\t\t\$result = \$this->object->doSomething();\n";
|
$out .= "\t\t\$result = \$this->object->doSomething();\n";
|
||||||
$out .= "\t\t\$expected = 1;\n";
|
$out .= "\t\t\$expected = 1;\n";
|
||||||
$out .= "\t\t\$this->assertEquals(\$result, \$expected);\n\t}\n\t*/\n}";
|
$out .= "\t\t\$this->assertEqual(\$result, \$expected);\n\t}\n\t*/\n}";
|
||||||
$path = MODEL_TESTS;
|
$path = MODEL_TESTS;
|
||||||
$filename = $this->__singularName($className).'.test.php';
|
$filename = $this->__singularName($className).'.test.php';
|
||||||
break;
|
break;
|
||||||
case 'controller':
|
case 'controller':
|
||||||
|
$out .= "loadController('$className');\n\n";
|
||||||
$out .= "class {$className}ControllerTestCase extends UnitTestCase {\n";
|
$out .= "class {$className}ControllerTestCase extends UnitTestCase {\n";
|
||||||
$out .= "\tvar \$object = null;\n\n";
|
$out .= "\tvar \$object = null;\n\n";
|
||||||
$out .= "\tfunction setUp()\n\t{\n\t\t\$this->object = new {$className}();\n";
|
$out .= "\tfunction setUp()\n\t{\n\t\t\$this->object = new {$className}Controller();\n";
|
||||||
$out .= "\t}\n\n\tfunction tearDown()\n\t{\n\t\tunset(\$this->object);\n\t}\n";
|
$out .= "\t}\n\n\tfunction tearDown()\n\t{\n\t\tunset(\$this->object);\n\t}\n";
|
||||||
$out .= "\n\t/*\n\tfunction testMe()\n\t{\n";
|
$out .= "\n\t/*\n\tfunction testMe()\n\t{\n";
|
||||||
$out .= "\t\t\$result = \$this->object->doSomething();\n";
|
$out .= "\t\t\$result = \$this->object->doSomething();\n";
|
||||||
$out .= "\t\t\$expected = 1;\n";
|
$out .= "\t\t\$expected = 1;\n";
|
||||||
$out .= "\t\t\$this->assertEquals(\$result, \$expected);\n\t}\n\t*/\n}";
|
$out .= "\t\t\$this->assertEqual(\$result, \$expected);\n\t}\n\t*/\n}";
|
||||||
$path = CONTROLLER_TESTS;
|
$path = CONTROLLER_TESTS;
|
||||||
$filename = $this->__pluralName($className.'Controller').'.test.php';
|
$filename = $this->__pluralName($className.'Controller').'.test.php';
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue