From 84c599a87efc3674cac9020fee11b9164772a599 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 31 May 2015 12:08:42 +0530 Subject: [PATCH] Add Response as argument for auth storage classes. --- src/Auth/Storage/SessionStorage.php | 4 +++- src/Controller/Component/AuthComponent.php | 2 +- tests/TestCase/Auth/Storage/SessionStorageTest.php | 4 +++- tests/TestCase/Controller/Component/AuthComponentTest.php | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Auth/Storage/SessionStorage.php b/src/Auth/Storage/SessionStorage.php index f140d36c625..70478b06574 100644 --- a/src/Auth/Storage/SessionStorage.php +++ b/src/Auth/Storage/SessionStorage.php @@ -16,6 +16,7 @@ use Cake\Core\InstanceConfigTrait; use Cake\Network\Request; +use Cake\Network\Response; /** * Session based persistent storage for authenticated user record. @@ -55,9 +56,10 @@ class SessionStorage implements StorageInterface * Constructor. * * @param \Cake\Network\Request $request Request instance. + * @param \Cake\Netowrk\Response $respose Response instance. * @param array $config Configuration list. */ - public function __construct(Request $request, array $config = []) + public function __construct(Request $request, Response $respose, array $config = []) { $this->_session = $request->session(); $this->config($config); diff --git a/src/Controller/Component/AuthComponent.php b/src/Controller/Component/AuthComponent.php index 8ed64952535..84b54fd2818 100644 --- a/src/Controller/Component/AuthComponent.php +++ b/src/Controller/Component/AuthComponent.php @@ -813,7 +813,7 @@ public function storage(StorageInterface $storage = null) if (!class_exists($className)) { throw new Exception(sprintf('Auth storage adapter "%s" was not found.', $class)); } - $this->_storage = new $className($this->request, $config); + $this->_storage = new $className($this->request, $this->response, $config); return $this->_storage; } diff --git a/tests/TestCase/Auth/Storage/SessionStorageTest.php b/tests/TestCase/Auth/Storage/SessionStorageTest.php index bcb001e79c1..bcbe794e343 100644 --- a/tests/TestCase/Auth/Storage/SessionStorageTest.php +++ b/tests/TestCase/Auth/Storage/SessionStorageTest.php @@ -16,6 +16,7 @@ use Cake\Auth\Storage\SessionStorage; use Cake\Network\Request; +use Cake\Network\Response; use Cake\TestSuite\TestCase; /** @@ -36,7 +37,8 @@ public function setUp() $this->session = $this->getMock('Cake\Network\Session'); $this->request = new Request(['session' => $this->session]); - $this->storage = new SessionStorage($this->request, ['key' => 'Auth.AuthUser']); + $this->response = new Response(); + $this->storage = new SessionStorage($this->request, $this->response, ['key' => 'Auth.AuthUser']); $this->user = ['id' => 1]; } diff --git a/tests/TestCase/Controller/Component/AuthComponentTest.php b/tests/TestCase/Controller/Component/AuthComponentTest.php index ca43926e2da..926b14d9e68 100644 --- a/tests/TestCase/Controller/Component/AuthComponentTest.php +++ b/tests/TestCase/Controller/Component/AuthComponentTest.php @@ -1117,7 +1117,7 @@ public function testSetUser() $storage = $this->getMock( 'Cake\Auth\Storage\SessionStorage', ['write'], - [$this->Auth->request] + [$this->Auth->request, $this->Auth->response] ); $this->Auth->storage($storage);