[TASK] Fix CGL violations against ClassDocComment
[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 /**
28 * List utility test
29 *
30 * @package Extension Manager
31 * @subpackage Tests
32 */
33 class ListUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
34
35 /**
36 * @var \TYPO3\CMS\Extensionmanager\Utility\ListUtility
37 */
38 private $fixture;
39
40 private $loadedExtensions = array();
41
42 /**
43 * @return void
44 */
45 public function setUp() {
46 $this->fixture = new \TYPO3\CMS\Extensionmanager\Utility\ListUtility();
47 $this->loadedExtensions = $GLOBALS['TYPO3_LOADED_EXT'];
48 $GLOBALS['TYPO3_LOADED_EXT'] = array(
49 'cms' => 'cms',
50 'lang' => 'lang',
51 'news' => 'news',
52 'saltedpasswords' => 'saltedpasswords',
53 'rsaauth' => 'rsaauth'
54 );
55 }
56
57 /**
58 * @return void
59 */
60 public function tearDown() {
61 unset($this->fixture);
62 $GLOBALS['TYPO3_LOADED_EXT'] = $this->loadedExtensions;
63 }
64
65 /**
66 * @return array
67 */
68 public function getAvailableAndInstalledExtensionsDataProvider() {
69 return array(
70 'same extension lists' => array(
71 array(
72 'cms' => array(),
73 'lang' => array(),
74 'news' => array(),
75 'saltedpasswords' => array(),
76 'rsaauth' => array()
77 ),
78 array(
79 'cms' => array('installed' => TRUE),
80 'lang' => array('installed' => TRUE),
81 'news' => array('installed' => TRUE),
82 'saltedpasswords' => array('installed' => TRUE),
83 'rsaauth' => array('installed' => TRUE)
84 )
85 ),
86 'different extension lists' => array(
87 array(
88 'cms' => array(),
89 'lang' => array(),
90 'news' => array(),
91 'saltedpasswords' => array(),
92 'rsaauth' => array()
93 ),
94 array(
95 'cms' => array('installed' => TRUE),
96 'lang' => array('installed' => TRUE),
97 'news' => array('installed' => TRUE),
98 'saltedpasswords' => array('installed' => TRUE),
99 'rsaauth' => array('installed' => TRUE)
100 )
101 ),
102 'different extension lists - set2' => array(
103 array(
104 'cms' => array(),
105 'lang' => array(),
106 'news' => array(),
107 'saltedpasswords' => array(),
108 'rsaauth' => array(),
109 'em' => array()
110 ),
111 array(
112 'cms' => array('installed' => TRUE),
113 'lang' => array('installed' => TRUE),
114 'news' => array('installed' => TRUE),
115 'saltedpasswords' => array('installed' => TRUE),
116 'rsaauth' => array('installed' => TRUE),
117 'em' => array()
118 )
119 ),
120 'different extension lists - set3' => array(
121 array(
122 'cms' => array(),
123 'lang' => array(),
124 'fluid' => array(),
125 'news' => array(),
126 'saltedpasswords' => array(),
127 'rsaauth' => array(),
128 'em' => array()
129 ),
130 array(
131 'cms' => array('installed' => TRUE),
132 'lang' => array('installed' => TRUE),
133 'fluid' => array(),
134 'news' => array('installed' => TRUE),
135 'saltedpasswords' => array('installed' => TRUE),
136 'rsaauth' => array('installed' => TRUE),
137 'em' => array()
138 )
139 )
140 );
141 }
142
143 /**
144 * @test
145 * @dataProvider getAvailableAndInstalledExtensionsDataProvider
146 * @param $availableExtensions
147 * @param $expectedResult
148 * @return void
149 */
150 public function getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult) {
151 $this->assertEquals($expectedResult, $this->fixture->getAvailableAndInstalledExtensions($availableExtensions));
152 }
153
154 /**
155 * @return array
156 */
157 public function enrichExtensionsWithEmConfInformationDataProvider() {
158 return array(
159 'simple key value array emconf' => array(
160 array(
161 'cms' => array('test' => 'test2'),
162 'lang' => array('property1' => 'oldvalue'),
163 'news' => array(),
164 'saltedpasswords' => array(),
165 'rsaauth' => array()
166 ),
167 array(
168 'property1' => 'property value1'
169 ),
170 array(
171 'cms' => array('test' => 'test2', 'property1' => 'property value1'),
172 'lang' => array('property1' => 'oldvalue'),
173 'news' => array('property1' => 'property value1'),
174 'saltedpasswords' => array('property1' => 'property value1'),
175 'rsaauth' => array('property1' => 'property value1')
176 )
177 )
178 );
179 }
180
181 /**
182 * @test
183 * @dataProvider enrichExtensionsWithEmConfInformationDataProvider
184 * @param $extensions
185 * @param $emConf
186 * @param $expectedResult
187 * @return void
188 */
189 public function enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult) {
190 $this->fixture->extensionRepository = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('findOneByExtensionKeyAndVersion'));
191 $this->fixture->emConfUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\EmConfUtility');
192 $this->fixture->emConfUtility->expects($this->any())->method('includeEmConf')->will($this->returnValue($emConf));
193 $this->assertEquals($expectedResult, $this->fixture->enrichExtensionsWithEmConfAndTerInformation($extensions));
194 }
195
196 }
197
198
199 ?>