Skip to content

Commit

Permalink
[TASK] Ensure package dependencies in functional/acceptance tests
Browse files Browse the repository at this point in the history
This change uses the dependency ordering service in the method
`\TYPO3\TestingFramework\Core\Testbase::setUpPackageStates` for
test scenarios in functional and acceptance tests.

Besides that the following changes were applied:
* remove invalid dependency in fixture ext:test_configoverride_second
* add `PackageStatesTest` to keep track of extension dependencies
* add dependency to ext:frontend in ext:form, since it overrides
  TCA for the tables tt_content and sys_template (which would result
  in different ext:impexp results due to table field orderings)
* recreate IRRE related XML fixtures for ext:impexp since fixture
  extensions are now ordered alphabetically (and due to #100734)

Resolves: #101809
Releases: main, 12.4
Change-Id: I1f91a75ac8aec9db0291b0f5c8bcf7162d5b0082
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81093
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
ohader authored and sbuerk committed Sep 20, 2023
1 parent 4ca9a26 commit a89023e
Show file tree
Hide file tree
Showing 8 changed files with 1,094 additions and 937 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -118,7 +118,7 @@
"sokil/php-isocodes-db-i18n": "^4.0.13",
"symfony/translation": "^6.2",
"typo3/cms-styleguide": "^12.0.2",
"typo3/testing-framework": "^8.0.5",
"typo3/testing-framework": "^8.0.6",
"webmozart/assert": "^1.11.0"
},
"suggest": {
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -14,9 +14,10 @@
'constraints' => [
'depends' => [
'typo3' => '12.4.7',
'a' => '12.4.7',
],
'conflicts' => [],
'suggests' => [],
'suggests' => [
'test_configoverride_first' => '12.4.7',
],
],
];
154 changes: 154 additions & 0 deletions typo3/sysext/core/Tests/Functional/Package/PackageStatesTest.php
@@ -0,0 +1,154 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

namespace TYPO3\CMS\Core\Tests\Functional\Package;

use TYPO3\CMS\Core\Cache\Backend\NullBackend;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

/**
* Tests the package states and order of packages in functional tests.
* Thus, this is a test case for functional tests.
*/
final class PackageStatesTest extends FunctionalTestCase
{
// @todo how to automatically fetch all available TYPO3 system extensions?
private const CORE_EXTENSION_TO_LOAD = [
'adminpanel',
'backend',
'belog',
'beuser',
'dashboard',
'extbase',
'extensionmanager',
'felogin',
'filelist',
'filemetadata',
'fluid',
'fluid_styled_content',
'form',
'frontend',
'impexp',
'indexed_search',
'info',
'install',
'linkvalidator',
'lowlevel',
'opendocs',
'reactions',
'recycler',
'redirects',
'reports',
'rte_ckeditor',
'scheduler',
'seo',
'setup',
'sys_note',
't3editor',
'tstemplate',
'viewpage',
'webhooks',
'workspaces',
];

protected array $configurationToUseInTestInstance = [
'SYS' => [
'caching' => [
'cacheConfigurations' => [
// disables caching of package states
'core' => [
'backend' => NullBackend::class,
],
],
],
],
];

protected function setUp(): void
{
$this->coreExtensionsToLoad = self::CORE_EXTENSION_TO_LOAD;
shuffle($this->coreExtensionsToLoad);
parent::setUp();
}

/**
* This test cannot test the complete scenario, since the dependency
* ordering service can only adjust order base on available information.
*
* The "sorting constraints" are a combination of static prioritized packages, the
* corresponding dependencies from `ext_emconf.php` and finally as a fall-back,
* an alphabetic order - which just ensures that the sequence stays the same.
*
* @test
*/
public function activePackagesAreOrderedByPrioritizedPackageKeysOrPackageDependenciesOrAlphabetically(): void
{
$packageManager = $this->get(PackageManager::class);
$activePackages = $packageManager->getActivePackages();
// @todo this list is still incorrect and requires consolidated `ext_emconf.php` constraints
$expectedKeys = [
'core',
'scheduler',
'extbase',
'fluid',
'frontend',
'fluid_styled_content',
'filelist',
'impexp',
'form',
'install',
'info',
'linkvalidator',
'reports',
'redirects',
'indexed_search',
'recycler',
'setup',
'rte_ckeditor',
'adminpanel',
'backend',
'belog',
'beuser',
'dashboard',
'extensionmanager',
'felogin',
'filemetadata',
'lowlevel',
'opendocs',
'reactions',
'seo',
'sys_note',
't3editor',
'tstemplate',
'viewpage',
'webhooks',
'workspaces',
];

self::assertSame(
$expectedKeys,
// use the order of `$activePackages`, but only pass those values of `$expectedKeys`
array_values(
array_intersect(
array_keys($activePackages),
$expectedKeys
)
),
);
}
}
3 changes: 2 additions & 1 deletion typo3/sysext/form/composer.json
Expand Up @@ -21,7 +21,8 @@
"require": {
"psr/http-message": "^1.1 || ^2.0",
"symfony/expression-language": "^6.2",
"typo3/cms-core": "12.4.*@dev"
"typo3/cms-core": "12.4.*@dev",
"typo3/cms-frontend": "12.4.*@dev"
},
"suggest": {
"typo3/cms-filelist": "Listing of files in the directory",
Expand Down
1 change: 1 addition & 0 deletions typo3/sysext/form/ext_emconf.php
Expand Up @@ -12,6 +12,7 @@
'constraints' => [
'depends' => [
'typo3' => '12.4.7',
'frontend' => '12.4.7',
],
'conflicts' => [],
'suggests' => [
Expand Down

0 comments on commit a89023e

Please sign in to comment.