[TASK] Increase code coverage of FrontendConfigurationManager
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Core / BootstrapTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Core;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * This class is a backport of the corresponding class of TYPO3 Flow.
8 * All credits go to the TYPO3 Flow team.
9 * All rights reserved
10 *
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.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 * A copy is found in the textfile GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the script!
29 ***************************************************************/
30 class BootstrapTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
31
32 /**
33 * @var \TYPO3\CMS\Extbase\Core\Bootstrap|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
34 */
35 protected $bootstrapMock;
36
37 /**
38 * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManager
39 */
40 protected $configurationManager;
41
42 /**
43 * @var \TYPO3\CMS\Extbase\Object\ObjectManager
44 */
45 protected $objectManager;
46
47 /**
48 * @var array
49 */
50 protected $frameworkSettings = array();
51
52 /**
53 * Sets up this testcase
54 */
55 public function setUp() {
56 $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
57
58 $this->configurationManager = $this->getAccessibleMock('TYPO3\CMS\Extbase\Configuration\ConfigurationManager', array('getConfiguration'));
59 $this->bootstrapMock = $this->getAccessibleMock('TYPO3\CMS\Extbase\Core\Bootstrap', array('inject'));
60 $this->bootstrapMock->_set('objectManager', $this->objectManager);
61 }
62
63 /**
64 * @test
65 * @author Alexander Schnitzler <alex.schnitzler@typovision.de>
66 */
67 public function pluginConfigurationAffectsAlternativeImplementationPropertyOfObjectContainer() {
68 $this->frameworkSettings['objects'] = array(
69 'TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface' => array(
70 'className' => 'TYPO3\CMS\Extbase\Persistence\Reddis\PersistenceManager'
71 )
72 );
73
74 $this->configurationManager->expects($this->any())->method('getConfiguration')->with('Framework')->will($this->returnValue($this->frameworkSettings));
75 $this->bootstrapMock->_set('configurationManager', $this->configurationManager);
76 $this->bootstrapMock->configureObjectManager();
77
78 /** @var $objectContainer \TYPO3\CMS\Extbase\Object\Container\Container */
79 $objectContainer = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Object\\Container\\Container');
80
81 $class = new \ReflectionClass(get_class($objectContainer));
82 $property = $class->getProperty('alternativeImplementation');
83 $property->setAccessible(TRUE);
84 $alternativeImplementation = $property->getValue($objectContainer);
85
86 $this->assertEquals(
87 'TYPO3\CMS\Extbase\Persistence\Reddis\PersistenceManager',
88 $alternativeImplementation['TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface']
89 );
90 }
91 }
92
93 ?>