Skip to content

Commit

Permalink
Fixing the ControllerTestCase tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 9, 2011
1 parent 7b7dabc commit ca32143
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
15 changes: 11 additions & 4 deletions lib/Cake/TestSuite/ControllerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,13 @@ private function _testAction($url = '', $options = array()) {
* @return Controller Mocked controller
*/
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'));
}
ClassRegistry::flush();
Expand Down Expand Up @@ -295,10 +301,11 @@ public function generate($controller, $mocks = array()) {
if ($methods === true) {
$methods = array();
}
list($plugin, $name) = pluginSplit($component);
if (!App::import('Component', $component)) {
list($plugin, $name) = pluginSplit($component, true);
App::uses($name . 'Component', $plugin . 'Controller/Component');
if (!class_exists($name . 'Component')) {
throw new MissingComponentFileException(array(
'file' => Inflector::underscore($name) . '.php',
'file' => $name . 'Component.php',
'class' => $name.'Component'
));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ protected function _getViewFileName($name = null) {
if (strpos($name, DS) === false && $name[0] !== '.') {
$name = $this->viewPath . DS . $subDir . Inflector::underscore($name);
} elseif (strpos($name, DS) !== false) {
if ($name{0} === DS || $name{1} === ':') {
if ($name[0] === DS || $name[1] === ':') {
if (is_file($name)) {
return $name;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/tests/cases/libs/controller_test_case.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ function setUp() {
parent::setUp();
App::build(array(
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'controllers' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS),
'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS)
'Controller' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS),
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS)
));
$this->Case = new ControllerTestCase();
Router::reload();
Expand Down

0 comments on commit ca32143

Please sign in to comment.