Permalink
Browse files

Fixing issues where ControllerTestCase couldn't properly hit plugin

controllers.
Fixing some formatting.
Fixes #1918
  • Loading branch information...
markstory committed Aug 20, 2011
1 parent 70f4737 commit 7276f3357d0290829e528244b7a29b56cc2a6595
@@ -268,8 +268,21 @@ public function testTestAction() {
$this->assertEquals($expected, $results);
}
+/**
+ * Make sure testAction() can hit plugin controllers.
+ *
+ * @return void
+ */
+ public function testTestActionWithPlugin() {
+ $Controller = $this->Case->generate('TestPlugin.Tests');
+ $this->Case->testAction('/test_plugin/tests/index');
+ $this->assertEquals('It is a variable', $this->Case->controller->viewVars['test_value']);
+ }
+
/**
* Tests using loaded routes during tests
+ *
+ * @return void
*/
public function testUseRoutes() {
Router::connect('/:controller/:action/*');
@@ -23,6 +23,7 @@ class TestsController extends TestPluginAppController {
public $components = array('TestPlugin.PluginsComponent');
public function index() {
+ $this->set('test_value', 'It is a variable');
}
public function some_method() {
@@ -200,7 +200,7 @@ private function _testAction($url = '', $options = array()) {
$request = new CakeRequest($url);
$Dispatch = new ControllerTestDispatcher();
foreach (Router::$routes as $route) {
- if (is_a($route, 'RedirectRoute')) {
+ if ($route instanceof RedirectRoute) {
$route->response = $this->getMock('CakeResponse', array('send'));
}
}
@@ -213,8 +213,9 @@ private function _testAction($url = '', $options = array()) {
if ($this->controller !== null && Inflector::camelize($request->params['controller']) !== $this->controller->name) {
$this->controller = null;
}
+ $plugin = empty($request->params['plugin']) ? '' : Inflector::camelize($request->params['plugin']) . '.';
if ($this->controller === null && $this->autoMock) {
- $this->generate(Inflector::camelize($request->params['controller']));
+ $this->generate(Inflector::camelize($plugin . $request->params['controller']));
}
$params = array();
if ($options['return'] == 'result') {

0 comments on commit 7276f33

Please sign in to comment.