Skip to content

Commit

Permalink
Fixes tests to expect changes made to read and write methods - This c…
Browse files Browse the repository at this point in the history
…ould be a possible BC change

Since php 7 expects write to return true or false this needed to change, previous implementation would return the values sent to write on success and false on failure. Similar change to read method test CakeSession::read() now returns results or ''.
  • Loading branch information
phpnut committed Dec 28, 2015
1 parent 3c21f4a commit 1fd3293
Showing 1 changed file with 7 additions and 22 deletions.
Expand Up @@ -122,19 +122,8 @@ public function testOpen() {
* @return void
*/
public function testWrite() {
$result = $this->storage->write('foo', 'Some value');
$expected = array(
'Session' => array(
'id' => 'foo',
'data' => 'Some value',
)
);
$expires = $result['Session']['expires'];
unset($result['Session']['expires']);
$this->assertEquals($expected, $result);

$expected = time() + (Configure::read('Session.timeout') * 60);
$this->assertWithinMargin($expires, $expected, 1);
$this->storage->write('foo', 'Some value');
$this->assertEquals($this->storage->read('foo'), 'Some value');
}

/**
Expand All @@ -154,13 +143,8 @@ public function testWriteEmptySessionId() {
*/
public function testRead() {
$this->storage->write('foo', 'Some value');

$result = $this->storage->read('foo');
$expected = 'Some value';
$this->assertEquals($expected, $result);

$result = $this->storage->read('made up value');
$this->assertFalse($result);
$this->assertEquals($this->storage->read('foo'), 'Some value');
$this->assertSame('', $this->storage->read('made up value'));
}

/**
Expand All @@ -172,7 +156,8 @@ public function testDestroy() {
$this->storage->write('foo', 'Some value');

$this->assertTrue($this->storage->destroy('foo'), 'Destroy failed');
$this->assertFalse($this->storage->read('foo'), 'Value still present.');
$this->assertSame($this->storage->read('foo'), '');

}

/**
Expand All @@ -189,7 +174,7 @@ public function testGc() {

sleep(1);
$storage->gc();
$this->assertFalse($storage->read('foo'));
$this->assertSame($storage->read('foo'), '');
}

/**
Expand Down

0 comments on commit 1fd3293

Please sign in to comment.