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