From 126e1483afc5bd180f305f2afe273f758578a9e3 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 11 Feb 2025 22:19:59 +0100 Subject: [PATCH 1/4] [TASK] Move some tests for `Comment` to functional tests Move the tests that rely on another class (`OutputFormat`) (or might in the future). Part of #757. --- tests/Functional/.gitkeep | 0 tests/Functional/Comment/CommentTest.php | 67 ++++++++++++++++++++++++ tests/Unit/Comment/CommentTest.php | 27 ---------- 3 files changed, 67 insertions(+), 27 deletions(-) delete mode 100644 tests/Functional/.gitkeep create mode 100644 tests/Functional/Comment/CommentTest.php diff --git a/tests/Functional/.gitkeep b/tests/Functional/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Functional/Comment/CommentTest.php b/tests/Functional/Comment/CommentTest.php new file mode 100644 index 00000000..cb6a4fa6 --- /dev/null +++ b/tests/Functional/Comment/CommentTest.php @@ -0,0 +1,67 @@ +setComment($comment); + + self::assertSame('/*' . $comment . '*/', (string) $subject); + } + + /** + * @test + */ + public function renderWithDefaultOutputFormatRendersCommentEnclosedInCommentDelimiters(): void + { + $comment = 'There is no spoon.'; + $subject = new Comment(); + + $subject->setComment($comment); + + self::assertSame('/*' . $comment . '*/', $subject->render(new OutputFormat())); + } + + /** + * @test + */ + public function renderWithCompactOutputFormatRendersCommentEnclosedInCommentDelimiters(): void + { + $comment = 'There is no spoon.'; + $subject = new Comment(); + + $subject->setComment($comment); + + self::assertSame('/*' . $comment . '*/', $subject->render(new OutputFormat())); + } + + /** + * @test + */ + public function renderWithPrettyOutputFormatRendersCommentEnclosedInCommentDelimiters(): void + { + $comment = 'There is no spoon.'; + $subject = new Comment(); + + $subject->setComment($comment); + + self::assertSame('/*' . $comment . '*/', $subject->render(new OutputFormat())); + } +} diff --git a/tests/Unit/Comment/CommentTest.php b/tests/Unit/Comment/CommentTest.php index c9e07102..2bfe670c 100644 --- a/tests/Unit/Comment/CommentTest.php +++ b/tests/Unit/Comment/CommentTest.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\TestCase; use Sabberworm\CSS\Comment\Comment; -use Sabberworm\CSS\OutputFormat; use Sabberworm\CSS\Renderable; /** @@ -78,30 +77,4 @@ public function getLineNoInitiallyReturnsLineNumberPassedToConstructor(): void self::assertSame($lineNumber, $subject->getLineNo()); } - - /** - * @test - */ - public function toStringRendersCommentEnclosedInCommentDelimiters(): void - { - $comment = 'There is no spoon.'; - $subject = new Comment(); - - $subject->setComment($comment); - - self::assertSame('/*' . $comment . '*/', (string) $subject); - } - - /** - * @test - */ - public function renderRendersCommentEnclosedInCommentDelimiters(): void - { - $comment = 'There is no spoon.'; - $subject = new Comment(); - - $subject->setComment($comment); - - self::assertSame('/*' . $comment . '*/', $subject->render(new OutputFormat())); - } } From 788119c8d70c478a8696ed13a2ae0b67b968323f Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Thu, 13 Feb 2025 10:02:49 +0100 Subject: [PATCH 2/4] Update tests/Functional/Comment/CommentTest.php Co-authored-by: JakeQZ --- tests/Functional/Comment/CommentTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Functional/Comment/CommentTest.php b/tests/Functional/Comment/CommentTest.php index cb6a4fa6..6e5a1fc9 100644 --- a/tests/Functional/Comment/CommentTest.php +++ b/tests/Functional/Comment/CommentTest.php @@ -62,6 +62,6 @@ public function renderWithPrettyOutputFormatRendersCommentEnclosedInCommentDelim $subject->setComment($comment); - self::assertSame('/*' . $comment . '*/', $subject->render(new OutputFormat())); + self::assertSame('/*' . $comment . '*/', $subject->render(OutputFormat::createPretty())); } } From 1d7b87d8c88b64c29d8ffccdad0df5124cc55c20 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Thu, 13 Feb 2025 10:02:59 +0100 Subject: [PATCH 3/4] Update tests/Functional/Comment/CommentTest.php Co-authored-by: JakeQZ --- tests/Functional/Comment/CommentTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Functional/Comment/CommentTest.php b/tests/Functional/Comment/CommentTest.php index 6e5a1fc9..f69fa465 100644 --- a/tests/Functional/Comment/CommentTest.php +++ b/tests/Functional/Comment/CommentTest.php @@ -49,7 +49,7 @@ public function renderWithCompactOutputFormatRendersCommentEnclosedInCommentDeli $subject->setComment($comment); - self::assertSame('/*' . $comment . '*/', $subject->render(new OutputFormat())); + self::assertSame('/*' . $comment . '*/', $subject->render(OutputFormat::createCompact())); } /** From a470b6cc45d7fbee19d8c9bb3203033fcfe9f8c4 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Thu, 13 Feb 2025 10:05:10 +0100 Subject: [PATCH 4/4] Test more output formats --- tests/Functional/Comment/CommentTest.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/Functional/Comment/CommentTest.php b/tests/Functional/Comment/CommentTest.php index f69fa465..100d2531 100644 --- a/tests/Functional/Comment/CommentTest.php +++ b/tests/Functional/Comment/CommentTest.php @@ -29,7 +29,7 @@ public function toStringRendersCommentEnclosedInCommentDelimiters(): void /** * @test */ - public function renderWithDefaultOutputFormatRendersCommentEnclosedInCommentDelimiters(): void + public function renderWithVirginOutputFormatRendersCommentEnclosedInCommentDelimiters(): void { $comment = 'There is no spoon.'; $subject = new Comment(); @@ -39,6 +39,19 @@ public function renderWithDefaultOutputFormatRendersCommentEnclosedInCommentDeli self::assertSame('/*' . $comment . '*/', $subject->render(new OutputFormat())); } + /** + * @test + */ + public function renderWithDefaultOutputFormatRendersCommentEnclosedInCommentDelimiters(): void + { + $comment = 'There is no spoon.'; + $subject = new Comment(); + + $subject->setComment($comment); + + self::assertSame('/*' . $comment . '*/', $subject->render(OutputFormat::create())); + } + /** * @test */