From fb543d7c065dc25907663de6cd8f26325e266f1f Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Sun, 26 Jan 2025 16:36:55 +0100 Subject: [PATCH] [TASK] Migrate part of `CommentTests` to unit tests Part of #758. --- tests/Comment/CommentTest.php | 93 ------------------------- tests/Unit/Comment/CommentTest.php | 107 +++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 93 deletions(-) create mode 100644 tests/Unit/Comment/CommentTest.php diff --git a/tests/Comment/CommentTest.php b/tests/Comment/CommentTest.php index 1c32b6ca..d80c65f9 100644 --- a/tests/Comment/CommentTest.php +++ b/tests/Comment/CommentTest.php @@ -5,9 +5,7 @@ namespace Sabberworm\CSS\Tests\Comment; use PHPUnit\Framework\TestCase; -use Sabberworm\CSS\Comment\Comment; use Sabberworm\CSS\OutputFormat; -use Sabberworm\CSS\Renderable; use Sabberworm\CSS\Tests\ParserTest as TestsParserTest; /** @@ -17,97 +15,6 @@ */ final class CommentTest extends TestCase { - /** - * @test - */ - public function implementsRenderable(): void - { - $subject = new Comment(); - - self::assertInstanceOf(Renderable::class, $subject); - } - - /** - * @test - */ - public function getCommentOnEmptyInstanceReturnsReturnsEmptyString(): void - { - $subject = new Comment(); - - self::assertSame('', $subject->getComment()); - } - - /** - * @test - */ - public function getCommentInitiallyReturnsCommentPassedToConstructor(): void - { - $comment = 'There is no spoon.'; - $subject = new Comment($comment); - - self::assertSame($comment, $subject->getComment()); - } - - /** - * @test - */ - public function setCommentSetsComments(): void - { - $comment = 'There is no spoon.'; - $subject = new Comment(); - - $subject->setComment($comment); - - self::assertSame($comment, $subject->getComment()); - } - - /** - * @test - */ - public function getLineNoOnEmptyInstanceReturnsReturnsZero(): void - { - $subject = new Comment(); - - self::assertSame(0, $subject->getLineNo()); - } - - /** - * @test - */ - public function getLineNoInitiallyReturnsLineNumberPassedToConstructor(): void - { - $lineNumber = 42; - $subject = new Comment('', $lineNumber); - - 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())); - } - /** * @test */ diff --git a/tests/Unit/Comment/CommentTest.php b/tests/Unit/Comment/CommentTest.php new file mode 100644 index 00000000..c9e07102 --- /dev/null +++ b/tests/Unit/Comment/CommentTest.php @@ -0,0 +1,107 @@ +getComment()); + } + + /** + * @test + */ + public function getCommentInitiallyReturnsCommentPassedToConstructor(): void + { + $comment = 'There is no spoon.'; + $subject = new Comment($comment); + + self::assertSame($comment, $subject->getComment()); + } + + /** + * @test + */ + public function setCommentSetsComments(): void + { + $comment = 'There is no spoon.'; + $subject = new Comment(); + + $subject->setComment($comment); + + self::assertSame($comment, $subject->getComment()); + } + + /** + * @test + */ + public function getLineNoOnEmptyInstanceReturnsZero(): void + { + $subject = new Comment(); + + self::assertSame(0, $subject->getLineNo()); + } + + /** + * @test + */ + public function getLineNoInitiallyReturnsLineNumberPassedToConstructor(): void + { + $lineNumber = 42; + $subject = new Comment('', $lineNumber); + + 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())); + } +}