|
|
@@ -55,6 +55,21 @@ class TestTask extends BakeTask {
|
|
|
);
|
|
|
|
|
|
/**
|
|
|
+ * 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.
|
|
|
*
|
|
|
* @var array
|
|
|
@@ -132,6 +147,8 @@ class TestTask extends BakeTask {
|
|
|
} elseif ($this->interactive) {
|
|
|
$this->getUserFixtures();
|
|
|
}
|
|
|
+ list($baseClass, $baseType) = $this->getBaseType($type);
|
|
|
+ App::uses($baseClass, $baseType);
|
|
|
App::uses($fullClassName, $realType);
|
|
|
|
|
|
$methods = array();
|
|
|
@@ -312,6 +329,20 @@ class TestTask extends BakeTask {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 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.
|
|
|
* No parent methods will be returned
|
|
|
*
|