From 390968ef2545b794fd045b8a42a30f57feb3ade9 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Sat, 9 Jan 2016 00:06:54 +0100 Subject: [PATCH 1/3] Test save and fetch item with no data --- src/CachePoolTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/CachePoolTest.php b/src/CachePoolTest.php index bbafa32..9c5c665 100644 --- a/src/CachePoolTest.php +++ b/src/CachePoolTest.php @@ -302,6 +302,21 @@ public function testSave() $this->assertEquals('value', $this->cache->getItem('key')->get()); } + public function testSaveWithNoData() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + + return; + } + + $item = $this->cache->getItem('key'); + $this->cache->save($item); + + $this->assertTrue($this->cache->hasItem('key'), 'A saved item with no data should still be a hit.'); + $this->assertTrue($this->cache->getItem('key')->isHit(), 'A saved item with no data should still be a hit.'); + } + public function testDeferredSave() { if (isset($this->skippedTests[__FUNCTION__])) { From 7f8c6a49bea662fc187c90aed89ce295e21c8fbd Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 11 Jan 2016 22:18:05 +0100 Subject: [PATCH 2/3] Saving an item with no data should return false --- src/CachePoolTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/CachePoolTest.php b/src/CachePoolTest.php index 9c5c665..e391e36 100644 --- a/src/CachePoolTest.php +++ b/src/CachePoolTest.php @@ -311,10 +311,11 @@ public function testSaveWithNoData() } $item = $this->cache->getItem('key'); - $this->cache->save($item); + $return = $this->cache->save($item); - $this->assertTrue($this->cache->hasItem('key'), 'A saved item with no data should still be a hit.'); - $this->assertTrue($this->cache->getItem('key')->isHit(), 'A saved item with no data should still be a hit.'); + $this->assertFalse($return, 'When saving an object with no data, we should generate an error.'); + $this->assertFalse($this->cache->hasItem('key'), 'A saved item with no data should not be a hit.'); + $this->assertFalse($this->cache->getItem('key')->isHit(), 'A saved item with no data should not be a hit.'); } public function testDeferredSave() From ef397939e192fac7a966ed2b70b1e7b5143b3647 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 11 Jan 2016 22:18:55 +0100 Subject: [PATCH 3/3] Style fix --- src/CachePoolTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CachePoolTest.php b/src/CachePoolTest.php index 904bc4f..a380e6b 100644 --- a/src/CachePoolTest.php +++ b/src/CachePoolTest.php @@ -324,7 +324,7 @@ public function testSaveWithNoData() return; } - $item = $this->cache->getItem('key'); + $item = $this->cache->getItem('key'); $return = $this->cache->save($item); $this->assertFalse($return, 'When saving an object with no data, we should generate an error.');