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