From 1fd329311b6dfb46e5df70bdff7b1d4a4cabda33 Mon Sep 17 00:00:00 2001 From: "Larry E. Masters" Date: Mon, 28 Dec 2015 11:29:17 -0500 Subject: [PATCH] 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 ''. --- .../Session/DatabaseSessionTest.php | 29 +++++-------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php index da19cfcc6..b529f803e 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php @@ -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'), ''); } /**