Skip to content
Permalink
Browse files

Fix failing tests.

* Change ext -> _ext.
* Add default routes.
* Add missing App.namespace.
  • Loading branch information...
markstory committed Oct 3, 2012
1 parent 9b53319 commit 6d0e033663a3002c124eeb8cb7c849b8839f5292
Showing with 26 additions and 10 deletions.
  1. +26 −10 lib/Cake/Test/TestCase/Controller/Component/RequestHandlerComponentTest.php
@@ -249,7 +249,7 @@ public function testViewClassMap() {
$this->assertEquals($expected, $result);
$this->RequestHandler->renderAs($this->Controller, 'json');
$this->assertEquals('CustomJson', $this->Controller->viewClass);
$this->assertEquals('TestApp\View\CustomJsonView', $this->Controller->viewClass);
}
/**
@@ -273,7 +273,7 @@ public function testDisabling() {
*/
public function testAutoResponseType() {
$this->Controller->ext = '.thtml';
$this->Controller->request->params['ext'] = 'rss';
$this->Controller->request->params['_ext'] = 'rss';
$this->RequestHandler->initialize($this->Controller);
$this->RequestHandler->startup($this->Controller);
$this->assertEquals('.ctp', $this->Controller->ext);
@@ -290,7 +290,7 @@ public function testAutoAjaxLayout() {
$this->assertEquals($this->Controller->layout, $this->RequestHandler->ajaxLayout);
$this->_init();
$this->Controller->request->params['ext'] = 'js';
$this->Controller->request->params['_ext'] = 'js';
$this->RequestHandler->initialize($this->Controller);
$this->RequestHandler->startup($this->Controller);
$this->assertNotEquals('ajax', $this->Controller->layout);
@@ -399,7 +399,7 @@ public function testRenderAsWithAttachment() {
$this->RequestHandler->renderAs($this->Controller, 'xml', array('attachment' => 'myfile.xml'));
$this->assertEquals('Xml', $this->Controller->viewClass);
$this->assertEquals('Cake\View\XmlView', $this->Controller->viewClass);
}
/**
@@ -696,11 +696,17 @@ public function testClientProperties() {
* @return void
*/
public function testAjaxRedirectAsRequestAction() {
Configure::write('App.namespace', 'TestApp');
App::build(array(
'View' => array(CAKE . 'Test/TestApp/View/')
), App::RESET);
Router::connect('/:controller/:action');
$this->Controller->RequestHandler = $this->getMock('Cake\Controller\Component\RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
$this->Controller->RequestHandler = $this->getMock(
'Cake\Controller\Component\RequestHandlerComponent',
array('_stop'),
array(&$this->Controller->Components)
);
$this->Controller->request = $this->getMock('Cake\Network\Request');
$this->Controller->response = $this->getMock('Cake\Network\Response', array('_sendHeader'));
$this->Controller->RequestHandler->request = $this->Controller->request;
@@ -725,11 +731,17 @@ public function testAjaxRedirectAsRequestAction() {
* @return void
*/
public function testAjaxRedirectAsRequestActionStillRenderingLayout() {
Configure::write('App.namespace', 'TestApp');
App::build(array(
'View' => array(CAKE . 'Test/TestApp/View/')
), App::RESET);
Router::connect('/:controller/:action');
$this->Controller->RequestHandler = $this->getMock('Cake\Controller\Component\RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
$this->Controller->RequestHandler = $this->getMock(
'Cake\Controller\Component\RequestHandlerComponent',
array('_stop'),
array(&$this->Controller->Components)
);
$this->Controller->request = $this->getMock('Cake\Network\Request');
$this->Controller->response = $this->getMock('Cake\Network\Response', array('_sendHeader'));
$this->Controller->RequestHandler->request = $this->Controller->request;
@@ -744,8 +756,6 @@ public function testAjaxRedirectAsRequestActionStillRenderingLayout() {
$result = ob_get_clean();
$this->assertRegExp('/posts index/', $result, 'RequestAction redirect failed.');
$this->assertRegExp('/Ajax!/', $result, 'Layout was not rendered.');
App::build();
}
/**
@@ -757,14 +767,20 @@ public function testAjaxRedirectAsRequestActionStillRenderingLayout() {
* @return void
*/
public function testBeforeRedirectCallbackWithArrayUrl() {
Configure::write('App.namespace', 'TestApp');
Router::connect('/:controller/:action/*');
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
Router::setRequestInfo(array(
array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array()),
array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/')
array('base' => '', 'here' => '/accounts/', 'webroot' => '/')
));
$RequestHandler = $this->getMock('Cake\Controller\Component\RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
$RequestHandler = $this->getMock(
'Cake\Controller\Component\RequestHandlerComponent',
array('_stop'),
array(&$this->Controller->Components)
);
$RequestHandler->response = $this->getMock('Cake\Network\Response', array('_sendHeader'));
$RequestHandler->request = new Request('posts/index');
$RequestHandler->response = $this->getMock('Cake\Network\Response', array('_sendHeader'));

0 comments on commit 6d0e033

Please sign in to comment.
You can’t perform that action at this time.