Skip to content

Commit 64ad006

Browse files
committed
Rename SessionStorageInterface methods.
Makes them consistent with names used by Cache and Session classes.
1 parent 933e2b7 commit 64ad006

File tree

6 files changed

+36
-36
lines changed

6 files changed

+36
-36
lines changed

src/Auth/Storage/MemoryStorage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ class MemoryStorage implements StorageInterface
3232
/**
3333
* {@inheritDoc}
3434
*/
35-
public function get()
35+
public function read()
3636
{
3737
return $this->_user;
3838
}
3939

4040
/**
4141
* {@inheritDoc}
4242
*/
43-
public function set(array $user)
43+
public function write(array $user)
4444
{
4545
$this->_user = $user;
4646
}
4747

4848
/**
4949
* {@inheritDoc}
5050
*/
51-
public function remove()
51+
public function delete()
5252
{
5353
$this->_user = null;
5454
}

src/Auth/Storage/SessionStorage.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ public function __construct(Request $request, array $config = [])
6464
}
6565

6666
/**
67-
* Get user record from session.
67+
* Read user record from session.
6868
*
6969
* @return array|null User record if available else null.
7070
*/
71-
public function get()
71+
public function read()
7272
{
7373
if ($this->_user !== null) {
7474
return $this->_user ?: null;
@@ -79,14 +79,14 @@ public function get()
7979
}
8080

8181
/**
82-
* Set user record to session.
82+
* Write user record to session.
8383
*
8484
* The session id is also renewed to help mitigate issues with session replays.
8585
*
8686
* @param array $user User record.
8787
* @return void
8888
*/
89-
public function set(array $user)
89+
public function write(array $user)
9090
{
9191
$this->_user = $user;
9292

@@ -95,13 +95,13 @@ public function set(array $user)
9595
}
9696

9797
/**
98-
* Remove user record from session.
98+
* Delete user record from session.
9999
*
100100
* The session id is also renewed to help mitigate issues with session replays.
101101
*
102102
* @return void
103103
*/
104-
public function remove()
104+
public function delete()
105105
{
106106
$this->_user = false;
107107

src/Auth/Storage/StorageInterface.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@
2121
interface StorageInterface
2222
{
2323
/**
24-
* Get user record.
24+
* Read user record.
2525
*
2626
* @return array|null
2727
*/
28-
public function get();
28+
public function read();
2929

3030
/**
31-
* Set user record.
31+
* Write user record.
3232
*
3333
* @param array $user User record.
3434
* @return void
3535
*/
36-
public function set(array $user);
36+
public function write(array $user);
3737

3838
/**
39-
* Remove user record.
39+
* Delete user record.
4040
*
4141
* @return void
4242
*/
43-
public function remove();
43+
public function delete();
4444
}

src/Controller/Component/AuthComponent.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ public function deny($actions = null)
600600
*/
601601
public function setUser(array $user)
602602
{
603-
$this->storage()->set($user);
603+
$this->storage()->write($user);
604604
}
605605

606606
/**
@@ -621,7 +621,7 @@ public function logout()
621621
$user = (array)$this->user();
622622
$this->dispatchEvent('Auth.logout', [$user]);
623623
$this->session->delete('Auth.redirect');
624-
$this->storage()->remove();
624+
$this->storage()->delete();
625625
return Router::normalize($this->_config['logoutRedirect']);
626626
}
627627

@@ -634,7 +634,7 @@ public function logout()
634634
*/
635635
public function user($key = null)
636636
{
637-
$user = $this->storage()->get();
637+
$user = $this->storage()->read();
638638
if (!$user) {
639639
return;
640640
}
@@ -668,7 +668,7 @@ protected function _getUser()
668668
foreach ($this->_authenticateObjects as $auth) {
669669
$result = $auth->getUser($this->request);
670670
if (!empty($result) && is_array($result)) {
671-
$this->storage()->set($result);
671+
$this->storage()->write($result);
672672
return true;
673673
}
674674
}

tests/TestCase/Auth/Storage/SessionStorageTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,63 +41,63 @@ public function setUp()
4141
}
4242

4343
/**
44-
* Test set
44+
* Test write
4545
*
4646
* @return void
4747
*/
48-
public function testSet()
48+
public function testWrite()
4949
{
5050
$this->session->expects($this->once())
5151
->method('write')
5252
->with('Auth.AuthUser', $this->user)
5353
->will($this->returnValue(true));
5454

55-
$this->storage->set($this->user);
55+
$this->storage->write($this->user);
5656
}
5757

5858
/**
59-
* Test get
59+
* Test read
6060
*
6161
* @return void
6262
*/
63-
public function testGet()
63+
public function testRead()
6464
{
6565
$this->session->expects($this->once())
6666
->method('read')
6767
->with('Auth.AuthUser')
6868
->will($this->returnValue($this->user));
6969

70-
$result = $this->storage->get();
70+
$result = $this->storage->read();
7171
$this->assertSame($this->user, $result);
7272
}
7373

7474
/**
75-
* Test get from local var
75+
* Test read from local var
7676
*
7777
* @return void
7878
*/
7979
public function testGetFromLocalVar()
8080
{
81-
$this->storage->set($this->user);
81+
$this->storage->write($this->user);
8282

8383
$this->session->expects($this->never())
8484
->method('read');
8585

86-
$result = $this->storage->get();
86+
$result = $this->storage->read();
8787
$this->assertSame($this->user, $result);
8888
}
8989

9090
/**
91-
* Test remove
91+
* Test delete
9292
*
9393
* @return void
9494
*/
95-
public function testRemove()
95+
public function testDelete()
9696
{
9797
$this->session->expects($this->once())
9898
->method('delete')
9999
->with('Auth.AuthUser');
100100

101-
$this->storage->remove();
101+
$this->storage->delete();
102102
}
103103
}

tests/TestCase/Controller/Component/AuthComponentTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public function testRedirectVarClearing()
183183
$this->Auth->startup($event);
184184
$this->assertEquals('/auth_test/add', $this->Auth->session->read('Auth.redirect'));
185185

186-
$this->Auth->storage()->set(['username' => 'admad']);
186+
$this->Auth->storage()->write(['username' => 'admad']);
187187
$this->Auth->startup($event, $this->Controller);
188188
$this->assertNull($this->Auth->session->read('Auth.redirect'));
189189
}
@@ -199,14 +199,14 @@ public function testAuthorizeFalse()
199199
$event = new Event('Controller.startup', $this->Controller);
200200
$Users = TableRegistry::get('Users');
201201
$user = $Users->find('all')->hydrate(false)->first();
202-
$this->Controller->Auth->storage()->set($user);
202+
$this->Controller->Auth->storage()->write($user);
203203
$this->Controller->Auth->config('userModel', 'Users');
204204
$this->Controller->Auth->config('authorize', false);
205205
$this->Controller->request->addParams(Router::parse('auth_test/add'));
206206
$result = $this->Controller->Auth->startup($event);
207207
$this->assertNull($result);
208208

209-
$this->Controller->Auth->storage()->remove();
209+
$this->Controller->Auth->storage()->delete();
210210
$result = $this->Controller->Auth->startup($event);
211211
$this->assertTrue($event->isStopped());
212212
$this->assertInstanceOf('Cake\Network\Response', $result);
@@ -1116,15 +1116,15 @@ public function testSetUser()
11161116
{
11171117
$storage = $this->getMock(
11181118
'Cake\Auth\Storage\SessionStorage',
1119-
['set'],
1119+
['write'],
11201120
[$this->Auth->request]
11211121
);
11221122
$this->Auth->storage($storage);
11231123

11241124
$user = ['username' => 'mark', 'role' => 'admin'];
11251125

11261126
$storage->expects($this->once())
1127-
->method('set')
1127+
->method('write')
11281128
->with($user);
11291129

11301130
$this->Auth->setUser($user);

0 commit comments

Comments
 (0)