[TASK] Re-work/simplify copyright header in PHP files - Part 9
[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 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16 use TYPO3\CMS\Cms\Package;
17
18 /**
19 * List utility test
20 *
21 */
22 class ListUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
23
24 /**
25 * @var \TYPO3\CMS\Extensionmanager\Utility\ListUtility
26 */
27 protected $subject;
28
29 /**
30 * @return void
31 */
32 public function setUp() {
33 $this->subject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility', array('emitPackagesMayHaveChangedSignal'));
34 $packageManagerMock = $this->getMock('TYPO3\\CMS\\Core\\Package\\PackageManager');
35 $packageManagerMock
36 ->expects($this->any())
37 ->method('getActivePackages')
38 ->will($this->returnValue(array(
39 'cms' => $this->getMock('TYPO3\\CMS\\Cms\\Package', array(), array(), '', FALSE),
40 'lang' => $this->getMock('TYPO3\\CMS\\Cms\\Package', array(), array(), '', FALSE),
41 'news' => $this->getMock('TYPO3\\CMS\\Cms\\Package', array(), array(), '', FALSE),
42 'saltedpasswords' => $this->getMock('TYPO3\\CMS\\Cms\\Package', array(), array(), '', FALSE),
43 'rsaauth' => $this->getMock('TYPO3\\CMS\\Cms\\Package', array(), array(), '', FALSE),
44 )));
45 $this->inject($this->subject, 'packageManager', $packageManagerMock);
46 }
47
48 /**
49 * @return array
50 */
51 public function getAvailableAndInstalledExtensionsDataProvider() {
52 return array(
53 'same extension lists' => array(
54 array(
55 'cms' => array(),
56 'lang' => array(),
57 'news' => array(),
58 'saltedpasswords' => array(),
59 'rsaauth' => array()
60 ),
61 array(
62 'cms' => array('installed' => TRUE),
63 'lang' => array('installed' => TRUE),
64 'news' => array('installed' => TRUE),
65 'saltedpasswords' => array('installed' => TRUE),
66 'rsaauth' => array('installed' => TRUE)
67 )
68 ),
69 'different 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 - set2' => array(
86 array(
87 'cms' => array(),
88 'lang' => array(),
89 'news' => array(),
90 'saltedpasswords' => array(),
91 'rsaauth' => array(),
92 'em' => 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 'em' => array()
101 )
102 ),
103 'different extension lists - set3' => array(
104 array(
105 'cms' => array(),
106 'lang' => array(),
107 'fluid' => array(),
108 'news' => array(),
109 'saltedpasswords' => array(),
110 'rsaauth' => array(),
111 'em' => array()
112 ),
113 array(
114 'cms' => array('installed' => TRUE),
115 'lang' => array('installed' => TRUE),
116 'fluid' => array(),
117 'news' => array('installed' => TRUE),
118 'saltedpasswords' => array('installed' => TRUE),
119 'rsaauth' => array('installed' => TRUE),
120 'em' => array()
121 )
122 )
123 );
124 }
125
126 /**
127 * @test
128 * @dataProvider getAvailableAndInstalledExtensionsDataProvider
129 * @param $availableExtensions
130 * @param $expectedResult
131 * @return void
132 */
133 public function getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult) {
134 $this->assertEquals($expectedResult, $this->subject->getAvailableAndInstalledExtensions($availableExtensions));
135 }
136
137 /**
138 * @return array
139 */
140 public function enrichExtensionsWithEmConfInformationDataProvider() {
141 return array(
142 'simple key value array emconf' => array(
143 array(
144 'cms' => array('test' => 'test2'),
145 'lang' => array('property1' => 'oldvalue'),
146 'news' => array(),
147 'saltedpasswords' => array(),
148 'rsaauth' => array()
149 ),
150 array(
151 'property1' => 'property value1'
152 ),
153 array(
154 'cms' => array('test' => 'test2', 'property1' => 'property value1'),
155 'lang' => array('property1' => 'oldvalue'),
156 'news' => array('property1' => 'property value1'),
157 'saltedpasswords' => array('property1' => 'property value1'),
158 'rsaauth' => array('property1' => 'property value1')
159 )
160 )
161 );
162 }
163
164 /**
165 * @test
166 * @dataProvider enrichExtensionsWithEmConfInformationDataProvider
167 * @param $extensions
168 * @param $emConf
169 * @param $expectedResult
170 * @return void
171 */
172 public function enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult) {
173 $this->inject($this->subject, 'extensionRepository', $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('findOneByExtensionKeyAndVersion'), array(), '', FALSE));
174 $emConfUtilityMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\EmConfUtility');
175 $emConfUtilityMock->expects($this->any())->method('includeEmConf')->will($this->returnValue($emConf));
176 $this->inject($this->subject, 'emConfUtility', $emConfUtilityMock);
177 $this->assertEquals($expectedResult, $this->subject->enrichExtensionsWithEmConfAndTerInformation($extensions));
178 }
179 }