|
|
@@ -337,7 +337,9 @@ class RequestHandlerComponentTest extends TestCase {
|
|
|
$this->RequestHandler->initialize($event);
|
|
|
$this->RequestHandler->startup($event);
|
|
|
$this->assertEquals($this->Controller->viewClass, 'Cake\View\AjaxView');
|
|
|
-
|
|
|
+ $view = $this->Controller->createView();
|
|
|
+ $this->assertEquals('ajax', $view->layout);
|
|
|
+
|
|
|
$this->_init();
|
|
|
$this->Controller->request->params['_ext'] = 'js';
|
|
|
$this->RequestHandler->initialize($event);
|
|
|
@@ -348,6 +350,50 @@ class RequestHandlerComponentTest extends TestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * test custom JsonView class is loaded and correct.
|
|
|
+ */
|
|
|
+ public function testJsonViewLoaded() {
|
|
|
+ Router::parseExtensions('json', 'xml', 'ajax');
|
|
|
+ $this->Controller->request->params['_ext'] = 'json';
|
|
|
+ $event = new Event('Controller.startup', $this->Controller);
|
|
|
+ $this->RequestHandler->initialize($event);
|
|
|
+ $this->RequestHandler->startup($event);
|
|
|
+ $this->assertEquals('Cake\View\JsonView', $this->Controller->viewClass);
|
|
|
+ $view = $this->Controller->createView();
|
|
|
+ $this->assertEquals('json', $view->layoutPath);
|
|
|
+ $this->assertEquals('json', $view->subDir);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * test custom XmlView class is loaded and correct.
|
|
|
+ */
|
|
|
+ public function testXmlViewLoaded() {
|
|
|
+ Router::parseExtensions('json', 'xml', 'ajax');
|
|
|
+ $this->Controller->request->params['_ext'] = 'xml';
|
|
|
+ $event = new Event('Controller.startup', $this->Controller);
|
|
|
+ $this->RequestHandler->initialize($event);
|
|
|
+ $this->RequestHandler->startup($event);
|
|
|
+ $this->assertEquals('Cake\View\XmlView', $this->Controller->viewClass);
|
|
|
+ $view = $this->Controller->createView();
|
|
|
+ $this->assertEquals('xml', $view->layoutPath);
|
|
|
+ $this->assertEquals('xml', $view->subDir);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * test custom AjaxView class is loaded and correct.
|
|
|
+ */
|
|
|
+ public function testAjaxViewLoaded() {
|
|
|
+ Router::parseExtensions('json', 'xml', 'ajax');
|
|
|
+ $this->Controller->request->params['_ext'] = 'ajax';
|
|
|
+ $event = new Event('Controller.startup', $this->Controller);
|
|
|
+ $this->RequestHandler->initialize($event);
|
|
|
+ $this->RequestHandler->startup($event);
|
|
|
+ $this->assertEquals('Cake\View\AjaxView', $this->Controller->viewClass);
|
|
|
+ $view = $this->Controller->createView();
|
|
|
+ $this->assertEquals('ajax', $view->layout);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* testStartupCallback method
|
|
|
*
|
|
|
* @return void
|