From 2e7d5790197a8889474aa5a95bd9928bf3f1320d Mon Sep 17 00:00:00 2001 From: Martin Herndl Date: Wed, 28 Feb 2024 18:13:24 +0100 Subject: [PATCH] Switch to PHPUnit 10 attributes instead of PHPDoc --- test/integration/Writer/MultiplePdfFilesWriterTest.php | 3 ++- test/unit/DocbookPageTest.php | 3 ++- test/unit/Formatter/ExtractFrontMatterTest.php | 7 ++++--- test/unit/Formatter/InlineCodeFromFileTest.php | 3 ++- test/unit/Formatter/InlineExternalImagesTest.php | 7 ++++--- test/unit/Writer/ConfluenceWriterTest.php | 3 ++- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/test/integration/Writer/MultiplePdfFilesWriterTest.php b/test/integration/Writer/MultiplePdfFilesWriterTest.php index d3b6380f..d435bd72 100644 --- a/test/integration/Writer/MultiplePdfFilesWriterTest.php +++ b/test/integration/Writer/MultiplePdfFilesWriterTest.php @@ -4,6 +4,7 @@ namespace Roave\DocbookToolIntegrationTest\Writer; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; use Roave\DocbookTool\DocbookPage; @@ -13,7 +14,7 @@ use function file_exists; use function unlink; -/** @covers \Roave\DocbookTool\Writer\MultiplePdfFilesWriter */ +#[CoversClass(MultiplePdfFilesWriter::class)] final class MultiplePdfFilesWriterTest extends TestCase { private const OUTPUT_PDF_PATH = __DIR__; diff --git a/test/unit/DocbookPageTest.php b/test/unit/DocbookPageTest.php index 8859acc3..7c4673f3 100644 --- a/test/unit/DocbookPageTest.php +++ b/test/unit/DocbookPageTest.php @@ -4,11 +4,12 @@ namespace Roave\DocbookToolUnitTest; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Roave\DocbookTool\DocbookPage; use RuntimeException; -/** @covers \Roave\DocbookTool\DocbookPage */ +#[CoversClass(DocbookPage::class)] final class DocbookPageTest extends TestCase { public function testEmptyPageThrowsExceptionWhenFetchingTitle(): void diff --git a/test/unit/Formatter/ExtractFrontMatterTest.php b/test/unit/Formatter/ExtractFrontMatterTest.php index db940074..12843c4a 100644 --- a/test/unit/Formatter/ExtractFrontMatterTest.php +++ b/test/unit/Formatter/ExtractFrontMatterTest.php @@ -4,6 +4,8 @@ namespace Roave\DocbookToolUnitTest\Formatter; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; use Roave\DocbookTool\DocbookPage; @@ -11,7 +13,7 @@ use Roave\DocbookTool\Formatter\ExtractFrontMatter; use Roave\DocbookTool\Formatter\MarkdownToHtml; -/** @covers \Roave\DocbookTool\Formatter\ExtractFrontMatter */ +#[CoversClass(ExtractFrontMatter::class)] final class ExtractFrontMatterTest extends TestCase { /** @return array */ @@ -75,9 +77,8 @@ public static function titleProvider(): array /** * @param non-empty-string $content * @param non-empty-string $expectedTitle - * - * @dataProvider titleProvider */ + #[DataProvider('titleProvider')] public function testTitleCanBeSetInFrontMatter(string $content, string $expectedTitle): void { $logger = new NullLogger(); diff --git a/test/unit/Formatter/InlineCodeFromFileTest.php b/test/unit/Formatter/InlineCodeFromFileTest.php index 2438ccbc..2fd5cb72 100644 --- a/test/unit/Formatter/InlineCodeFromFileTest.php +++ b/test/unit/Formatter/InlineCodeFromFileTest.php @@ -4,12 +4,13 @@ namespace Roave\DocbookToolUnitTest\Formatter; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; use Roave\DocbookTool\DocbookPage; use Roave\DocbookTool\Formatter\InlineCodeFromFile; -/** @covers \Roave\DocbookTool\Formatter\InlineCodeFromFile */ +#[CoversClass(InlineCodeFromFile::class)] final class InlineCodeFromFileTest extends TestCase { public function testExternalSourceCodeIsInlined(): void diff --git a/test/unit/Formatter/InlineExternalImagesTest.php b/test/unit/Formatter/InlineExternalImagesTest.php index c1a5fb38..dd1bce9c 100644 --- a/test/unit/Formatter/InlineExternalImagesTest.php +++ b/test/unit/Formatter/InlineExternalImagesTest.php @@ -4,6 +4,8 @@ namespace Roave\DocbookToolUnitTest\Formatter; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; use Roave\DocbookTool\DocbookPage; @@ -13,7 +15,7 @@ use function sprintf; -/** @covers \Roave\DocbookTool\Formatter\InlineExternalImages */ +#[CoversClass(InlineExternalImages::class)] final class InlineExternalImagesTest extends TestCase { private const MIME_JPG = 'image/jpeg'; @@ -61,9 +63,8 @@ public static function contentAndImagePathProvider(): array * @param non-empty-string $contentPath * @param non-empty-string $imagePath * @param non-empty-string $expectedMimeType - * - * @dataProvider contentAndImagePathProvider */ + #[DataProvider('contentAndImagePathProvider')] public function testExternalImagesAreInlined(string $contentPath, string $imagePath, string $expectedMimeType): void { $markdown = <<