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(
'StringCacheTest'), $this->equalTo($theString));
43 $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend(
'StringFrontend',
$backend);
44 $cache->set(
'StringCacheTest', $theString);
51 $theString =
'Just some value';
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(
'StringCacheTest'), $this->equalTo($theString), $this->equalTo(array()), $this->equalTo($theLifetime));
55 $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend(
'StringFrontend',
$backend);
56 $cache->set(
'StringCacheTest', $theString, array(), $theLifetime);
64 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
65 $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend(
'StringFrontend',
$backend);
66 $cache->set(
'StringCacheTest', array());
73 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
74 $backend->expects($this->once())->method(
'get')->will($this->returnValue(
'Just some value'));
75 $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend(
'StringFrontend',
$backend);
76 $this->assertEquals(
'Just some value', $cache->get(
'StringCacheTest'),
'The returned value was not the expected string.');
83 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
84 $backend->expects($this->once())->method(
'has')->with($this->equalTo(
'StringCacheTest'))->will($this->returnValue(TRUE));
85 $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend(
'StringFrontend',
$backend);
86 $this->assertTrue($cache->has(
'StringCacheTest'),
'has() did not return TRUE.');
93 $cacheIdentifier =
'someCacheIdentifier';
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(
'remove')->with($this->equalTo($cacheIdentifier))->will($this->returnValue(TRUE));
96 $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend(
'StringFrontend',
$backend);
97 $this->assertTrue($cache->remove($cacheIdentifier),
'remove() did not return TRUE');
105 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\BackendInterface', array(), array(),
'', FALSE);
106 $backend->expects($this->never())->method(
'getByTag');
107 $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend(
'StringFrontend',
$backend);
108 $cache->getByTag(
'SomeInvalid\\Tag');
116 $identifiers = array(
'one',
'two');
117 $entries = array(
'one value',
'two value');
118 $backend = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Backend\\AbstractBackend', array(
'get',
'set',
'has',
'remove',
'findIdentifiersByTag',
'flush',
'flushByTag',
'collectGarbage'), array(),
'', FALSE);
119 $backend->expects($this->once())->method(
'findIdentifiersByTag')->with($this->equalTo($tag))->will($this->returnValue($identifiers));
120 $backend->expects($this->exactly(2))->method(
'get')->will($this->onConsecutiveCalls(
'one value',
'two value'));
121 $cache = new \TYPO3\CMS\Core\Cache\Frontend\StringFrontend(
'StringFrontend',
$backend);
122 $this->assertEquals($entries, $cache->getByTag($tag),
'Did not receive the expected entries');
getByTagRejectsInvalidTags()
setPassesStringToBackend()
setThrowsInvalidDataExceptionOnNonStringValues()
hasReturnsResultFromBackend()
setPassesLifetimeToBackend()
getFetchesStringValueFromBackend()
setChecksIfTheIdentifierIsValid()