Fixes tests to expect changes made to read and write methods - This could 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 ''.
This commit is contained in:
Larry E. Masters 2015-12-28 11:29:17 -05:00
parent 3c21f4a8af
commit 1fd329311b

View file

@ -122,19 +122,8 @@ class DatabaseSessionTest extends CakeTestCase {
* @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 @@ class DatabaseSessionTest extends CakeTestCase {
*/
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 @@ class DatabaseSessionTest extends CakeTestCase {
$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 @@ class DatabaseSessionTest extends CakeTestCase {
sleep(1);
$storage->gc();
$this->assertFalse($storage->read('foo'));
$this->assertSame($storage->read('foo'), '');
}
/**