From a565f3cca2faef03fe54e8b42883e27af75d2974 Mon Sep 17 00:00:00 2001 From: HugoFara Date: Sun, 23 Aug 2026 12:40:32 +0200 Subject: [PATCH] chore(tests): move @covers to attributes for PHPUnit 12 (#233) Four dictionary-import test classes still carried their coverage target in a doc-comment, which PHPUnit 11 reports as a runner deprecation and PHPUnit 12 will stop reading altogether. The rest of the suite is already on #[CoversClass], so these were the last four; the run is now deprecation-free. Each class doc-comment existed only to hold the @covers line, so rather than leave a copy of the file header behind, each now says what its tests actually check. --- .../Infrastructure/Import/ArchiveExtractorTest.php | 5 ++++- .../Dictionary/Infrastructure/Import/CsvImporterBomTest.php | 5 ++++- .../Infrastructure/Import/CsvImporterCanImportTest.php | 5 ++++- .../Infrastructure/Import/JsonImporterCanImportTest.php | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/backend/Modules/Dictionary/Infrastructure/Import/ArchiveExtractorTest.php b/tests/backend/Modules/Dictionary/Infrastructure/Import/ArchiveExtractorTest.php index 75c79c50d..92a6edaef 100644 --- a/tests/backend/Modules/Dictionary/Infrastructure/Import/ArchiveExtractorTest.php +++ b/tests/backend/Modules/Dictionary/Infrastructure/Import/ArchiveExtractorTest.php @@ -15,13 +15,16 @@ namespace Lwt\Tests\Modules\Dictionary\Infrastructure\Import; use Lwt\Modules\Dictionary\Infrastructure\Import\ArchiveExtractor; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use RuntimeException; use ZipArchive; /** - * @covers \Lwt\Modules\Dictionary\Infrastructure\Import\ArchiveExtractor + * Archive detection, extraction and cleanup, including the path-traversal + * guard and the nested-file search extraction relies on. */ +#[CoversClass(ArchiveExtractor::class)] class ArchiveExtractorTest extends TestCase { private string $sandbox; diff --git a/tests/backend/Modules/Dictionary/Infrastructure/Import/CsvImporterBomTest.php b/tests/backend/Modules/Dictionary/Infrastructure/Import/CsvImporterBomTest.php index b0580a1c0..2b209ade9 100644 --- a/tests/backend/Modules/Dictionary/Infrastructure/Import/CsvImporterBomTest.php +++ b/tests/backend/Modules/Dictionary/Infrastructure/Import/CsvImporterBomTest.php @@ -15,12 +15,15 @@ namespace Lwt\Tests\Modules\Dictionary\Infrastructure\Import; use Lwt\Modules\Dictionary\Infrastructure\Import\CsvImporter; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use RuntimeException; /** - * @covers \Lwt\Modules\Dictionary\Infrastructure\Import\CsvImporter + * What the importer does with a byte-order mark: UTF-8 is stripped from the + * first cell, UTF-16 and UTF-32 are refused with a message that says why. */ +#[CoversClass(CsvImporter::class)] class CsvImporterBomTest extends TestCase { private string $tmpDir; diff --git a/tests/backend/Modules/Dictionary/Infrastructure/Import/CsvImporterCanImportTest.php b/tests/backend/Modules/Dictionary/Infrastructure/Import/CsvImporterCanImportTest.php index 02599189f..29aaa48bd 100644 --- a/tests/backend/Modules/Dictionary/Infrastructure/Import/CsvImporterCanImportTest.php +++ b/tests/backend/Modules/Dictionary/Infrastructure/Import/CsvImporterCanImportTest.php @@ -16,11 +16,14 @@ namespace Lwt\Tests\Modules\Dictionary\Infrastructure\Import; use Lwt\Modules\Dictionary\Infrastructure\Import\CsvImporter; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; /** - * @covers \Lwt\Modules\Dictionary\Infrastructure\Import\CsvImporter + * Whether a file is a CSV when the upload path has no extension, which is + * how PHP hands over $_FILES['file']['tmp_name']. */ +#[CoversClass(CsvImporter::class)] class CsvImporterCanImportTest extends TestCase { private string $tmpDir; diff --git a/tests/backend/Modules/Dictionary/Infrastructure/Import/JsonImporterCanImportTest.php b/tests/backend/Modules/Dictionary/Infrastructure/Import/JsonImporterCanImportTest.php index a52031f31..8d6d5588e 100644 --- a/tests/backend/Modules/Dictionary/Infrastructure/Import/JsonImporterCanImportTest.php +++ b/tests/backend/Modules/Dictionary/Infrastructure/Import/JsonImporterCanImportTest.php @@ -16,11 +16,14 @@ namespace Lwt\Tests\Modules\Dictionary\Infrastructure\Import; use Lwt\Modules\Dictionary\Infrastructure\Import\JsonImporter; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; /** - * @covers \Lwt\Modules\Dictionary\Infrastructure\Import\JsonImporter + * Whether a file is JSON when the upload path has no extension, which is + * how PHP hands over $_FILES['file']['tmp_name']. */ +#[CoversClass(JsonImporter::class)] class JsonImporterCanImportTest extends TestCase { private string $tmpDir;