32 if (!extension_loaded(
'wincache')) {
33 $this->markTestSkipped(
'WinCache extension was not available');
56 $inCache =
$backend->has($identifier);
57 $this->assertTrue($inCache,
'WinCache backend failed to set and check entry');
68 $fetchedData =
$backend->get($identifier);
69 $this->assertEquals($data, $fetchedData,
'Winache backend failed to set and retrieve data');
81 $inCache =
$backend->has($identifier);
82 $this->assertFalse($inCache,
'Failed to set and remove data from WinCache backend');
93 $otherData =
'some other data';
94 $backend->set($identifier, $otherData);
95 $fetchedData =
$backend->get($identifier);
96 $this->assertEquals($otherData, $fetchedData,
'WinCache backend failed to overwrite and retrieve data');
106 $backend->set($identifier, $data, array(
'UnitTestTag%tag1',
'UnitTestTag%tag2'));
107 $retrieved =
$backend->findIdentifiersByTag(
'UnitTestTag%tag1');
108 $this->assertEquals($identifier, $retrieved[0],
'Could not retrieve expected entry by tag.');
109 $retrieved =
$backend->findIdentifiersByTag(
'UnitTestTag%tag2');
110 $this->assertEquals($identifier, $retrieved[0],
'Could not retrieve expected entry by tag.');
120 $backend->set($identifier, $data, array(
'UnitTestTag%tag1',
'UnitTestTag%tagX'));
121 $backend->set($identifier, $data, array(
'UnitTestTag%tag3'));
122 $retrieved =
$backend->findIdentifiersByTag(
'UnitTestTag%tagX');
123 $this->assertEquals(array(), $retrieved,
'Found entry which should no longer exist.');
131 $identifier = $this->
getUniqueId(
'NonExistingIdentifier');
132 $inCache =
$backend->has($identifier);
133 $this->assertFalse($inCache,
'"has" did not return FALSE when checking on non existing identifier');
141 $identifier = $this->
getUniqueId(
'NonExistingIdentifier');
142 $inCache =
$backend->remove($identifier);
143 $this->assertFalse($inCache,
'"remove" did not return FALSE when checking on non existing identifier');
151 $data =
'some data' . microtime();
152 $backend->set(
'BackendWincacheTest1', $data, array(
'UnitTestTag%test',
'UnitTestTag%boring'));
153 $backend->set(
'BackendWincacheTest2', $data, array(
'UnitTestTag%test',
'UnitTestTag%special'));
154 $backend->set(
'BackendWincacheTest3', $data, array(
'UnitTestTag%test'));
155 $backend->flushByTag(
'UnitTestTag%special');
156 $this->assertTrue(
$backend->has(
'BackendWincacheTest1'),
'BackendWincacheTest1');
157 $this->assertFalse(
$backend->has(
'BackendWincacheTest2'),
'BackendWincacheTest2');
158 $this->assertTrue(
$backend->has(
'BackendWincacheTest3'),
'BackendWincacheTest3');
166 $data =
'some data' . microtime();
167 $backend->set(
'BackendWincacheTest1', $data);
168 $backend->set(
'BackendWincacheTest2', $data);
169 $backend->set(
'BackendWincacheTest3', $data);
171 $this->assertFalse(
$backend->has(
'BackendWincacheTest1'),
'BackendWincacheTest1');
172 $this->assertFalse(
$backend->has(
'BackendWincacheTest2'),
'BackendWincacheTest2');
173 $this->assertFalse(
$backend->has(
'BackendWincacheTest3'),
'BackendWincacheTest3');
179 public function flushRemovesOnlyOwnEntries() {
181 $thisCache = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(),
'', FALSE);
182 $thisCache->expects($this->any())->method(
'getIdentifier')->will($this->returnValue(
'thisCache'));
184 $thisBackend->setCache($thisCache);
187 $thatCache = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(),
'', FALSE);
188 $thatCache->expects($this->any())->method(
'getIdentifier')->will($this->returnValue(
'thatCache'));
190 $thatBackend->setCache($thatCache);
191 $thisBackend->set(
'thisEntry',
'Hello');
192 $thatBackend->set(
'thatEntry',
'World!');
193 $thatBackend->flush();
194 $this->assertEquals(
'Hello', $thisBackend->get(
'thisEntry'));
195 $this->assertFalse($thatBackend->has(
'thatEntry'));
205 $data = str_repeat(
'abcde', 1024 * 1024);
208 $this->assertTrue(
$backend->has($identifier));
209 $this->assertEquals(
$backend->get($identifier), $data);
217 $tags = array(
'UnitTestTag%test',
'UnitTestTag%boring');
219 $backend = $this->setUpBackend(TRUE);
220 $backend->_call(
'addIdentifierToTags', $identifier, $tags);
223 $backend->_call(
'findTagsByIdentifier', $identifier)
226 $backend->_call(
'addIdentifierToTags', $identifier, $tags);
229 $backend->_call(
'findTagsByIdentifier', $identifier)
239 protected function setUpBackend($accessible = FALSE) {
241 $cache = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface', array(), array(),
'', FALSE);
243 $accessibleClassName = $this->
buildAccessibleProxy(
'\\TYPO3\\CMS\\Core\\Cache\\Backend\\WincacheBackend');
244 $backend =
new $accessibleClassName(
'Testing');
setRemovesTagsFromPreviousSet()
itIsPossibleToSetAndCheckExistenceInCache()
itIsPossibleToOverwriteAnEntryInTheCache()
removeReturnsFalseIfTheEntryDoesntExist()
flushRemovesAllCacheEntries()
flushByTagRemovesCacheEntriesWithSpecifiedTag()
hasReturnsFalseIfTheEntryDoesntExist()
findIdentifiersByTagFindsSetEntries()
itIsPossibleToSetAndGetEntry()
buildAccessibleProxy($className)
setTagsOnlyOnceToIdentifier()
setThrowsExceptionIfNoFrontEndHasBeenSet()
itIsPossibleToRemoveEntryFromCache()