TYPO3  7.6
ListUtilityTest.php
Go to the documentation of this file.
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 
22 class ListUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
23 {
27  protected $subject;
28 
32  protected function setUp()
33  {
34  $this->subject = $this->getMock(\TYPO3\CMS\Extensionmanager\Utility\ListUtility::class, array('emitPackagesMayHaveChangedSignal'));
35  $packageManagerMock = $this->getMock(\TYPO3\CMS\Core\Package\PackageManager::class);
36  $packageManagerMock
37  ->expects($this->any())
38  ->method('getActivePackages')
39  ->will($this->returnValue(array(
40  'lang' => $this->getMock(\TYPO3\CMS\Core\Package::class, array(), array(), '', false),
41  'news' => $this->getMock(\TYPO3\CMS\Core\Package::class, array(), array(), '', false),
42  'saltedpasswords' => $this->getMock(\TYPO3\CMS\Core\Package::class, array(), array(), '', false),
43  'rsaauth' => $this->getMock(\TYPO3\CMS\Core\Package::class, array(), array(), '', false),
44  )));
45  $this->inject($this->subject, 'packageManager', $packageManagerMock);
46  }
47 
52  {
53  return array(
54  'same extension lists' => array(
55  array(
56  'lang' => array(),
57  'news' => array(),
58  'saltedpasswords' => array(),
59  'rsaauth' => array()
60  ),
61  array(
62  'lang' => array('installed' => true),
63  'news' => array('installed' => true),
64  'saltedpasswords' => array('installed' => true),
65  'rsaauth' => array('installed' => true)
66  )
67  ),
68  'different extension lists' => array(
69  array(
70  'lang' => array(),
71  'news' => array(),
72  'saltedpasswords' => array(),
73  'rsaauth' => array()
74  ),
75  array(
76  'lang' => array('installed' => true),
77  'news' => array('installed' => true),
78  'saltedpasswords' => array('installed' => true),
79  'rsaauth' => array('installed' => true)
80  )
81  ),
82  'different extension lists - set2' => array(
83  array(
84  'lang' => array(),
85  'news' => array(),
86  'saltedpasswords' => array(),
87  'rsaauth' => array(),
88  'em' => array()
89  ),
90  array(
91  'lang' => array('installed' => true),
92  'news' => array('installed' => true),
93  'saltedpasswords' => array('installed' => true),
94  'rsaauth' => array('installed' => true),
95  'em' => array()
96  )
97  ),
98  'different extension lists - set3' => array(
99  array(
100  'lang' => array(),
101  'fluid' => array(),
102  'news' => array(),
103  'saltedpasswords' => array(),
104  'rsaauth' => array(),
105  'em' => array()
106  ),
107  array(
108  'lang' => array('installed' => true),
109  'fluid' => array(),
110  'news' => array('installed' => true),
111  'saltedpasswords' => array('installed' => true),
112  'rsaauth' => array('installed' => true),
113  'em' => array()
114  )
115  )
116  );
117  }
118 
126  public function getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult)
127  {
128  $this->assertEquals($expectedResult, $this->subject->getAvailableAndInstalledExtensions($availableExtensions));
129  }
130 
135  {
136  return array(
137  'simple key value array emconf' => array(
138  array(
139  'lang' => array('property1' => 'oldvalue'),
140  'news' => array(),
141  'saltedpasswords' => array(),
142  'rsaauth' => array()
143  ),
144  array(
145  'property1' => 'property value1'
146  ),
147  array(
148  'lang' => array('property1' => 'oldvalue'),
149  'news' => array('property1' => 'property value1'),
150  'saltedpasswords' => array('property1' => 'property value1'),
151  'rsaauth' => array('property1' => 'property value1')
152  )
153  )
154  );
155  }
156 
165  public function enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult)
166  {
167  $this->inject($this->subject, 'extensionRepository', $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository::class, array('findOneByExtensionKeyAndVersion', 'findHighestAvailableVersion'), array(), '', false));
168  $emConfUtilityMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Utility\EmConfUtility::class);
169  $emConfUtilityMock->expects($this->any())->method('includeEmConf')->will($this->returnValue($emConf));
170  $this->inject($this->subject, 'emConfUtility', $emConfUtilityMock);
171  $this->assertEquals($expectedResult, $this->subject->enrichExtensionsWithEmConfAndTerInformation($extensions));
172  }
173 }