From d98abc58d16c241ac8e847fb66fbb975aba29822 Mon Sep 17 00:00:00 2001 From: David Steinsland Date: Tue, 22 Jul 2014 14:45:18 +0200 Subject: [PATCH] Added test case for CakeResponse::send() and ajaxLogin --- .../Component/AuthComponentTest.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index be974fd1183..22f45197356 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -1155,6 +1155,36 @@ public function testAjaxLogin() { unset($_SERVER['HTTP_X_REQUESTED_WITH']); } +/** + * testAjaxLoginResponseCode + * + * @return void + */ + public function testAjaxLoginResponseCode() { + App::build(array( + 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) + )); + $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; + + $url = '/ajax_auth/add'; + $this->Auth->request->addParams(Router::parse($url)); + $this->Auth->request->query['url'] = ltrim($url, '/'); + $this->Auth->request->base = ''; + $this->Auth->ajaxLogin = 'test_element'; + + Router::setRequestInfo($this->Auth->request); + + $this->Controller->response = $this->getMock('CakeResponse', array('send')); + $this->Controller->response->expects($this->once())->method('send'); + $this->Auth->initialize($this->Controller); + + $result = $this->Auth->startup($this->Controller); + + $this->assertFalse($result); + $this->assertEquals('this is the test element', $this->Controller->response->body()); + unset($_SERVER['HTTP_X_REQUESTED_WITH']); + } + /** * testLoginActionRedirect method *