Skip to content

Commit a450273

Browse files
committed
- updates the unit test
1 parent 661856a commit a450273

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Tests/SessionTestCaseTrait.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function test_toData()
8888

8989
public function test_clear()
9090
{
91-
$this->assertEquals(['qux' => 'zim', 'foo' => 'bar'], $this->SUT->toArray());
91+
$this->assertEquals(['foo' => 'bar'], $this->SUT->toArray());
9292

9393
$this->SUT->clear();
9494
$this->assertEmpty($this->SUT->toArray());
@@ -98,17 +98,25 @@ public function test_clear()
9898
public function test_destroy()
9999
{
100100
$sessionId = $this->SUT->id();
101+
$token = $this->SUT->token();
102+
$timestamp = $this->SUT->starttime();
101103

104+
$this->assertNotEmpty($sessionId);
102105
$this->assertTrue($this->SUT->destroy());
106+
103107
$this->assertNotEquals($sessionId, $this->SUT->id(), 'Session id is regenerated');
108+
$this->assertNotEquals($token, $this->SUT->token(), 'Session token is regenerated');
109+
$this->assertNotEquals($timestamp, $this->SUT->starttime(), 'Session timestamp is regenerated');
104110
}
105111

106112
public function test_regenerate()
107113
{
108114
$sessionId = $this->SUT->id();
115+
$token = $this->SUT->token();
109116

110117
$this->assertTrue($this->SUT->regenerate());
111118
$this->assertNotEquals($this->SUT->id(), $sessionId);
119+
$this->assertNotEquals($this->SUT->token(), $token, 'The session token is regenerated');
112120
}
113121

114122
public function test_flash()
@@ -151,7 +159,7 @@ public function test_import_should_import()
151159
{
152160
$this->SUT->import(['name' => 'changed']);
153161

154-
$this->assertSame([
162+
$this->assertEquals([
155163
'name' => 'changed',
156164
'foo' => 'bar'
157165
], $this->SUT->toArray(), 'The existing session variables are replaced');
@@ -195,7 +203,7 @@ public function test_starttime()
195203

196204
public function test_useragent()
197205
{
198-
$this->assertSame('', $this->SUT->agent());
206+
$this->assertSame('Koded/Session', $this->SUT->agent());
199207
$this->assertFalse($this->SUT->accessed(), 'This method does not flag the session accessed');
200208
}
201209

0 commit comments

Comments
 (0)