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