/** * @test */ public function getByTagCallsBackend() { $tag = 'sometag'; $identifiers = array('one', 'two'); $entries = array('one value', 'two 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('findIdentifiersByTag')->with($this->equalTo($tag))->will($this->returnValue($identifiers)); $backend->expects($this->exactly(2))->method('get')->will($this->onConsecutiveCalls(serialize('one value'), serialize('two value'))); $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend); $this->assertEquals($entries, $cache->getByTag($tag), 'Did not receive the expected entries'); }
/** * @test */ public function getByTagUsesIgBinaryIfAvailable() { if (!extension_loaded('igbinary')) { $this->markTestSkipped('Cannot test igbinary support, because igbinary is not installed.'); } $tag = 'sometag'; $identifiers = array('one', 'two'); $entries = array('one value', 'two value'); $backend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', FALSE); $backend->expects($this->once())->method('findIdentifiersByTag')->with($this->equalTo($tag))->will($this->returnValue($identifiers)); $backend->expects($this->exactly(2))->method('get')->will($this->onConsecutiveCalls(igbinary_serialize('one value'), igbinary_serialize('two value'))); $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend('VariableFrontend', $backend); $cache->initializeObject(); $this->assertEquals($entries, $cache->getByTag($tag), 'Did not receive the expected entries'); }