Skip to content
Permalink
Browse files

Fixes tests to expect changes made to read and write methods - This c…

…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 1fd329311b6dfb46e5df70bdff7b1d4a4cabda33
Showing with 7 additions and 22 deletions.
  1. +7 −22 lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php
@@ -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');
}
/**
@@ -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'));
}
/**
@@ -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'), '');
}
/**
@@ -189,7 +174,7 @@ public function testGc() {
sleep(1);
$storage->gc();
$this->assertFalse($storage->read('foo'));
$this->assertSame($storage->read('foo'), '');
}
/**

0 comments on commit 1fd3293

Please sign in to comment.
You can’t perform that action at this time.