From 55f17b312fb802ea650b47b9ce3552a7c961e7ef Mon Sep 17 00:00:00 2001 From: Nicolas Joubert Date: Wed, 21 Oct 2026 09:26:32 +0200 Subject: [PATCH] #49 - Extension tests: check that every task is tested, with a unique prefixed code and its deprecated alias testEveryTaskIsTested, as in doctrine: every task service is in provideTasks(), codes unique and prefixed by archive_, every former id is a deprecated alias. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../CleverAgeArchiveProcessExtensionTest.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/DependencyInjection/CleverAgeArchiveProcessExtensionTest.php b/tests/DependencyInjection/CleverAgeArchiveProcessExtensionTest.php index 2bb7d38..3eae708 100644 --- a/tests/DependencyInjection/CleverAgeArchiveProcessExtensionTest.php +++ b/tests/DependencyInjection/CleverAgeArchiveProcessExtensionTest.php @@ -99,6 +99,32 @@ public function testTaskIsRegistered(string $class, string $code, string $deprec ); } + public function testEveryTaskIsTested(): void + { + $container = new ContainerBuilder(); + (new CleverAgeArchiveProcessExtension())->load([], $container); + + $ids = array_filter( + array_keys($container->getDefinitions()), + static fn (string $id): bool => str_starts_with($id, 'CleverAge\\ArchiveProcessBundle\\Task\\') + ); + self::assertEqualsCanonicalizing(array_column(iterator_to_array(self::provideTasks()), 0), array_values($ids)); + + // Every task has its own code, prefixed by the bridge name + $codes = array_column(iterator_to_array(self::provideTasks()), 1); + self::assertSame($codes, array_unique($codes)); + foreach ($codes as $code) { + self::assertStringStartsWith('archive_', $code); + } + + // Every former id is a deprecated alias + $aliases = array_filter( + array_keys($container->getAliases()), + static fn (string $id): bool => str_starts_with($id, 'cleverage_archive_process.task.') + ); + self::assertEqualsCanonicalizing(array_column(iterator_to_array(self::provideTasks()), 2), array_values($aliases)); + } + public function testConfigurationKeysAreDeprecated(): void { $deprecations = $this->collectDeprecations(static function (): void {