/** * @test */ public function setPassesLifetimeToBackend() { $theString = 'Just some value'; $theLifetime = 1234; $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\AbstractBackend::class, array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', false); $backend->expects($this->once())->method('set')->with($this->equalTo('VariableCacheTest'), $this->equalTo(serialize($theString)), $this->equalTo(array()), $this->equalTo($theLifetime)); $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend); $cache->set('VariableCacheTest', $theString, array(), $theLifetime); }
/** * @test */ public function setUsesIgBinarySerializeIfAvailable() { if (!extension_loaded('igbinary')) { $this->markTestSkipped('Cannot test igbinary support, because igbinary is not installed.'); } $theString = 'Just some value'; $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\AbstractBackend::class, array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', false); $backend->expects($this->once())->method('set')->with($this->equalTo('VariableCacheTest'), $this->equalTo(igbinary_serialize($theString))); $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend); $cache->initializeObject(); $cache->set('VariableCacheTest', $theString); }