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