* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\Adapter\NullAdapter; /** * @group time-sensitive */ class NullAdapterTest extends TestCase { public function createCachePool() { return new NullAdapter(); } public function testGetItem() { $adapter = $this->createCachePool(); $item = $adapter->getItem('key'); $this->assertFalse($item->isHit()); $this->assertNull($item->get(), "Item's value must be null when isHit is false."); } public function testHasItem() { $this->assertFalse($this->createCachePool()->hasItem('key')); } public function testGetItems() { $adapter = $this->createCachePool(); $keys = array('foo', 'bar', 'baz', 'biz'); /** @var CacheItemInterface[] $items */ $items = $adapter->getItems($keys); $count = 0; foreach ($items as $key => $item) { $itemKey = $item->getKey(); $this->assertEquals($itemKey, $key, 'Keys must be preserved when fetching multiple items'); $this->assertContains($key, $keys, 'Cache key can not change.'); $this->assertFalse($item->isHit()); // Remove $key for $keys foreach ($keys as $k => $v) { if ($v === $key) { unset($keys[$k]); } } ++$count; } $this->assertSame(4, $count); } public function testIsHit() { $adapter = $this->createCachePool(); $item = $adapter->getItem('key'); $this->assertFalse($item->isHit()); } public function testClear() { $this->assertTrue($this->createCachePool()->clear()); } public function testDeleteItem() { $this->assertTrue($this->createCachePool()->deleteItem('key')); } public function testDeleteItems() { $this->assertTrue($this->createCachePool()->deleteItems(array('key', 'foo', 'bar'))); } public function testSave() { $adapter = $this->createCachePool(); $item = $adapter->getItem('key'); $this->assertFalse($item->isHit()); $this->assertNull($item->get(), "Item's value must be null when isHit is false."); $this->assertFalse($adapter->save($item)); } public function testDeferredSave() { $adapter = $this->createCachePool(); $item = $adapter->getItem('key'); $this->assertFalse($item->isHit()); $this->assertNull($item->get(), "Item's value must be null when isHit is false."); $this->assertFalse($adapter->saveDeferred($item)); } public function testCommit() { $adapter = $this->createCachePool(); $item = $adapter->getItem('key'); $this->assertFalse($item->isHit()); $this->assertNull($item->get(), "Item's value must be null when isHit is false."); $this->assertFalse($adapter->saveDeferred($item)); $this->assertFalse($this->createCachePool()->commit()); } } __halt_compiler();----SIGNATURE:----TonDV01zIZNzqjHF4BabrCaHTkQhN30LXuYvv2rlSYs8JdCAC3/y6yBWAtI90noK/ZZO0RXZIvoN7zBOlZHXEH2P0wzlXRxtHCdj9k9z0KYs7fDvxgR7ty13p2g6CV7ri/eIJLRKw7vh/CuBLakVdlEhm23WgncI9kYRWLaZRFKSHXlGhoa/Xk1WCqkHdJ0jsCnjk5006Edg/EixGFn1QIwvt6LUY0f32SFHNTrcmDGVeq6idDlga5DPGd/iF23GK+yxEyZkVMrbCIaUEdfdb0+RVsRuZq5lBxkaVTJ4rudEVUSBx7mIfZvfWuYl15hiS53S4DzhCu3HZJceGtUlX3yjU1T+7JRpGRtcz/wmqTVz3Sf0Ky8LzVJ0BOrOBQBNsM6B9GFqkBuz98mu7z+JuJnOMGaLO8UHU71yboU2g9IlqHW2vp0wm2deSecltpt99Qvz0Prrm4O4SfKNXvSQcQJDSviJ/bl5TpRl692T0p4frfUfu1Z76GbByMJIvjGubJ/7usVEZuFy7eZ2LUc80A73j0WXxg7x33jsdZXEfEdMemtenwtb2u15Gk0WqJiy8bLXHZl13Eyft201B4yfaowRRlWQZ8vEsrGfmFCxHHDtEvttjNdaaMXZc3pNXJJONOyiaaI4UgdJj4Y6EtjJMhJVVFRaHz6kNYU0ah6RlQ4=----ATTACHMENT:----NjIzMDUxODg2NTA2Mzg4NyA2NTUxMjQ0MDc1OTQzODAxIDgzMjYzNDcwODIxOTQxOTc=