31 $cache = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array(
'isValidEntryIdentifier'), array(),
'', FALSE);
32 $cache->expects($this->once())->method(
'isValidEntryIdentifier')->with(
'foo')->will($this->returnValue(FALSE));
33 $cache->set(
'foo',
'bar');
40 $theString =
'Just some value';
41 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
42 $backend->expects($this->once())->method(
'set')->with($this->equalTo(
'VariableCacheTest'), $this->equalTo(serialize($theString)));
44 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
45 $cache->set(
'VariableCacheTest', $theString);
52 $theArray = array(
'Just some value',
'and another one.');
53 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
54 $backend->expects($this->once())->method(
'set')->with($this->equalTo(
'VariableCacheTest'), $this->equalTo(serialize($theArray)));
56 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
57 $cache->set(
'VariableCacheTest', $theArray);
64 $theString =
'Just some value';
66 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
67 $backend->expects($this->once())->method(
'set')->with($this->equalTo(
'VariableCacheTest'), $this->equalTo(serialize($theString)), $this->equalTo(array()), $this->equalTo($theLifetime));
69 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
70 $cache->set(
'VariableCacheTest', $theString, array(), $theLifetime);
77 if (!extension_loaded(
'igbinary')) {
78 $this->markTestSkipped(
'Cannot test igbinary support, because igbinary is not installed.');
81 $theString =
'Just some value';
82 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
83 $backend->expects($this->once())->method(
'set')->with($this->equalTo(
'VariableCacheTest'), $this->equalTo(igbinary_serialize($theString)));
85 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
86 $cache->initializeObject();
87 $cache->set(
'VariableCacheTest', $theString);
94 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
95 $backend->expects($this->once())->method(
'get')->will($this->returnValue(serialize(
'Just some value')));
97 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
98 $this->assertEquals(
'Just some value', $cache->get(
'VariableCacheTest'),
'The returned value was not the expected string.');
105 $theArray = array(
'Just some value',
'and another one.');
106 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
107 $backend->expects($this->once())->method(
'get')->will($this->returnValue(serialize($theArray)));
109 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
110 $this->assertEquals($theArray, $cache->get(
'VariableCacheTest'),
'The returned value was not the expected unserialized array.');
117 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
118 $backend->expects($this->once())->method(
'get')->will($this->returnValue(serialize(FALSE)));
120 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
121 $this->assertFalse($cache->get(
'VariableCacheTest'),
'The returned value was not the FALSE.');
128 if (!extension_loaded(
'igbinary')) {
129 $this->markTestSkipped(
'Cannot test igbinary support, because igbinary is not installed.');
132 $theArray = array(
'Just some value',
'and another one.');
133 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
134 $backend->expects($this->once())->method(
'get')->will($this->returnValue(igbinary_serialize($theArray)));
136 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
137 $cache->initializeObject();
139 $this->assertEquals($theArray, $cache->get(
'VariableCacheTest'),
'The returned value was not the expected unserialized array.');
146 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
147 $backend->expects($this->once())->method(
'has')->with($this->equalTo(
'VariableCacheTest'))->will($this->returnValue(TRUE));
149 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
150 $this->assertTrue($cache->has(
'VariableCacheTest'),
'has() did not return TRUE.');
157 $cacheIdentifier =
'someCacheIdentifier';
158 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
160 $backend->expects($this->once())->method(
'remove')->with($this->equalTo($cacheIdentifier))->will($this->returnValue(TRUE));
162 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
163 $this->assertTrue($cache->remove($cacheIdentifier),
'remove() did not return TRUE');
171 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\BackendInterface', array(), array(),
'', FALSE);
172 $backend->expects($this->never())->method(
'getByTag');
174 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
175 $cache->getByTag(
'SomeInvalid\Tag');
183 $identifiers = array(
'one',
'two');
184 $entries = array(
'one value',
'two value');
185 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
187 $backend->expects($this->once())->method(
'findIdentifiersByTag')->with($this->equalTo($tag))->will($this->returnValue($identifiers));
188 $backend->expects($this->exactly(2))->method(
'get')->will($this->onConsecutiveCalls(serialize(
'one value'), serialize(
'two value')));
190 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
191 $this->assertEquals($entries, $cache->getByTag($tag),
'Did not receive the expected entries');
198 if (!extension_loaded(
'igbinary')) {
199 $this->markTestSkipped(
'Cannot test igbinary support, because igbinary is not installed.');
203 $identifiers = array(
'one',
'two');
204 $entries = array(
'one value',
'two value');
205 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
207 $backend->expects($this->once())->method(
'findIdentifiersByTag')->with($this->equalTo($tag))->will($this->returnValue($identifiers));
208 $backend->expects($this->exactly(2))->method(
'get')->will($this->onConsecutiveCalls(igbinary_serialize(
'one value'), igbinary_serialize(
'two value')));
210 $cache = new \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend(
'VariableFrontend',
$backend);
211 $cache->initializeObject();
212 $this->assertEquals($entries, $cache->getByTag($tag),
'Did not receive the expected entries');
getFetchesStringValueFromBackend()
hasReturnsResultFromBackend()
getUsesIgBinaryIfAvailable()
setPassesSerializedStringToBackend()
setChecksIfTheIdentifierIsValid()
setPassesSerializedArrayToBackend()
setUsesIgBinarySerializeIfAvailable()
getFetchesFalseBooleanValueFromBackend()
getByTagRejectsInvalidTags()
getByTagUsesIgBinaryIfAvailable()
getFetchesArrayValueFromBackend()
setPassesLifetimeToBackend()