Skip to content

Commit 43677ae

Browse files
committed
Merge pull request #51 from nicolas-grekas/tweaks
Saving expired values should invalidated existing ones
2 parents 1c0e8a7 + 7418d31 commit 43677ae

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/CachePoolTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ public function testSaveExpired()
343343

344344
$item = $this->cache->getItem('key');
345345
$item->set('value');
346+
$item->expiresAt(\DateTime::createFromFormat('U', time() + 10));
347+
$this->cache->save($item);
346348
$item->expiresAt(\DateTime::createFromFormat('U', time() - 1));
347349
$this->cache->save($item);
348350
$item = $this->cache->getItem('key');
@@ -695,7 +697,7 @@ public function testDataTypeNull()
695697
$item = $this->cache->getItem('key');
696698
$this->assertTrue(null === $item->get(), 'Wrong data type. If we store null we must get an null back.');
697699
$this->assertTrue(is_null($item->get()), 'Wrong data type. If we store null we must get an null back.');
698-
$this->assertTrue($item->isHit(), 'Null is a perfectly fine cache value. isHit() should return true when null are stored. ');
700+
$this->assertTrue($item->isHit(), 'isHit() should return true when null are stored. ');
699701
}
700702

701703
public function testDataTypeFloat()
@@ -714,7 +716,7 @@ public function testDataTypeFloat()
714716
$item = $this->cache->getItem('key');
715717
$this->assertTrue(is_float($item->get()), 'Wrong data type. If we store float we must get an float back.');
716718
$this->assertEquals($float, $item->get());
717-
$this->assertTrue($item->isHit(), 'Null is a perfectly fine cache value. isHit() should return true when null are stored. ');
719+
$this->assertTrue($item->isHit(), 'isHit() should return true when float are stored. ');
718720
}
719721

720722
public function testDataTypeBoolean()
@@ -732,7 +734,7 @@ public function testDataTypeBoolean()
732734
$item = $this->cache->getItem('key');
733735
$this->assertTrue(is_bool($item->get()), 'Wrong data type. If we store boolean we must get an boolean back.');
734736
$this->assertTrue($item->get());
735-
$this->assertTrue($item->isHit(), 'Null is a perfectly fine cache value. isHit() should return true when null are stored. ');
737+
$this->assertTrue($item->isHit(), 'isHit() should return true when true are stored. ');
736738
}
737739

738740
public function testDataTypeArray()
@@ -751,7 +753,7 @@ public function testDataTypeArray()
751753
$item = $this->cache->getItem('key');
752754
$this->assertTrue(is_array($item->get()), 'Wrong data type. If we store array we must get an array back.');
753755
$this->assertEquals($array, $item->get());
754-
$this->assertTrue($item->isHit(), 'Null is a perfectly fine cache value. isHit() should return true when null are stored. ');
756+
$this->assertTrue($item->isHit(), 'isHit() should return true when array are stored. ');
755757
}
756758

757759
public function testDataTypeObject()
@@ -769,9 +771,9 @@ public function testDataTypeObject()
769771
$this->cache->save($item);
770772

771773
$item = $this->cache->getItem('key');
772-
$this->assertTrue(is_object($item->get()), 'Wrong data type. If we store array we must get an array back.');
774+
$this->assertTrue(is_object($item->get()), 'Wrong data type. If we store object we must get an object back.');
773775
$this->assertEquals($object, $item->get());
774-
$this->assertTrue($item->isHit(), 'Null is a perfectly fine cache value. isHit() should return true when null are stored. ');
776+
$this->assertTrue($item->isHit(), 'isHit() should return true when object are stored. ');
775777
}
776778

777779
public function testIsHit()

0 commit comments

Comments
 (0)