TYPO3 CMS  TYPO3_6-2
LocalizationFactoryTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
25 
29  public function getParsedDataHandlesLocallangXMLOverride() {
31  $subject = new LocalizationFactory;
32 
33  $unique = 'locallangXMLOverrideTest' . substr($this->getUniqueId(), 0, 10);
34  $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
35  <T3locallang>
36  <data type="array">
37  <languageKey index="default" type="array">
38  <label index="buttons.logout">EXIT</label>
39  </languageKey>
40  </data>
41  </T3locallang>';
42  $file = PATH_site . 'typo3temp/' . $unique . '.xml';
44  // Make sure there is no cached version of the label
45  GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('l10n')->flush();
46  // Get default value
47  $defaultLL = $subject->getParsedData('EXT:lang/locallang_core.xlf', 'default', 'utf-8', 0);
48  // Clear language cache again
49  GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('l10n')->flush();
50  // Set override file
51  $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:lang/locallang_core.xlf'][$unique] = $file;
53  $store = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Localization\\LanguageStore');
54  $store->flushData('EXT:lang/locallang_core.xlf');
55  // Get override value
56  $overrideLL = $subject->getParsedData('EXT:lang/locallang_core.xlf', 'default', 'utf-8', 0);
57  // Clean up again
58  unlink($file);
59  $this->assertNotEquals($overrideLL['default']['buttons.logout'][0]['target'], '');
60  $this->assertNotEquals($defaultLL['default']['buttons.logout'][0]['target'], $overrideLL['default']['buttons.logout'][0]['target']);
61  $this->assertEquals($overrideLL['default']['buttons.logout'][0]['target'], 'EXIT');
62  }
63 
67  public function getParsedDataCallsLocalizationOverrideIfFileNotFoundExceptionIsThrown() {
69  $localizationFactory = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Localization\\LocalizationFactory', array('localizationOverride'));
70  $languageStore = $this->getMock('TYPO3\\CMS\\Core\\Localization\\LanguageStore', array('hasData', 'setConfiguration', 'getData', 'setData'));
71  $cacheInstance = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend', array('get', 'set'), array(), '', FALSE);
72  $localizationFactory->_set('store', $languageStore);
73  $localizationFactory->_set('cacheInstance', $cacheInstance);
74  $languageStore->method('hasData')->willReturn(FALSE);
75  $languageStore->method('getData')->willReturn(array());
76  $languageStore->method('setConfiguration')->willThrowException(new FileNotFoundException());
77  $cacheInstance->method('get')->willReturn(FALSE);
78  $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'] = array('foo' => 'bar');
79 
80  $localizationFactory->expects($this->once())->method('localizationOverride');
81  $localizationFactory->getParsedData('EXT:backend/Resources/Private/Language/locallang_layout.xlf', 'default', 'utf-8', 0);
82  }
83 
84 }
static writeFileToTypo3tempDir($filepath, $content)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]