TYPO3 CMS  TYPO3_8-7
DependencyUtilityTest.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 
23 
27 class DependencyUtilityTest extends UnitTestCase
28 {
32  protected $objectManagerMock;
33 
37  protected function setUp()
38  {
39  $this->objectManagerMock = $this->getMockBuilder(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class)->getMock();
40  }
41 
45  public function checkTypo3DependencyThrowsExceptionIfVersionNumberIsTooLow()
46  {
48  $dependencyMock = $this->getMockBuilder(Dependency::class)
49  ->setMethods(['getHighestVersion', 'getLowestVersion'])
50  ->getMock();
51  $dependencyMock->expects($this->atLeastOnce())->method('getLowestVersion')->will($this->returnValue('15.0.0'));
52  $dependencyMock->setIdentifier('typo3');
53  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
54 
55  $this->expectException(ExtensionManagerException::class);
56  $this->expectExceptionCode(1399144499);
57  $dependencyUtility->_call('checkTypo3Dependency', $dependencyMock);
58  }
59 
63  public function checkTypo3DependencyThrowsExceptionIfVersionNumberIsTooHigh()
64  {
66  $dependencyMock = $this->getMockBuilder(Dependency::class)
67  ->setMethods(['getHighestVersion', 'getLowestVersion'])
68  ->getMock();
69  $dependencyMock->expects($this->atLeastOnce())->method('getHighestVersion')->will($this->returnValue('3.0.0'));
70  $dependencyMock->expects($this->atLeastOnce())->method('getLowestVersion')->will($this->returnValue('1.0.0'));
71  $dependencyMock->setIdentifier('typo3');
72  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
73 
74  $this->expectException(ExtensionManagerException::class);
75  $this->expectExceptionCode(1399144521);
76  $dependencyUtility->_call('checkTypo3Dependency', $dependencyMock);
77  }
78 
82  public function checkTypo3DependencyThrowsExceptionIfIdentifierIsNotTypo3()
83  {
85  $dependencyMock = $this->getMockBuilder(Dependency::class)
86  ->setMethods(['getHighestVersion', 'getLowestVersion'])
87  ->getMock();
88  $dependencyMock->setIdentifier('123');
89  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
90 
91  $this->expectException(ExtensionManagerException::class);
92  $this->expectExceptionCode(1399144551);
93  $dependencyUtility->_call('checkTypo3Dependency', $dependencyMock);
94  }
95 
99  public function checkTypo3DependencyReturnsTrueIfVersionNumberIsInRange()
100  {
102  $dependencyMock = $this->getMockBuilder(Dependency::class)
103  ->setMethods(['getHighestVersion', 'getLowestVersion'])
104  ->getMock();
105  $dependencyMock->expects($this->atLeastOnce())->method('getHighestVersion')->will($this->returnValue('15.0.0'));
106  $dependencyMock->expects($this->atLeastOnce())->method('getLowestVersion')->will($this->returnValue('1.0.0'));
107  $dependencyMock->setIdentifier('typo3');
108  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
109 
110  $this->assertTrue($dependencyUtility->_call('checkTypo3Dependency', $dependencyMock));
111  }
112 
116  public function checkTypo3DependencyCanHandleEmptyVersionHighestVersion()
117  {
119  $dependencyMock = $this->getMockBuilder(Dependency::class)
120  ->setMethods(['getHighestVersion', 'getLowestVersion'])
121  ->getMock();
122  $dependencyMock->expects($this->atLeastOnce())->method('getHighestVersion')->will($this->returnValue(''));
123  $dependencyMock->expects($this->atLeastOnce())->method('getLowestVersion')->will($this->returnValue('1.0.0'));
124  $dependencyMock->setIdentifier('typo3');
125  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
126 
127  $this->assertTrue($dependencyUtility->_call('checkTypo3Dependency', $dependencyMock));
128  }
129 
133  public function checkTypo3DependencyCanHandleEmptyVersionLowestVersion()
134  {
136  $dependencyMock = $this->getMockBuilder(Dependency::class)
137  ->setMethods(['getHighestVersion', 'getLowestVersion'])
138  ->getMock();
139  $dependencyMock->expects($this->atLeastOnce())->method('getHighestVersion')->will($this->returnValue('15.0.0'));
140  $dependencyMock->expects($this->atLeastOnce())->method('getLowestVersion')->will($this->returnValue(''));
141  $dependencyMock->setIdentifier('typo3');
142  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
143 
144  $this->assertTrue($dependencyUtility->_call('checkTypo3Dependency', $dependencyMock));
145  }
146 
150  public function checkPhpDependencyThrowsExceptionIfVersionNumberIsTooLow()
151  {
153  $dependencyMock = $this->getMockBuilder(Dependency::class)
154  ->setMethods(['getHighestVersion', 'getLowestVersion'])
155  ->getMock();
156  $dependencyMock->expects($this->atLeastOnce())->method('getLowestVersion')->will($this->returnValue('15.0.0'));
157  $dependencyMock->setIdentifier('php');
158  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
159 
160  $this->expectException(ExtensionManagerException::class);
161  $this->expectExceptionCode(1377977857);
162  $dependencyUtility->_call('checkPhpDependency', $dependencyMock);
163  }
164 
168  public function checkPhpDependencyThrowsExceptionIfVersionNumberIsTooHigh()
169  {
171  $dependencyMock = $this->getMockBuilder(Dependency::class)
172  ->setMethods(['getHighestVersion', 'getLowestVersion'])
173  ->getMock();
174  $dependencyMock->expects($this->atLeastOnce())->method('getHighestVersion')->will($this->returnValue('3.0.0'));
175  $dependencyMock->expects($this->atLeastOnce())->method('getLowestVersion')->will($this->returnValue('1.0.0'));
176  $dependencyMock->setIdentifier('php');
177  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
178 
179  $this->expectException(ExtensionManagerException::class);
180  $this->expectExceptionCode(1377977856);
181  $dependencyUtility->_call('checkPhpDependency', $dependencyMock);
182  }
183 
187  public function checkPhpDependencyThrowsExceptionIfIdentifierIsNotTypo3()
188  {
190  $dependencyMock = $this->getMockBuilder(Dependency::class)
191  ->setMethods(['getHighestVersion', 'getLowestVersion'])
192  ->getMock();
193  $dependencyMock->setIdentifier('123');
194  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
195 
196  $this->expectException(ExtensionManagerException::class);
197  $this->expectExceptionCode(1377977858);
198  $dependencyUtility->_call('checkPhpDependency', $dependencyMock);
199  }
200 
204  public function checkPhpDependencyReturnsTrueIfVersionNumberIsInRange()
205  {
207  $dependencyMock = $this->getMockBuilder(Dependency::class)
208  ->setMethods(['getHighestVersion', 'getLowestVersion'])
209  ->getMock();
210  $dependencyMock->expects($this->atLeastOnce())->method('getHighestVersion')->will($this->returnValue('15.0.0'));
211  $dependencyMock->expects($this->atLeastOnce())->method('getLowestVersion')->will($this->returnValue('1.0.0'));
212  $dependencyMock->setIdentifier('php');
213  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
214 
215  $this->assertTrue($dependencyUtility->_call('checkPhpDependency', $dependencyMock));
216  }
217 
221  public function checkPhpDependencyCanHandleEmptyVersionHighestVersion()
222  {
224  $dependencyMock = $this->getMockBuilder(Dependency::class)
225  ->setMethods(['getHighestVersion', 'getLowestVersion'])
226  ->getMock();
227  $dependencyMock->expects($this->atLeastOnce())->method('getHighestVersion')->will($this->returnValue(''));
228  $dependencyMock->expects($this->atLeastOnce())->method('getLowestVersion')->will($this->returnValue('1.0.0'));
229  $dependencyMock->setIdentifier('php');
230  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
231 
232  $this->assertTrue($dependencyUtility->_call('checkPhpDependency', $dependencyMock));
233  }
234 
238  public function checkPhpDependencyCanHandleEmptyVersionLowestVersion()
239  {
241  $dependencyMock = $this->getMockBuilder(Dependency::class)
242  ->setMethods(['getHighestVersion', 'getLowestVersion'])
243  ->getMock();
244  $dependencyMock->expects($this->atLeastOnce())->method('getHighestVersion')->will($this->returnValue('15.0.0'));
245  $dependencyMock->expects($this->atLeastOnce())->method('getLowestVersion')->will($this->returnValue(''));
246  $dependencyMock->setIdentifier('php');
247  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
248 
249  $this->assertTrue($dependencyUtility->_call('checkPhpDependency', $dependencyMock));
250  }
251 
255  public function checkDependenciesCallsMethodToCheckPhpDependencies()
256  {
258  $extensionMock = $this->getMockBuilder(Extension::class)
259  ->setMethods(['dummy'])
260  ->getMock();
262  $dependencyMock = $this->getMockBuilder(Dependency::class)
263  ->setMethods(['getHighestVersion', 'getLowestVersion'])
264  ->getMock();
265  $dependencyMock->setIdentifier('php');
266  $dependencyStorage = new \SplObjectStorage();
267  $dependencyStorage->attach($dependencyMock);
268  $extensionMock->setDependencies($dependencyStorage);
270  $dependencyUtility = $this->getMockBuilder(DependencyUtility::class)
271  ->setMethods(['checkPhpDependency', 'checkTypo3Dependency'])
272  ->getMock();
273  $dependencyUtility->expects($this->atLeastOnce())->method('checkPhpDependency');
274  $dependencyUtility->checkDependencies($extensionMock);
275  }
276 
280  public function checkDependenciesCallsMethodToCheckTypo3Dependencies()
281  {
283  $extensionMock = $this->getMockBuilder(Extension::class)
284  ->setMethods(['dummy'])
285  ->getMock();
287  $dependencyMock = $this->getMockBuilder(Dependency::class)
288  ->setMethods(['getHighestVersion', 'getLowestVersion'])
289  ->getMock();
290  $dependencyMock->setIdentifier('typo3');
291  $dependencyStorage = new \SplObjectStorage();
292  $dependencyStorage->attach($dependencyMock);
293  $extensionMock->setDependencies($dependencyStorage);
295  $dependencyUtility = $this->getMockBuilder(DependencyUtility::class)
296  ->setMethods(['checkPhpDependency', 'checkTypo3Dependency'])
297  ->getMock();
298 
299  $dependencyUtility->expects($this->atLeastOnce())->method('checkTypo3Dependency');
300  $dependencyUtility->checkDependencies($extensionMock);
301  }
302 
306  public function isVersionCompatibleReturnsTrueForCompatibleVersion()
307  {
309  $dependencyMock = $this->getMockBuilder(Dependency::class)
310  ->setMethods(['getHighestVersion', 'getLowestVersion'])
311  ->getMock();
312  $dependencyMock->expects($this->atLeastOnce())->method('getHighestVersion')->will($this->returnValue('15.0.0'));
313  $dependencyMock->expects($this->atLeastOnce())->method('getLowestVersion')->will($this->returnValue('1.0.0'));
314  $version = '3.3.3';
315  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
316 
317  $this->assertTrue($dependencyUtility->_call('isVersionCompatible', $version, $dependencyMock));
318  }
319 
323  public function isVersionCompatibleReturnsFalseForIncompatibleVersion()
324  {
326  $dependencyMock = $this->getMockBuilder(Dependency::class)
327  ->setMethods(['getHighestVersion', 'getLowestVersion'])
328  ->getMock();
329  $dependencyMock->expects($this->atLeastOnce())->method('getHighestVersion')->will($this->returnValue('1.0.1'));
330  $dependencyMock->expects($this->atLeastOnce())->method('getLowestVersion')->will($this->returnValue('1.0.0'));
331  $version = '3.3.3';
332  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
333 
334  $this->assertFalse($dependencyUtility->_call('isVersionCompatible', $version, $dependencyMock));
335  }
336 
341  {
342  $availableExtensions = [
343  'dummy' => [],
344  'foo' => [],
345  'bar' => []
346  ];
347  $listUtilityMock = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Utility\ListUtility::class)
348  ->setMethods(['getAvailableExtensions'])
349  ->getMock();
350  $listUtilityMock->expects($this->atLeastOnce())->method('getAvailableExtensions')->will($this->returnValue($availableExtensions));
351  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
352  $dependencyUtility->_set('listUtility', $listUtilityMock);
353 
354  $this->assertTrue($dependencyUtility->_call('isDependentExtensionAvailable', 'dummy'));
355  }
356 
361  {
362  $availableExtensions = [
363  'dummy' => [],
364  'foo' => [],
365  'bar' => []
366  ];
367  $listUtilityMock = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Utility\ListUtility::class)
368  ->setMethods(['getAvailableExtensions'])
369  ->getMock();
370  $listUtilityMock->expects($this->atLeastOnce())->method('getAvailableExtensions')->will($this->returnValue($availableExtensions));
371  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
372  $dependencyUtility->_set('listUtility', $listUtilityMock);
373 
374  $this->assertFalse($dependencyUtility->_call('isDependentExtensionAvailable', '42'));
375  }
376 
381  {
382  $emConfUtility = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Utility\EmConfUtility::class)
383  ->setMethods(['includeEmConf'])
384  ->getMock();
385  $emConfUtility->expects($this->once())->method('includeEmConf')->will($this->returnValue([
386  'key' => 'dummy',
387  'version' => '1.0.0'
388  ]));
389  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['setAvailableExtensions', 'isVersionCompatible']);
390  $dependencyMock = $this->getMockBuilder(Dependency::class)
391  ->setMethods(['getIdentifier'])
392  ->getMock();
393  $dependencyMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('dummy'));
394  $dependencyUtility->_set('emConfUtility', $emConfUtility);
395  $dependencyUtility->_set('availableExtensions', [
396  'dummy' => [
397  'foo' => '42'
398  ]
399  ]);
400  $dependencyUtility->expects($this->once())->method('setAvailableExtensions');
401  $dependencyUtility->expects($this->once())->method('isVersionCompatible')->with('1.0.0', $this->anything());
402  $dependencyUtility->_call('isAvailableVersionCompatible', $dependencyMock);
403  }
404 
409  {
410  $extensionRepositoryMock = $this->getMockBuilder(ExtensionRepository::class)
411  ->setMethods(['countByExtensionKey'])
412  ->setConstructorArgs([$this->objectManagerMock])
413  ->getMock();
414  $extensionRepositoryMock->expects($this->once())->method('countByExtensionKey')->with('test123')->will($this->returnValue(1));
415  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
416  $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
417  $count = $dependencyUtility->_call('isExtensionDownloadableFromTer', 'test123');
418 
419  $this->assertTrue($count);
420  }
421 
426  {
427  $extensionRepositoryMock = $this->getMockBuilder(ExtensionRepository::class)
428  ->setMethods(['countByExtensionKey'])
429  ->setConstructorArgs([$this->objectManagerMock])
430  ->getMock();
431  $extensionRepositoryMock->expects($this->once())->method('countByExtensionKey')->with('test123')->will($this->returnValue(0));
432  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
433  $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
434  $count = $dependencyUtility->_call('isExtensionDownloadableFromTer', 'test123');
435 
436  $this->assertFalse($count);
437  }
438 
443  {
444  $dependencyMock = $this->getMockBuilder(Dependency::class)
445  ->setMethods(['getIdentifier', 'getHighestVersion', 'getLowestVersion'])
446  ->getMock();
447  $dependencyMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('dummy'));
448  $dependencyMock->expects($this->once())->method('getHighestVersion')->will($this->returnValue('10.0.0'));
449  $dependencyMock->expects($this->once())->method('getLowestVersion')->will($this->returnValue('1.0.0'));
450  $extensionRepositoryMock = $this->getMockBuilder(ExtensionRepository::class)
451  ->setMethods(['countByVersionRangeAndExtensionKey'])
452  ->setConstructorArgs([$this->objectManagerMock])
453  ->getMock();
454  $extensionRepositoryMock->expects($this->once())->method('countByVersionRangeAndExtensionKey')->with('dummy', 1000000, 10000000)->will($this->returnValue(2));
455  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
456  $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
457  $count = $dependencyUtility->_call('isDownloadableVersionCompatible', $dependencyMock);
458 
459  $this->assertTrue($count);
460  }
461 
466  {
467  $dependencyMock = $this->getMockBuilder(Dependency::class)
468  ->setMethods(['getIdentifier'])
469  ->getMock();
470  $dependencyMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('dummy'));
471  $extensionRepositoryMock = $this->getMockBuilder(ExtensionRepository::class)
472  ->setMethods(['countByVersionRangeAndExtensionKey'])
473  ->setConstructorArgs([$this->objectManagerMock])
474  ->getMock();
475  $extensionRepositoryMock->expects($this->once())->method('countByVersionRangeAndExtensionKey')->with('dummy', 1000000, 2000000)->will($this->returnValue(0));
476  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['getLowestAndHighestIntegerVersions']);
477  $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
478  $dependencyUtility->expects($this->once())->method('getLowestAndHighestIntegerVersions')->will($this->returnValue([
479  'lowestIntegerVersion' => 1000000,
480  'highestIntegerVersion' => 2000000
481  ]));
482  $count = $dependencyUtility->_call('isDownloadableVersionCompatible', $dependencyMock);
483 
484  $this->assertFalse($count);
485  }
486 
491  {
492  $expectedVersions = [
493  'lowestIntegerVersion' => 1000000,
494  'highestIntegerVersion' => 2000000
495  ];
496 
497  $dependencyMock = $this->getMockBuilder(Dependency::class)
498  ->setMethods(['getHighestVersion', 'getLowestVersion'])
499  ->getMock();
500  $dependencyMock->expects($this->once())->method('getHighestVersion')->will($this->returnValue('2.0.0'));
501  $dependencyMock->expects($this->once())->method('getLowestVersion')->will($this->returnValue('1.0.0'));
502  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
503  $versions = $dependencyUtility->_call('getLowestAndHighestIntegerVersions', $dependencyMock);
504 
505  $this->assertSame($expectedVersions, $versions);
506  }
507 
512  {
513  $extension1 = new Extension();
514  $extension1->setExtensionKey('foo');
515  $extension1->setVersion('1.0.0');
516  $extension2 = new Extension();
517  $extension2->setExtensionKey('bar');
518  $extension2->setVersion('1.0.42');
519 
520  $myStorage = new \TYPO3\CMS\Extensionmanager\Tests\Unit\Fixtures\LatestCompatibleExtensionObjectStorageFixture();
521  $myStorage->extensions[] = $extension1;
522  $myStorage->extensions[] = $extension2;
523  $dependencyMock = $this->getMockBuilder(Dependency::class)
524  ->setMethods(['getIdentifier'])
525  ->getMock();
526  $dependencyMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('foobar'));
527  $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['getLowestAndHighestIntegerVersions']);
528  $dependencyUtility->expects($this->once())->method('getLowestAndHighestIntegerVersions')->will($this->returnValue([
529  'lowestIntegerVersion' => 1000000,
530  'highestIntegerVersion' => 2000000
531  ]));
532  $extensionRepositoryMock = $this->getMockBuilder(ExtensionRepository::class)
533  ->setMethods(['findByVersionRangeAndExtensionKeyOrderedByVersion'])
534  ->setConstructorArgs([$this->objectManagerMock])
535  ->getMock();
536  $extensionRepositoryMock->expects($this->once())->method('findByVersionRangeAndExtensionKeyOrderedByVersion')->with('foobar', 1000000, 2000000)->will($this->returnValue($myStorage));
537  $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
538  $extension = $dependencyUtility->_call('getLatestCompatibleExtensionByIntegerVersionDependency', $dependencyMock);
539 
540  $this->assertInstanceOf(Extension::class, $extension);
541  $this->assertSame('foo', $extension->getExtensionKey());
542  }
543 
548  {
549  // foo2 should be kept
550  $foo1 = new Extension();
551  $foo1->setExtensionKey('foo');
552  $foo1->setVersion('1.0.0');
553  $foo2 = new Extension();
554  $foo2->setExtensionKey('foo');
555  $foo2->setVersion('1.0.1');
556 
557  // bar1 should be kept
558  $bar1 = new Extension();
559  $bar1->setExtensionKey('bar');
560  $bar1->setVersion('1.1.2');
561  $bar2 = new Extension();
562  $bar2->setExtensionKey('bar');
563  $bar2->setVersion('1.1.1');
564  $bar3 = new Extension();
565  $bar3->setExtensionKey('bar');
566  $bar3->setVersion('1.0.3');
567 
568  $input = [$foo1, $foo2, $bar1, $bar2, $bar3];
569  $this->assertEquals(['foo' => $foo2, 'bar' => $bar1], (new DependencyUtility())->filterYoungestVersionOfExtensionList($input, true));
570  }
571 
576  {
577  $suitableDependency = new Dependency();
578  $suitableDependency->setIdentifier('typo3');
579  $suitableDependency->setLowestVersion('3.6.1');
580 
581  $suitableDependencies = new \SplObjectStorage();
582  $suitableDependencies->attach($suitableDependency);
583 
584  $unsuitableDependency = new Dependency();
585  $unsuitableDependency->setIdentifier('typo3');
586  $unsuitableDependency->setHighestVersion('4.3.0');
587 
588  $unsuitableDependencies = new \SplObjectStorage();
589  $unsuitableDependencies->attach($unsuitableDependency);
590 
591  // foo1 should be kept
592  $foo1 = new Extension();
593  $foo1->setExtensionKey('foo');
594  $foo1->setVersion('1.0.0');
595  $foo1->setDependencies($suitableDependencies);
596 
597  $foo2 = new Extension();
598  $foo2->setExtensionKey('foo');
599  $foo2->setVersion('1.0.1');
600  $foo2->setDependencies($unsuitableDependencies);
601 
602  // bar2 should be kept
603  $bar1 = new Extension();
604  $bar1->setExtensionKey('bar');
605  $bar1->setVersion('1.1.2');
606  $bar1->setDependencies($unsuitableDependencies);
607 
608  $bar2 = new Extension();
609  $bar2->setExtensionKey('bar');
610  $bar2->setVersion('1.1.1');
611  $bar2->setDependencies($suitableDependencies);
612 
613  $input = [$foo1, $foo2, $bar1, $bar2];
614  $this->assertEquals(['foo' => $foo1, 'bar' => $bar2], (new DependencyUtility())->filterYoungestVersionOfExtensionList($input, false));
615  }
616 }