‪TYPO3CMS  9.5
ListUtilityTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 use TYPO3\CMS\Core\Package\PackageManager;
21 use TYPO3\CMS\Extensionmanager\Utility\EmConfUtility;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪ListUtilityTest extends UnitTestCase
29 {
33  protected ‪$subject;
34 
37  protected function ‪setUp()
38  {
39  $this->subject = $this->getMockBuilder(ListUtility::class)
40  ->setMethods(['emitPackagesMayHaveChangedSignal'])
41  ->getMock();
42  $packageManagerMock = $this->getMockBuilder(PackageManager::class)
43  ->disableOriginalConstructor()
44  ->getMock();
45  $packageManagerMock
46  ->expects($this->any())
47  ->method('getActivePackages')
48  ->will($this->returnValue([
49  'lang' => $this->getMockBuilder(Package::class)->disableOriginalConstructor()->getMock(),
50  'news' => $this->getMockBuilder(Package::class)->disableOriginalConstructor()->getMock(),
51  'saltedpasswords' => $this->getMockBuilder(Package::class)->disableOriginalConstructor()->getMock(),
52  'rsaauth' => $this->getMockBuilder(Package::class)->disableOriginalConstructor()->getMock(),
53  ]));
54  $this->inject($this->subject, 'packageManager', $packageManagerMock);
55  }
56 
61  {
62  return [
63  'same extension lists' => [
64  [
65  'lang' => [],
66  'news' => [],
67  'saltedpasswords' => [],
68  'rsaauth' => []
69  ],
70  [
71  'lang' => ['installed' => true],
72  'news' => ['installed' => true],
73  'saltedpasswords' => ['installed' => true],
74  'rsaauth' => ['installed' => true]
75  ]
76  ],
77  'different extension lists' => [
78  [
79  'lang' => [],
80  'news' => [],
81  'saltedpasswords' => [],
82  'rsaauth' => []
83  ],
84  [
85  'lang' => ['installed' => true],
86  'news' => ['installed' => true],
87  'saltedpasswords' => ['installed' => true],
88  'rsaauth' => ['installed' => true]
89  ]
90  ],
91  'different extension lists - set2' => [
92  [
93  'lang' => [],
94  'news' => [],
95  'saltedpasswords' => [],
96  'rsaauth' => [],
97  'em' => []
98  ],
99  [
100  'lang' => ['installed' => true],
101  'news' => ['installed' => true],
102  'saltedpasswords' => ['installed' => true],
103  'rsaauth' => ['installed' => true],
104  'em' => []
105  ]
106  ],
107  'different extension lists - set3' => [
108  [
109  'lang' => [],
110  'fluid' => [],
111  'news' => [],
112  'saltedpasswords' => [],
113  'rsaauth' => [],
114  'em' => []
115  ],
116  [
117  'lang' => ['installed' => true],
118  'fluid' => [],
119  'news' => ['installed' => true],
120  'saltedpasswords' => ['installed' => true],
121  'rsaauth' => ['installed' => true],
122  'em' => []
123  ]
124  ]
125  ];
126  }
127 
134  public function ‪getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult)
135  {
136  $this->assertEquals($expectedResult, $this->subject->getAvailableAndInstalledExtensions($availableExtensions));
137  }
138 
143  {
144  return [
145  'simple key value array emconf' => [
146  [
147  'lang' => ['property1' => 'oldvalue'],
148  'news' => [],
149  'saltedpasswords' => [],
150  'rsaauth' => []
151  ],
152  [
153  'property1' => 'property value1'
154  ],
155  [
156  'lang' => ['property1' => 'oldvalue'],
157  'news' => ['property1' => 'property value1'],
158  'saltedpasswords' => ['property1' => 'property value1'],
159  'rsaauth' => ['property1' => 'property value1']
160  ]
161  ]
162  ];
163  }
164 
172  public function ‪enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult)
173  {
174  $this->inject($this->subject, 'extensionRepository', $this->getAccessibleMock(ExtensionRepository::class, ['findOneByExtensionKeyAndVersion', 'findHighestAvailableVersion'], [], '', false));
175  $emConfUtilityMock = $this->getMockBuilder(EmConfUtility::class)->getMock();
176  $emConfUtilityMock->expects($this->any())->method('includeEmConf')->will($this->returnValue($emConf));
177  $this->inject($this->subject, 'emConfUtility', $emConfUtilityMock);
178  $this->assertEquals($expectedResult, $this->subject->enrichExtensionsWithEmConfAndTerInformation($extensions));
179  }
180 }
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\ListUtilityTest\enrichExtensionsWithEmConfInformation
‪enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult)
Definition: ListUtilityTest.php:171
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\ListUtilityTest\setUp
‪setUp()
Definition: ListUtilityTest.php:36
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility
Definition: DependencyUtilityTest.php:2
‪TYPO3\CMS\Extensionmanager\Utility\ListUtility
Definition: ListUtility.php:35
‪TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository
Definition: ExtensionRepository.php:27
‪TYPO3\CMS\Core\Package\Package
Definition: Package.php:21
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\ListUtilityTest
Definition: ListUtilityTest.php:29
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\ListUtilityTest\getAvailableAndInstalledExtensionsDataProvider
‪array getAvailableAndInstalledExtensionsDataProvider()
Definition: ListUtilityTest.php:59
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\ListUtilityTest\enrichExtensionsWithEmConfInformationDataProvider
‪array enrichExtensionsWithEmConfInformationDataProvider()
Definition: ListUtilityTest.php:141
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\ListUtilityTest\$subject
‪ListUtility $subject
Definition: ListUtilityTest.php:32
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\ListUtilityTest\getAvailableAndInstalledExtensionsTest
‪getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult)
Definition: ListUtilityTest.php:133