forked from TYPO3/testing-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackageCollectionTest.php
More file actions
76 lines (67 loc) · 3.77 KB
/
PackageCollectionTest.php
File metadata and controls
76 lines (67 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
declare(strict_types=1);
/*
* Copyright (C) 2024 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
namespace Typo3\TestingFramework\Tests\Unit\Core;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\TestingFramework\Composer\ComposerPackageManager;
use TYPO3\TestingFramework\Core\PackageCollection;
final class PackageCollectionTest extends TestCase
{
#[Test]
public function sortsComposerPackages(): void
{
$packageStates = require __DIR__ . '/../Fixtures/Packages/PackageStates.php';
$expectedPackageStates = require __DIR__ . '/../Fixtures/Packages/PackageStates_sorted.php';
$packageStates = $packageStates['packages'];
$basePath = realpath(__DIR__ . '/../../../');
$composerPackageManager = new ComposerPackageManager();
// That way it knows about the extensions, this is done by TestBase upfront.
$composerPackageManager->getPackageInfoWithFallback(__DIR__ . '/../Fixtures/Packages/package0');
$composerPackageManager->getPackageInfoWithFallback(__DIR__ . '/../Fixtures/Packages/package1');
$composerPackageManager->getPackageInfoWithFallback(__DIR__ . '/../Fixtures/Packages/package2');
$composerPackageManager->getPackageInfoWithFallback(__DIR__ . '/../Fixtures/Packages/package-with-extemconf');
$composerPackageManager->getPackageInfoWithFallback(__DIR__ . '/../Fixtures/Packages/package-unsynced-extemconf');
$composerPackageManager->getPackageInfoWithFallback(__DIR__ . '/../Fixtures/Packages/package2-unsynced-extemconf');
$subject = PackageCollection::fromPackageStates(
$composerPackageManager,
new PackageManager(
new DependencyOrderingService(),
__DIR__ . '/../Fixtures/Packages/PackageStates.php',
$basePath
),
$basePath,
$packageStates
);
$result = $subject->sortPackageStates(
$packageStates,
new DependencyOrderingService()
);
self::assertSame(5, array_search('package0', array_keys($result)), 'Package 0 is not stored at loading order 5.');
self::assertSame(6, array_search('package1', array_keys($result)), 'Package 1 is not stored at loading order 6.');
self::assertSame(7, array_search('extension_unsynced_extemconf', array_keys($result)), 'extension_unsynced_extemconf is not stored at loading order 7.');
self::assertSame(8, array_search('extension_with_extemconf', array_keys($result)), 'extension_with_extemconf is not stored at loading order 8.');
self::assertSame(9, array_search('extension2_unsynced_extemconf', array_keys($result)), 'extension2_unsynced_extemconf is not stored at loading order 9.');
self::assertSame(10, array_search('package2', array_keys($result)), 'Package 2 is not stored at loading order 10.');
self::assertSame($expectedPackageStates['packages'], $result, 'Sorted packages does not match expected order');
}
}