diff --git a/tests/Comment/CommentTest.php b/tests/Comment/CommentTest.php index 14a0b240..29385f01 100644 --- a/tests/Comment/CommentTest.php +++ b/tests/Comment/CommentTest.php @@ -3,7 +3,9 @@ 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; /** @@ -14,6 +16,97 @@ */ class CommentTest extends TestCase { + /** + * @test + */ + public function implementsRenderable() + { + $subject = new Comment(); + + self::assertInstanceOf(Renderable::class, $subject); + } + + /** + * @test + */ + public function getCommentOnEmptyInstanceReturnsReturnsEmptyString() + { + $subject = new Comment(); + + self::assertSame('', $subject->getComment()); + } + + /** + * @test + */ + public function getCommentInitiallyReturnsCommentPassedToConstructor() + { + $comment = 'There is no spoon.'; + $subject = new Comment($comment); + + self::assertSame($comment, $subject->getComment()); + } + + /** + * @test + */ + public function setCommentSetsComments() + { + $comment = 'There is no spoon.'; + $subject = new Comment(); + + $subject->setComment($comment); + + self::assertSame($comment, $subject->getComment()); + } + + /** + * @test + */ + public function getLineNoOnEmptyInstanceReturnsReturnsZero() + { + $subject = new Comment(); + + self::assertSame(0, $subject->getLineNo()); + } + + /** + * @test + */ + public function getLineNoInitiallyReturnsLineNumberPassedToConstructor() + { + $lineNumber = 42; + $subject = new Comment('', $lineNumber); + + self::assertSame($lineNumber, $subject->getLineNo()); + } + + /** + * @test + */ + public function toStringRendersCommentEnclosedInCommentDelimiters() + { + $comment = 'There is no spoon.'; + $subject = new Comment(); + + $subject->setComment($comment); + + self::assertSame('/*' . $comment . '*/', (string)$subject); + } + + /** + * @test + */ + public function renderRendersCommentEnclosedInCommentDelimiters() + { + $comment = 'There is no spoon.'; + $subject = new Comment(); + + $subject->setComment($comment); + + self::assertSame('/*' . $comment . '*/', $subject->render(new OutputFormat())); + } + /** * @test */