2 /***************************************************************
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
8 * This class is a backport of the corresponding class of FLOW3.
9 * All credits go to the v5 team.
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 class Tx_Extbase_Configuration_AbstractConfigurationManager_testcase
extends Tx_Extbase_BaseTestCase
{
33 public function settingsCanBeLoaded() {
34 $expectedSettings = array(
50 $configurationSource = $this->getMock('Tx_Extbase_Configuration_Source_TypoScriptSource', array('load'));
51 $configurationSource->expects($this->any())
53 ->with('Tx_Extbase_Foo_Bar')
54 ->will($this->returnValue($expectedSettings));
55 $configurationSources = array();
56 $configurationSources[] = $configurationSource;
58 $configurationManager = $this->getMock('Tx_Extbase_Configuration_AbstractConfigurationManager', array('loadTypoScriptSetup', 'getContextSpecificFrameworkConfiguration'), array($configurationSources));
59 $actualSettings = $configurationManager->getSettings('Tx_Extbase_Foo_Bar');
61 $this->assertEquals($expectedSettings, $actualSettings, 'The retrieved settings differs from the retrieved settings.');
67 public function storagePidFromExtbaseConfigurationOverridesDefaultStoragePid() {
68 $typoScriptSetup = array(
70 'tx_extbase.' => array(
71 'persistence' => array(
72 'storagePid' => 'newStoragePid'
77 $pluginConfiguration = array();
79 $configurationManager = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Configuration_AbstractConfigurationManager'), array('loadTypoScriptSetup', 'getContextSpecificFrameworkConfiguration'), array(), '', FALSE);
80 $configurationManager->expects($this->any())->method('loadTypoScriptSetup')->will($this->returnValue($typoScriptSetup));
81 $configurationManager->expects($this->any())->method('getContextSpecificFrameworkConfiguration')->will($this->returnValue(array()));
82 $expectedResult = array(
83 'persistence' => array(
84 'storagePid' => 'newStoragePid',
87 $actualResult = $configurationManager->getFrameworkConfiguration($pluginConfiguration);
89 $this->assertEquals($expectedResult, $actualResult);
95 public function getFrameworkConfigurationCorrectlyMergesPluginConfigurationWithExtbaseConfiguration() {
96 $typoScriptSetup = array(
98 'tx_extbase.' => array(
100 'persistence' => array(
102 'storagePid' => 'shouldBeOverwritten'
107 $pluginConfiguration = array(
108 'settings' => '< settingsReference',
109 'persistence' => '< persistenceReference',
110 'view' => '< viewReference',
113 $mockTypoScriptParser = $this->getMock('t3lib_TSparser');
114 $mockTypoScriptParser->expects($this->at(0))->method('getVal')->with('settingsReference', $typoScriptSetup)->will($this->returnValue(array('', array('resolved' => 'settingsReference'))));
115 $mockTypoScriptParser->expects($this->at(1))->method('getVal')->with('persistenceReference', $typoScriptSetup)->will($this->returnValue(array('', array('storagePid' => 'overwritten'))));
116 $mockTypoScriptParser->expects($this->at(2))->method('getVal')->with('viewReference', $typoScriptSetup)->will($this->returnValue(array('', array('resolved' => 'viewReference'))));
118 $configurationManager = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Configuration_AbstractConfigurationManager'), array('loadTypoScriptSetup', 'getContextSpecificFrameworkConfiguration'), array(), '', FALSE);
119 $configurationManager->_set('typoScriptParser', $mockTypoScriptParser);
120 $configurationManager->expects($this->any())->method('loadTypoScriptSetup')->will($this->returnValue($typoScriptSetup));
121 $configurationManager->expects($this->any())->method('getContextSpecificFrameworkConfiguration')->will($this->returnValue(array()));
123 $expectedResult = array(
124 'persistence' => array(
125 'storagePid' => 'overwritten',
130 'resolved' => 'settingsReference'
133 'resolved' => 'viewReference'
136 $actualResult = $configurationManager->getFrameworkConfiguration($pluginConfiguration);
138 $this->assertEquals($expectedResult, $actualResult);