Minor improvements

This commit is contained in:
Dan Hensby 2018-09-26 23:48:34 +01:00
parent b0e0566c93
commit 3584598d7a
No known key found for this signature in database
GPG Key ID: 3906B235643EF10B

View File

@ -137,7 +137,7 @@ class SessionTest extends SapphireTest
[ [
// 'existing' => true, // 'existing' => true,
'new' => true, 'new' => true,
'merge' => 2 'merge' => 2,
], ],
$session->getAll() $session->getAll()
); );
@ -183,17 +183,17 @@ class SessionTest extends SapphireTest
$session = $this->session->getAll(); $session = $this->session->getAll();
unset($session['HTTP_USER_AGENT']); unset($session['HTTP_USER_AGENT']);
$this->assertEquals($session, array('Test' => 'Test', 'Test-2' => 'Test-2')); $this->assertEquals($session, ['Test' => 'Test', 'Test-2' => 'Test-2']);
} }
public function testSettingExistingDoesntClear() public function testSettingExistingDoesntClear()
{ {
$s = new Session(array('something' => array('does' => 'exist'))); $s = new Session(['something' => ['does' => 'exist']]);
$s->set('something.does', 'exist'); $s->set('something.does', 'exist');
$result = $s->changedData(); $result = $s->changedData();
unset($result['HTTP_USER_AGENT']); unset($result['HTTP_USER_AGENT']);
$this->assertEquals(array(), $result); $this->assertEmpty($result);
} }
/** /**
@ -206,7 +206,7 @@ class SessionTest extends SapphireTest
// Clear without existing data // Clear without existing data
$data = $s->get('something.doesnt.exist'); $data = $s->get('something.doesnt.exist');
$this->assertEquals(array(), $s->changedData()); $this->assertEmpty($s->changedData());
$this->assertNull($data); $this->assertNull($data);
// Clear with existing change // Clear with existing change
@ -273,7 +273,7 @@ class SessionTest extends SapphireTest
$req1->addHeader('User-Agent', 'Test Agent'); $req1->addHeader('User-Agent', 'Test Agent');
// Generate our session // Generate our session
$s = new Session(array()); $s = new Session([]);
$s->init($req1); $s->init($req1);
$s->set('val', 123); $s->set('val', 123);
$s->finalize($req1); $s->finalize($req1);
@ -312,13 +312,13 @@ class SessionTest extends SapphireTest
'something' => [ 'something' => [
'another' => 'newanother', 'another' => 'newanother',
'newkey' => 'new value', 'newkey' => 'new value',
] ],
], ],
$_SESSION $_SESSION
); );
// Test cleared keys are restorable // Test cleared keys are restorable
$s = new Session($_SESSION = ['bookmarks' => [ 1 => 1, 2 => 2]]); $s = new Session($_SESSION = ['bookmarks' => [1 => 1, 2 => 2]]);
$s->clear('bookmarks'); $s->clear('bookmarks');
$s->set('bookmarks', [ $s->set('bookmarks', [
1 => 1, 1 => 1,
@ -330,7 +330,7 @@ class SessionTest extends SapphireTest
'bookmarks' => [ 'bookmarks' => [
1 => 1, 1 => 1,
3 => 3, 3 => 3,
] ],
], ],
$_SESSION $_SESSION
); );