[TASK] Extension Manager: Remove superfluous tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Tests / Unit / Utility / ListUtilityTest.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Utility;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012 Susanne Moog, <susanne.moog@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * Testcase for the Tx_Extensionmanager_Utility_List class in the TYPO3 Core.
28 *
29 * @package Extension Manager
30 * @subpackage Tests
31 */
32 class ListUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
33
34 /**
35 * @var \TYPO3\CMS\Extensionmanager\Utility\ListUtility
36 */
37 private $fixture;
38
39 private $loadedExtensions = array();
40
41 /**
42 * @return void
43 */
44 public function setUp() {
45 $this->fixture = new \TYPO3\CMS\Extensionmanager\Utility\ListUtility();
46 $this->loadedExtensions = $GLOBALS['TYPO3_LOADED_EXT'];
47 $GLOBALS['TYPO3_LOADED_EXT'] = array(
48 'cms' => 'cms',
49 'lang' => 'lang',
50 'news' => 'news',
51 'saltedpasswords' => 'saltedpasswords',
52 'rsaauth' => 'rsaauth'
53 );
54 }
55
56 /**
57 * @return void
58 */
59 public function tearDown() {
60 unset($this->fixture);
61 $GLOBALS['TYPO3_LOADED_EXT'] = $this->loadedExtensions;
62 }
63
64 /**
65 * @return array
66 */
67 public function getAvailableAndInstalledExtensionsDataProvider() {
68 return array(
69 'same extension lists' => array(
70 array(
71 'cms' => array(),
72 'lang' => array(),
73 'news' => array(),
74 'saltedpasswords' => array(),
75 'rsaauth' => array()
76 ),
77 array(
78 'cms' => array('installed' => TRUE),
79 'lang' => array('installed' => TRUE),
80 'news' => array('installed' => TRUE),
81 'saltedpasswords' => array('installed' => TRUE),
82 'rsaauth' => array('installed' => TRUE)
83 )
84 ),
85 'different extension lists' => array(
86 array(
87 'cms' => array(),
88 'lang' => array(),
89 'news' => array(),
90 'saltedpasswords' => array(),
91 'rsaauth' => array()
92 ),
93 array(
94 'cms' => array('installed' => TRUE),
95 'lang' => array('installed' => TRUE),
96 'news' => array('installed' => TRUE),
97 'saltedpasswords' => array('installed' => TRUE),
98 'rsaauth' => array('installed' => TRUE)
99 )
100 ),
101 'different extension lists - set2' => array(
102 array(
103 'cms' => array(),
104 'lang' => array(),
105 'news' => array(),
106 'saltedpasswords' => array(),
107 'rsaauth' => array(),
108 'em' => array()
109 ),
110 array(
111 'cms' => array('installed' => TRUE),
112 'lang' => array('installed' => TRUE),
113 'news' => array('installed' => TRUE),
114 'saltedpasswords' => array('installed' => TRUE),
115 'rsaauth' => array('installed' => TRUE),
116 'em' => array()
117 )
118 ),
119 'different extension lists - set3' => array(
120 array(
121 'cms' => array(),
122 'lang' => array(),
123 'fluid' => array(),
124 'news' => array(),
125 'saltedpasswords' => array(),
126 'rsaauth' => array(),
127 'em' => array()
128 ),
129 array(
130 'cms' => array('installed' => TRUE),
131 'lang' => array('installed' => TRUE),
132 'fluid' => array(),
133 'news' => array('installed' => TRUE),
134 'saltedpasswords' => array('installed' => TRUE),
135 'rsaauth' => array('installed' => TRUE),
136 'em' => array()
137 )
138 )
139 );
140 }
141
142 /**
143 * @test
144 * @dataProvider getAvailableAndInstalledExtensionsDataProvider
145 * @param $availableExtensions
146 * @param $expectedResult
147 * @return void
148 */
149 public function getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult) {
150 $this->assertEquals($expectedResult, $this->fixture->getAvailableAndInstalledExtensions($availableExtensions));
151 }
152
153 /**
154 * @return array
155 */
156 public function enrichExtensionsWithEmConfInformationDataProvider() {
157 return array(
158 'simple key value array emconf' => array(
159 array(
160 'cms' => array('test' => 'test2'),
161 'lang' => array('property1' => 'oldvalue'),
162 'news' => array(),
163 'saltedpasswords' => array(),
164 'rsaauth' => array()
165 ),
166 array(
167 'property1' => 'property value1'
168 ),
169 array(
170 'cms' => array('test' => 'test2', 'property1' => 'property value1'),
171 'lang' => array('property1' => 'oldvalue'),
172 'news' => array('property1' => 'property value1'),
173 'saltedpasswords' => array('property1' => 'property value1'),
174 'rsaauth' => array('property1' => 'property value1')
175 )
176 )
177 );
178 }
179
180 /**
181 * @test
182 * @dataProvider enrichExtensionsWithEmConfInformationDataProvider
183 * @param $extensions
184 * @param $emConf
185 * @param $expectedResult
186 * @return void
187 */
188 public function enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult) {
189 $this->fixture->extensionRepository = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('findOneByExtensionKeyAndVersion'));
190 $this->fixture->emConfUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\EmConfUtility');
191 $this->fixture->emConfUtility->expects($this->any())->method('includeEmConf')->will($this->returnValue($emConf));
192 $this->assertEquals($expectedResult, $this->fixture->enrichExtensionsWithEmConfAndTerInformation($extensions));
193 }
194
195 }
196
197
198 ?>