/** * testViewClassMap method * * @return void */ public function testViewClassMap() { $this->RequestHandler->config(['viewClassMap' => ['json' => 'CustomJson']]); $this->RequestHandler->initialize([]); $result = $this->RequestHandler->viewClassMap(); $expected = ['json' => 'CustomJson', 'xml' => 'Xml', 'ajax' => 'Ajax']; $this->assertEquals($expected, $result); $result = $this->RequestHandler->viewClassMap('xls', 'Excel.Excel'); $expected = ['json' => 'CustomJson', 'xml' => 'Xml', 'ajax' => 'Ajax', 'xls' => 'Excel.Excel']; $this->assertEquals($expected, $result); $this->RequestHandler->renderAs($this->Controller, 'json'); $this->assertEquals('TestApp\\View\\CustomJsonView', $this->Controller->viewClass); }
/** * testViewClassMap method * * @return void */ public function testViewClassMap() { $event = new Event('Controller.initialize', $this->Controller); $this->RequestHandler->config(array('viewClassMap' => array('json' => 'CustomJson'))); $this->RequestHandler->initialize($event); $result = $this->RequestHandler->viewClassMap(); $expected = array('json' => 'CustomJson', 'xml' => 'Xml', 'ajax' => 'Ajax'); $this->assertEquals($expected, $result); $result = $this->RequestHandler->viewClassMap('xls', 'Excel.Excel'); $expected = array('json' => 'CustomJson', 'xml' => 'Xml', 'ajax' => 'Ajax', 'xls' => 'Excel.Excel'); $this->assertEquals($expected, $result); $this->RequestHandler->renderAs($this->Controller, 'json'); $this->assertEquals('TestApp\\View\\CustomJsonView', $this->Controller->viewClass); }