mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix issue where omitting a base class would break test generation.
Fixes #3115
This commit is contained in:
parent
bc2d449487
commit
73f29069de
1 changed files with 31 additions and 0 deletions
|
@ -54,6 +54,21 @@ class TestTask extends BakeTask {
|
||||||
'Helper' => 'View/Helper'
|
'Helper' => 'View/Helper'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapping between packages, and their baseclass + package.
|
||||||
|
* This is used to generate App::uses() call to autoload base
|
||||||
|
* classes if a developer has forgotten to do so.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $baseTypes = array(
|
||||||
|
'Model' => array('Model', 'Model'),
|
||||||
|
'Behavior' => array('ModelBehavior', 'Model'),
|
||||||
|
'Controller' => array('Controller', 'Controller'),
|
||||||
|
'Component' => array('Component', 'Controller'),
|
||||||
|
'Helper' => array('Helper', 'View')
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal list of fixtures that have been added so far.
|
* Internal list of fixtures that have been added so far.
|
||||||
*
|
*
|
||||||
|
@ -132,6 +147,8 @@ class TestTask extends BakeTask {
|
||||||
} elseif ($this->interactive) {
|
} elseif ($this->interactive) {
|
||||||
$this->getUserFixtures();
|
$this->getUserFixtures();
|
||||||
}
|
}
|
||||||
|
list($baseClass, $baseType) = $this->getBaseType($type);
|
||||||
|
App::uses($baseClass, $baseType);
|
||||||
App::uses($fullClassName, $realType);
|
App::uses($fullClassName, $realType);
|
||||||
|
|
||||||
$methods = array();
|
$methods = array();
|
||||||
|
@ -311,6 +328,20 @@ class TestTask extends BakeTask {
|
||||||
return $real;
|
return $real;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the base class and package name for a given type.
|
||||||
|
*
|
||||||
|
* @param string $package The package the class having a test
|
||||||
|
* generated for is in.
|
||||||
|
* @return array Array of class, type)
|
||||||
|
*/
|
||||||
|
public function getBaseType($type) {
|
||||||
|
if (empty($this->baseTypes[$type])) {
|
||||||
|
throw new CakeException(__d('cake_dev', 'Invalid package name'));
|
||||||
|
}
|
||||||
|
return $this->baseTypes[$type];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get methods declared in the class given.
|
* Get methods declared in the class given.
|
||||||
* No parent methods will be returned
|
* No parent methods will be returned
|
||||||
|
|
Loading…
Reference in a new issue