‪TYPO3CMS  10.4
ListUtilityTest.php
Go to the documentation of this file.
1 <?php
2 
3 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 
20 use Psr\EventDispatcher\EventDispatcherInterface;
22 use TYPO3\CMS\Core\Package\PackageManager;
24 use TYPO3\CMS\Extensionmanager\Utility\EmConfUtility;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪ListUtilityTest extends UnitTestCase
32 {
36  protected ‪$subject;
37 
38  protected function ‪setUp(): void
39  {
40  parent::setUp();
41  $this->subject = new ‪ListUtility();
42  $this->subject->injectEventDispatcher($this->prophesize(EventDispatcherInterface::class)->reveal());
43  $packageManagerMock = $this->getMockBuilder(PackageManager::class)
44  ->disableOriginalConstructor()
45  ->getMock();
46  $packageManagerMock
47  ->expects(self::any())
48  ->method('getActivePackages')
49  ->willReturn([
50  'lang' => $this->getMockBuilder(Package::class)->disableOriginalConstructor()->getMock(),
51  'news' => $this->getMockBuilder(Package::class)->disableOriginalConstructor()->getMock(),
52  'saltedpasswords' => $this->getMockBuilder(Package::class)->disableOriginalConstructor()->getMock(),
53  ]);
54  $this->subject->injectPackageManager($packageManagerMock);
55  }
56 
61  {
62  return [
63  'same extension lists' => [
64  [
65  'lang' => [],
66  'news' => [],
67  'saltedpasswords' => [],
68  ],
69  [
70  'lang' => ['installed' => true],
71  'news' => ['installed' => true],
72  'saltedpasswords' => ['installed' => true],
73  ]
74  ],
75  'different extension lists' => [
76  [
77  'lang' => [],
78  'news' => [],
79  'saltedpasswords' => [],
80  ],
81  [
82  'lang' => ['installed' => true],
83  'news' => ['installed' => true],
84  'saltedpasswords' => ['installed' => true],
85  ]
86  ],
87  'different extension lists - set2' => [
88  [
89  'lang' => [],
90  'news' => [],
91  'saltedpasswords' => [],
92  'em' => []
93  ],
94  [
95  'lang' => ['installed' => true],
96  'news' => ['installed' => true],
97  'saltedpasswords' => ['installed' => true],
98  'em' => []
99  ]
100  ],
101  'different extension lists - set3' => [
102  [
103  'lang' => [],
104  'fluid' => [],
105  'news' => [],
106  'saltedpasswords' => [],
107  'em' => []
108  ],
109  [
110  'lang' => ['installed' => true],
111  'fluid' => [],
112  'news' => ['installed' => true],
113  'saltedpasswords' => ['installed' => true],
114  'em' => []
115  ]
116  ]
117  ];
118  }
119 
126  public function ‪getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult)
127  {
128  self::assertEquals($expectedResult, $this->subject->getAvailableAndInstalledExtensions($availableExtensions));
129  }
130 
135  {
136  return [
137  'simple key value array emconf' => [
138  [
139  'lang' => ['property1' => 'oldvalue'],
140  'news' => [],
141  'saltedpasswords' => [],
142  ],
143  [
144  'property1' => 'property value1'
145  ],
146  [
147  'lang' => ['property1' => 'oldvalue'],
148  'news' => ['property1' => 'property value1'],
149  'saltedpasswords' => ['property1' => 'property value1'],
150  ]
151  ]
152  ];
153  }
154 
162  public function ‪enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult)
163  {
164  $this->subject->injectExtensionRepository($this->getAccessibleMock(ExtensionRepository::class, ['findOneByExtensionKeyAndVersion', 'findHighestAvailableVersion'], [], '', false));
165  $emConfUtilityMock = $this->getMockBuilder(EmConfUtility::class)->getMock();
166  $emConfUtilityMock->expects(self::any())->method('includeEmConf')->willReturn($emConf);
167  $this->subject->injectEmConfUtility($emConfUtilityMock);
168  self::assertEquals($expectedResult, $this->subject->enrichExtensionsWithEmConfAndTerInformation($extensions));
169  }
170 }
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\ListUtilityTest\enrichExtensionsWithEmConfInformation
‪enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult)
Definition: ListUtilityTest.php:161
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\ListUtilityTest\setUp
‪setUp()
Definition: ListUtilityTest.php:37
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility
Definition: DependencyUtilityTest.php:16
‪TYPO3\CMS\Extensionmanager\Utility\ListUtility
Definition: ListUtility.php:41
‪TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository
Definition: ExtensionRepository.php:35
‪TYPO3\CMS\Core\Package\Package
Definition: Package.php:26
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\ListUtilityTest
Definition: ListUtilityTest.php:32
‪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:133
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\ListUtilityTest\$subject
‪ListUtility $subject
Definition: ListUtilityTest.php:35
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\ListUtilityTest\getAvailableAndInstalledExtensionsTest
‪getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult)
Definition: ListUtilityTest.php:125