mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-28 06:46:30 +00:00
Fixing the ControllerTestCase tests
This commit is contained in:
parent
7b7dabce48
commit
ca32143292
3 changed files with 15 additions and 8 deletions
lib/Cake
|
@ -254,7 +254,13 @@ class ControllerTestCase extends CakeTestCase {
|
||||||
* @return Controller Mocked controller
|
* @return Controller Mocked controller
|
||||||
*/
|
*/
|
||||||
public function generate($controller, $mocks = array()) {
|
public function generate($controller, $mocks = array()) {
|
||||||
if (!class_exists($controller.'Controller') && App::import('Controller', $controller) === false) {
|
list($plugin, $controller) = pluginSplit($controller);
|
||||||
|
if ($plugin) {
|
||||||
|
App::uses($plugin . 'AppController', $plugin . '.Controller');
|
||||||
|
$plugin .= '.';
|
||||||
|
}
|
||||||
|
App::uses($controller . 'Controller', $plugin . 'Controller');
|
||||||
|
if (!class_exists($controller.'Controller')) {
|
||||||
throw new MissingControllerException(array('controller' => $controller.'Controller'));
|
throw new MissingControllerException(array('controller' => $controller.'Controller'));
|
||||||
}
|
}
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
|
@ -295,10 +301,11 @@ class ControllerTestCase extends CakeTestCase {
|
||||||
if ($methods === true) {
|
if ($methods === true) {
|
||||||
$methods = array();
|
$methods = array();
|
||||||
}
|
}
|
||||||
list($plugin, $name) = pluginSplit($component);
|
list($plugin, $name) = pluginSplit($component, true);
|
||||||
if (!App::import('Component', $component)) {
|
App::uses($name . 'Component', $plugin . 'Controller/Component');
|
||||||
|
if (!class_exists($name . 'Component')) {
|
||||||
throw new MissingComponentFileException(array(
|
throw new MissingComponentFileException(array(
|
||||||
'file' => Inflector::underscore($name) . '.php',
|
'file' => $name . 'Component.php',
|
||||||
'class' => $name.'Component'
|
'class' => $name.'Component'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -687,7 +687,7 @@ class View extends Object {
|
||||||
if (strpos($name, DS) === false && $name[0] !== '.') {
|
if (strpos($name, DS) === false && $name[0] !== '.') {
|
||||||
$name = $this->viewPath . DS . $subDir . Inflector::underscore($name);
|
$name = $this->viewPath . DS . $subDir . Inflector::underscore($name);
|
||||||
} elseif (strpos($name, DS) !== false) {
|
} elseif (strpos($name, DS) !== false) {
|
||||||
if ($name{0} === DS || $name{1} === ':') {
|
if ($name[0] === DS || $name[1] === ':') {
|
||||||
if (is_file($name)) {
|
if (is_file($name)) {
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,9 +123,9 @@ class ControllerTestCaseTest extends CakeTestCase {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
|
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
|
||||||
'controllers' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS),
|
'Controller' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS),
|
||||||
'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
|
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
|
||||||
'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS)
|
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS)
|
||||||
));
|
));
|
||||||
$this->Case = new ControllerTestCase();
|
$this->Case = new ControllerTestCase();
|
||||||
Router::reload();
|
Router::reload();
|
||||||
|
|
Loading…
Add table
Reference in a new issue