-
Notifications
You must be signed in to change notification settings - Fork 51
[BUGFIX] Improve package name resolving #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sbuerk
merged 3 commits into
TYPO3:main
from
IchHabRecht:bugfix/improve-package-name-resolving
Jul 23, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
Tests/Unit/Core/Fixtures/Extensions/ext_folder_name/composer.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "name": "typo3/testing-framework-diverging-extension-key", | ||
| "description": "Test extension with a folder name differing from its extension key", | ||
| "type": "typo3-cms-extension", | ||
| "license": [ | ||
| "GPL-2.0-or-later" | ||
| ], | ||
| "require": { | ||
| "php": "*" | ||
| }, | ||
| "extra": { | ||
| "typo3/cms": { | ||
| "extension-key": "diverging_extension_key", | ||
| "version": "1.0.0", | ||
| "Package": { | ||
| "providesPackages": {} | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace TYPO3\TestingFramework\Tests\Unit\Core; | ||
|
|
||
| /* | ||
| * 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! | ||
| */ | ||
| use PHPUnit\Framework\Attributes\Test; | ||
| use PHPUnit\Framework\TestCase; | ||
| use TYPO3\TestingFramework\Core\Testbase; | ||
|
|
||
| final class TestbaseTest extends TestCase | ||
| { | ||
| private string $instancePath = ''; | ||
|
|
||
| protected function tearDown(): void | ||
| { | ||
| if ($this->instancePath !== '' && is_dir($this->instancePath)) { | ||
| $this->removeDirectory($this->instancePath); | ||
| } | ||
| $this->instancePath = ''; | ||
| parent::tearDown(); | ||
| } | ||
|
|
||
| /** | ||
| * Testbase::linkTestExtensionsToInstance() symlinks a test extension using the | ||
| * extension key determined by ComposerPackageManager::getPackageInfoWithFallback(). | ||
| * Testbase::setUpPackageStates() must determine the very same name, otherwise the | ||
| * written PackageStates.php points to a non-existing package path. | ||
| */ | ||
| #[Test] | ||
| public function setUpPackageStatesUsesExtensionKeyOfTestExtensionAndNotItsFolderName(): void | ||
| { | ||
| $extensionPath = __DIR__ . '/Fixtures/Extensions/ext_folder_name'; | ||
| // Folder name and extension key of the fixture extension differ on purpose. | ||
| self::assertSame('ext_folder_name', basename($extensionPath)); | ||
|
|
||
| $this->instancePath = $this->createTestInstance(); | ||
| // Symlink the extension the way linkTestExtensionsToInstance() does it. | ||
| symlink($extensionPath, $this->instancePath . '/typo3conf/ext/diverging_extension_key'); | ||
|
|
||
| $subject = new Testbase(); | ||
| $subject->setUpPackageStates($this->instancePath, [], [], [$extensionPath], []); | ||
|
|
||
| $packageStates = require $this->instancePath . '/typo3conf/PackageStates.php'; | ||
|
|
||
| self::assertArrayHasKey('diverging_extension_key', $packageStates['packages']); | ||
| self::assertArrayNotHasKey('ext_folder_name', $packageStates['packages']); | ||
| self::assertSame( | ||
| 'typo3conf/ext/diverging_extension_key/', | ||
| $packageStates['packages']['diverging_extension_key']['packagePath'] | ||
| ); | ||
| } | ||
|
|
||
| private function createTestInstance(): string | ||
| { | ||
| $instancePath = sys_get_temp_dir() . '/testbase-' . bin2hex(random_bytes(8)); | ||
| mkdir($instancePath . '/typo3conf/ext', 0775, true); | ||
| return $instancePath; | ||
| } | ||
|
|
||
| private function removeDirectory(string $path): void | ||
| { | ||
| foreach ((array)scandir($path) as $entry) { | ||
| if ($entry === '.' || $entry === '..') { | ||
| continue; | ||
| } | ||
| $entryPath = $path . '/' . $entry; | ||
| if (is_link($entryPath) || is_file($entryPath)) { | ||
| unlink($entryPath); | ||
| continue; | ||
| } | ||
| $this->removeDirectory($entryPath); | ||
| } | ||
| rmdir($path); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.