public function testKeyValueRemainsUnchanged() { $value = ['value' => ['another', 'array']]; $this->cacheItem->set($value); $this->assertSame($value, $this->cacheItem->get()); $this->assertEquals('key', $this->cacheItem->getKey()); }
public function testSaveDeferredAndCommit_SecondSaveFails() { $otherCacheItem = $this->getMock('Psr\\Cache\\CacheItemInterface'); $this->cacheItem->expects($this->once())->method('getExpiration')->willReturn(new \DateTime('now +30 seconds')); $this->cacheItem->expects($this->any())->method('getKey')->willReturn($this->cacheKey); $otherCacheKey = 'cache-key-2'; $otherCacheItem->expects($this->once())->method('getExpiration')->willReturn(new \DateTime('now +30 seconds')); $otherCacheItem->expects($this->any())->method('getKey')->willReturn($otherCacheKey); $cacheItemPool = $this->adapter->saveDeferred($this->cacheItem); $this->assertSame($this->adapter, $cacheItemPool); $cacheItemPool = $this->adapter->saveDeferred($otherCacheItem); $this->assertSame($this->adapter, $cacheItemPool); $this->cacheProvider->expects($this->at(0))->method('save')->willReturn(true); $this->cacheProvider->expects($this->at(1))->method('save')->willReturn(false); $this->assertFalse($this->adapter->commit()); }