mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Removing garbage methods.
This commit is contained in:
parent
3d39feeac9
commit
928ec36acf
1 changed files with 0 additions and 112 deletions
|
@ -400,117 +400,5 @@ class TestTask extends Shell {
|
|||
}
|
||||
return "new $fullClassName()\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the extra stuff needed
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function __extras($class) {
|
||||
$extras = null;
|
||||
switch ($class) {
|
||||
case 'Model':
|
||||
$extras = "\n\tvar \$cacheSources = false;";
|
||||
$extras .= "\n\tvar \$useDbConfig = 'test_suite';\n";
|
||||
break;
|
||||
}
|
||||
return $extras;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a test for a Model object.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function bakeModelTest($className) {
|
||||
$fixtureInc = 'app';
|
||||
if ($this->plugin) {
|
||||
$fixtureInc = 'plugin.'.Inflector::underscore($this->plugin);
|
||||
}
|
||||
|
||||
$fixture[] = "'{$fixtureInc}." . Inflector::underscore($className) ."'";
|
||||
|
||||
if (!empty($associations)) {
|
||||
$assoc[] = Set::extract($associations, 'belongsTo.{n}.className');
|
||||
$assoc[] = Set::extract($associations, 'hasOne.{n}.className');
|
||||
$assoc[] = Set::extract($associations, 'hasMany.{n}.className');
|
||||
foreach ($assoc as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $class) {
|
||||
$fixture[] = "'{$fixtureInc}." . Inflector::underscore($class) ."'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$fixture = join(", ", $fixture);
|
||||
|
||||
$import = $className;
|
||||
if (isset($this->plugin)) {
|
||||
$import = $this->plugin . '.' . $className;
|
||||
}
|
||||
|
||||
$out = "App::import('Model', '$import');\n\n";
|
||||
$out .= "class {$className}TestCase extends CakeTestCase {\n";
|
||||
$out .= "\tvar \${$className} = null;\n";
|
||||
$out .= "\tvar \$fixtures = array($fixture);\n\n";
|
||||
$out .= "\tfunction startTest() {\n";
|
||||
$out .= "\t\t\$this->{$className} =& ClassRegistry::init('{$className}');\n";
|
||||
$out .= "\t}\n\n";
|
||||
$out .= "\tfunction endTest() {\n";
|
||||
$out .= "\t\tunset(\$this->{$className});\n";
|
||||
$out .= "\t}\n\n";
|
||||
$out .= "\tfunction test{$className}Instance() {\n";
|
||||
$out .= "\t\t\$this->assertTrue(is_a(\$this->{$className}, '{$className}'));\n";
|
||||
$out .= "\t}\n\n";
|
||||
$out .= "}\n";
|
||||
|
||||
$path = MODEL_TESTS;
|
||||
if (isset($this->plugin)) {
|
||||
$pluginPath = 'plugins' . DS . Inflector::underscore($this->plugin) . DS;
|
||||
$path = APP . $pluginPath . 'tests' . DS . 'cases' . DS . 'models' . DS;
|
||||
}
|
||||
|
||||
$filename = Inflector::underscore($className).'.test.php';
|
||||
$this->out("\nBaking unit test for $className...");
|
||||
|
||||
$header = '$Id';
|
||||
$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