[TASK] Removes extra empty lines
[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
17 /**
18 * List utility test
19 *
20 */
21 class ListUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
22 {
23 /**
24 * @var \TYPO3\CMS\Extensionmanager\Utility\ListUtility
25 */
26 protected $subject;
27
28 /**
29 * @return void
30 */
31 protected function setUp()
32 {
33 $this->subject = $this->getMock(\TYPO3\CMS\Extensionmanager\Utility\ListUtility::class, array('emitPackagesMayHaveChangedSignal'));
34 $packageManagerMock = $this->getMock(\TYPO3\CMS\Core\Package\PackageManager::class);
35 $packageManagerMock
36 ->expects($this->any())
37 ->method('getActivePackages')
38 ->will($this->returnValue(array(
39 'lang' => $this->getMock(\TYPO3\CMS\Core\Package::class, array(), array(), '', false),
40 'news' => $this->getMock(\TYPO3\CMS\Core\Package::class, array(), array(), '', false),
41 'saltedpasswords' => $this->getMock(\TYPO3\CMS\Core\Package::class, array(), array(), '', false),
42 'rsaauth' => $this->getMock(\TYPO3\CMS\Core\Package::class, array(), array(), '', false),
43 )));
44 $this->inject($this->subject, 'packageManager', $packageManagerMock);
45 }
46
47 /**
48 * @return array
49 */
50 public function getAvailableAndInstalledExtensionsDataProvider()
51 {
52 return array(
53 'same extension lists' => array(
54 array(
55 'lang' => array(),
56 'news' => array(),
57 'saltedpasswords' => array(),
58 'rsaauth' => array()
59 ),
60 array(
61 'lang' => array('installed' => true),
62 'news' => array('installed' => true),
63 'saltedpasswords' => array('installed' => true),
64 'rsaauth' => array('installed' => true)
65 )
66 ),
67 'different extension lists' => array(
68 array(
69 'lang' => array(),
70 'news' => array(),
71 'saltedpasswords' => array(),
72 'rsaauth' => array()
73 ),
74 array(
75 'lang' => array('installed' => true),
76 'news' => array('installed' => true),
77 'saltedpasswords' => array('installed' => true),
78 'rsaauth' => array('installed' => true)
79 )
80 ),
81 'different extension lists - set2' => array(
82 array(
83 'lang' => array(),
84 'news' => array(),
85 'saltedpasswords' => array(),
86 'rsaauth' => array(),
87 'em' => array()
88 ),
89 array(
90 'lang' => array('installed' => true),
91 'news' => array('installed' => true),
92 'saltedpasswords' => array('installed' => true),
93 'rsaauth' => array('installed' => true),
94 'em' => array()
95 )
96 ),
97 'different extension lists - set3' => array(
98 array(
99 'lang' => array(),
100 'fluid' => array(),
101 'news' => array(),
102 'saltedpasswords' => array(),
103 'rsaauth' => array(),
104 'em' => array()
105 ),
106 array(
107 'lang' => array('installed' => true),
108 'fluid' => array(),
109 'news' => array('installed' => true),
110 'saltedpasswords' => array('installed' => true),
111 'rsaauth' => array('installed' => true),
112 'em' => array()
113 )
114 )
115 );
116 }
117
118 /**
119 * @test
120 * @dataProvider getAvailableAndInstalledExtensionsDataProvider
121 * @param $availableExtensions
122 * @param $expectedResult
123 * @return void
124 */
125 public function getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult)
126 {
127 $this->assertEquals($expectedResult, $this->subject->getAvailableAndInstalledExtensions($availableExtensions));
128 }
129
130 /**
131 * @return array
132 */
133 public function enrichExtensionsWithEmConfInformationDataProvider()
134 {
135 return array(
136 'simple key value array emconf' => array(
137 array(
138 'lang' => array('property1' => 'oldvalue'),
139 'news' => array(),
140 'saltedpasswords' => array(),
141 'rsaauth' => array()
142 ),
143 array(
144 'property1' => 'property value1'
145 ),
146 array(
147 'lang' => array('property1' => 'oldvalue'),
148 'news' => array('property1' => 'property value1'),
149 'saltedpasswords' => array('property1' => 'property value1'),
150 'rsaauth' => array('property1' => 'property value1')
151 )
152 )
153 );
154 }
155
156 /**
157 * @test
158 * @dataProvider enrichExtensionsWithEmConfInformationDataProvider
159 * @param $extensions
160 * @param $emConf
161 * @param $expectedResult
162 * @return void
163 */
164 public function enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult)
165 {
166 $this->inject($this->subject, 'extensionRepository', $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository::class, array('findOneByExtensionKeyAndVersion', 'findHighestAvailableVersion'), array(), '', false));
167 $emConfUtilityMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Utility\EmConfUtility::class);
168 $emConfUtilityMock->expects($this->any())->method('includeEmConf')->will($this->returnValue($emConf));
169 $this->inject($this->subject, 'emConfUtility', $emConfUtilityMock);
170 $this->assertEquals($expectedResult, $this->subject->enrichExtensionsWithEmConfAndTerInformation($extensions));
171 }
172 }