TYPO3 CMS  TYPO3_7-6
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 
22 {
26  protected $subject;
27 
31  protected function setUp()
32  {
33  $this->subject = $this->getMock(\TYPO3\CMS\Extensionmanager\Utility\ListUtility::class, ['emitPackagesMayHaveChangedSignal']);
34  $packageManagerMock = $this->getMock(\TYPO3\CMS\Core\Package\PackageManager::class);
35  $packageManagerMock
36  ->expects($this->any())
37  ->method('getActivePackages')
38  ->will($this->returnValue([
39  'lang' => $this->getMock(\TYPO3\CMS\Core\Package::class, [], [], '', false),
40  'news' => $this->getMock(\TYPO3\CMS\Core\Package::class, [], [], '', false),
41  'saltedpasswords' => $this->getMock(\TYPO3\CMS\Core\Package::class, [], [], '', false),
42  'rsaauth' => $this->getMock(\TYPO3\CMS\Core\Package::class, [], [], '', false),
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 
125  public function getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult)
126  {
127  $this->assertEquals($expectedResult, $this->subject->getAvailableAndInstalledExtensions($availableExtensions));
128  }
129 
134  {
135  return [
136  'simple key value array emconf' => [
137  [
138  'lang' => ['property1' => 'oldvalue'],
139  'news' => [],
140  'saltedpasswords' => [],
141  'rsaauth' => []
142  ],
143  [
144  'property1' => 'property value1'
145  ],
146  [
147  'lang' => ['property1' => 'oldvalue'],
148  'news' => ['property1' => 'property value1'],
149  'saltedpasswords' => ['property1' => 'property value1'],
150  'rsaauth' => ['property1' => 'property value1']
151  ]
152  ]
153  ];
154  }
155 
164  public function enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult)
165  {
166  $this->inject($this->subject, 'extensionRepository', $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository::class, ['findOneByExtensionKeyAndVersion', 'findHighestAvailableVersion'], [], '', false));
167  $emConfUtilityMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Utility\EmConfUtility::class);
168  $emConfUtilityMock->expects($this->any())->method('includeEmConf')->will($this->returnValue($emConf));
169  $this->inject($this->subject, 'emConfUtility', $emConfUtilityMock);
170  $this->assertEquals($expectedResult, $this->subject->enrichExtensionsWithEmConfAndTerInformation($extensions));
171  }
172 }
inject($target, $name, $dependency)
enrichExtensionsWithEmConfInformation($extensions, $emConf, $expectedResult)
getAvailableAndInstalledExtensionsTest($availableExtensions, $expectedResult)
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)