33 $GLOBALS[
'TYPO3_DB'] = $this->getMock(
'TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array());
34 $GLOBALS[
'TYPO3_DB']->expects($this->any())->method(
'fullQuoteStr')->will($this->onConsecutiveCalls(
'\'tx_phpunit\
'',
'\'someKey\
'',
'\'tx_phpunit\
'',
'\'someKey\
''));
35 $this->registry = new \TYPO3\CMS\Core\Registry();
43 $this->registry->get(
'',
'someKey');
51 $this->registry->get(
't',
'someKey');
58 $testKey =
'TYPO3\\CMS\\Core\\Registry_testcase.testData.getRetrievesTheCorrectEntry';
59 $testValue =
'getRetrievesTheCorrectEntry';
60 $GLOBALS[
'TYPO3_DB']->expects($this->once())->method(
'exec_SELECTgetRows')->with(
'*',
'sys_registry',
'entry_namespace = \'tx_phpunit\'')->will($this->returnValue(array(
61 array(
'entry_key' => $testKey,
'entry_value' => serialize($testValue))
63 $this->assertEquals($this->registry->get(
'tx_phpunit', $testKey), $testValue,
'The actual data did not match the expected data.');
70 $testKey1 =
'TYPO3\\CMS\\Core\\Registry_testcase.testData.getLazyLoadsEntriesOfOneNamespace1';
71 $testValue1 =
'getLazyLoadsEntriesOfOneNamespace1';
72 $testKey2 =
'TYPO3\\CMS\\Core\\Registry_testcase.testData.getLazyLoadsEntriesOfOneNamespace2';
73 $testValue2 =
'getLazyLoadsEntriesOfOneNamespace2';
74 $GLOBALS[
'TYPO3_DB']->expects($this->once())->method(
'exec_SELECTgetRows')->with(
'*',
'sys_registry',
'entry_namespace = \'tx_phpunit\'')->will($this->returnValue(array(
75 array(
'entry_key' => $testKey1,
'entry_value' => serialize($testValue1)),
76 array(
'entry_key' => $testKey2,
'entry_value' => serialize($testValue2))
78 $this->assertEquals($this->registry->get(
'tx_phpunit', $testKey1), $testValue1,
'The actual data did not match the expected data.');
79 $this->assertEquals($this->registry->get(
'tx_phpunit', $testKey2), $testValue2,
'The actual data did not match the expected data.');
86 $defaultValue =
'getReturnsTheDefaultValueIfTheRequestedKeyWasNotFound';
87 $GLOBALS[
'TYPO3_DB']->expects($this->once())->method(
'exec_SELECTgetRows')->with(
'*',
'sys_registry',
'entry_namespace = \'tx_phpunit\'')->will($this->returnValue(array(
88 array(
'entry_key' =>
'foo',
'entry_value' =>
'bar')
90 $this->assertEquals($defaultValue, $this->registry->get(
'tx_phpunit',
'someNonExistingKey', $defaultValue),
'A value other than the default value was returned.');
98 $this->registry->set(
'',
'someKey',
'someValue');
106 $this->registry->set(
't',
'someKey',
'someValue');
113 $registry = $this->getMock(
'TYPO3\\CMS\\Core\\Registry', array(
'loadEntriesByNamespace'));
114 $registry->set(
'tx_thisIsValid',
'someKey',
'someValue');
115 $registry->set(
'thisIsValid',
'someKey',
'someValue');
116 $registry->set(
'user_soIsThis',
'someKey',
'someValue');
117 $registry->set(
'core',
'someKey',
'someValue');
124 $GLOBALS[
'TYPO3_DB']->expects($this->once())->method(
'exec_INSERTquery')->with(
'sys_registry', array(
125 'entry_namespace' =>
'tx_phpunit',
126 'entry_key' =>
'someKey',
127 'entry_value' => serialize(
'someValue')
129 $registry = $this->getMock(
'TYPO3\\CMS\\Core\\Registry', array(
'loadEntriesByNamespace'));
130 $registry->set(
'tx_phpunit',
'someKey',
'someValue');
137 $GLOBALS[
'TYPO3_DB']->expects($this->once())->method(
'exec_SELECTquery')->with(
'uid',
'sys_registry',
'entry_namespace = \'tx_phpunit\' AND entry_key = \'someKey\'')->will($this->returnValue(
'DBResource'));
138 $GLOBALS[
'TYPO3_DB']->expects($this->once())->method(
'sql_num_rows')->with(
'DBResource')->will($this->returnValue(1));
139 $GLOBALS[
'TYPO3_DB']->expects($this->once())->method(
'exec_UPDATEquery')->with(
'sys_registry',
'entry_namespace = \'tx_phpunit\' AND entry_key = \'someKey\'', array(
140 'entry_value' => serialize(
'someValue')
142 $GLOBALS[
'TYPO3_DB']->expects($this->never())->method(
'exec_INSERTquery');
143 $registry = $this->getMock(
'TYPO3\\CMS\\Core\\Registry', array(
'loadEntriesByNamespace'));
144 $registry->set(
'tx_phpunit',
'someKey',
'someValue');
152 $this->registry->remove(
't',
'someKey');
159 $GLOBALS[
'TYPO3_DB']->expects($this->once())->method(
'exec_DELETEquery')->with(
'sys_registry',
'entry_namespace = \'tx_phpunit\' AND entry_key = \'someKey\'');
160 $this->registry->remove(
'tx_phpunit',
'someKey');
167 $registry = $this->getMock(
'TYPO3\\CMS\\Core\\Registry', array(
'loadEntriesByNamespace'));
168 $registry->set(
'tx_phpunit',
'someKey',
'someValue');
169 $registry->set(
'tx_phpunit',
'someOtherKey',
'someOtherValue');
170 $registry->set(
'tx_otherNamespace',
'someKey',
'someValueInOtherNamespace');
171 $registry->remove(
'tx_phpunit',
'someKey');
172 $this->assertEquals(
'defaultValue',
$registry->get(
'tx_phpunit',
'someKey',
'defaultValue'),
'A value other than the default value was returned, thus the entry was still present.');
173 $this->assertEquals(
'someOtherValue',
$registry->get(
'tx_phpunit',
'someOtherKey',
'defaultValue'),
'A value other than the stored value was returned, thus the entry was removed.');
174 $this->assertEquals(
'someValueInOtherNamespace',
$registry->get(
'tx_otherNamespace',
'someKey',
'defaultValue'),
'A value other than the stored value was returned, thus the entry was removed.');
182 $this->registry->removeAllByNamespace(
'');
189 $GLOBALS[
'TYPO3_DB']->expects($this->once())->method(
'exec_DELETEquery')->with(
'sys_registry',
'entry_namespace = \'tx_phpunit\'');
190 $this->registry->removeAllByNamespace(
'tx_phpunit');
197 $registry = $this->getMock(
'TYPO3\\CMS\\Core\\Registry', array(
'loadEntriesByNamespace'));
198 $registry->set(
'tx_phpunit',
'someKey',
'someValue');
199 $registry->set(
'tx_phpunit',
'someOtherKey',
'someOtherValue');
200 $registry->set(
'tx_otherNamespace',
'someKey',
'someValueInOtherNamespace');
201 $registry->removeAllByNamespace(
'tx_phpunit');
202 $this->assertEquals(
'defaultValue',
$registry->get(
'tx_phpunit',
'someKey',
'defaultValue'),
'A value other than the default value was returned, thus the entry was still present.');
203 $this->assertEquals(
'defaultValue',
$registry->get(
'tx_phpunit',
'someOtherKey',
'defaultValue'),
'A value other than the default value was returned, thus the entry was still present.');
204 $this->assertEquals(
'someValueInOtherNamespace',
$registry->get(
'tx_otherNamespace',
'someKey',
'defaultValue'),
'A value other than the stored value was returned, thus the entry was removed.');
removeReallyRemovesTheEntryFromTheDatabase()
removeThrowsAnExceptionOnWrongNamespace()
setThrowsAnExceptionOnWrongNamespace()
setReallySavesTheGivenValueToTheDatabase()
getThrowsExceptionForInvalidNamespacesUsingTooShortNamespace()
removeAllByNamespaceUnsetsValuesOfTheSpecifiedNamespaceFromTheInternalEntriesCache()
removeAllByNamespaceReallyRemovesAllEntriesOfTheSpecifiedNamespaceFromTheDatabase()
removeAllByNamespaceThrowsAnExceptionOnWrongNamespace()
getLazyLoadsEntriesOfOneNamespace()
removeUnsetsValueFromTheInternalEntriesCache()
setThrowsAnExceptionOnEmptyNamespace()
getRetrievesTheCorrectEntry()
getReturnsTheDefaultValueIfTheRequestedKeyWasNotFound()
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
setAllowsValidNamespaces()
getThrowsExceptionForInvalidNamespacesUsingNoNamespace()