|
3 | 3 | namespace Sabberworm\CSS\Tests\Comment;
|
4 | 4 |
|
5 | 5 | use PHPUnit\Framework\TestCase;
|
| 6 | +use Sabberworm\CSS\Comment\Comment; |
6 | 7 | use Sabberworm\CSS\OutputFormat;
|
| 8 | +use Sabberworm\CSS\Renderable; |
7 | 9 | use Sabberworm\CSS\Tests\ParserTest as TestsParserTest;
|
8 | 10 |
|
9 | 11 | /**
|
|
14 | 16 | */
|
15 | 17 | class CommentTest extends TestCase
|
16 | 18 | {
|
| 19 | + /** |
| 20 | + * @test |
| 21 | + */ |
| 22 | + public function implementsRenderable() |
| 23 | + { |
| 24 | + $subject = new Comment(); |
| 25 | + |
| 26 | + self::assertInstanceOf(Renderable::class, $subject); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * @test |
| 31 | + */ |
| 32 | + public function getCommentOnEmptyInstanceReturnsReturnsEmptyString() |
| 33 | + { |
| 34 | + $subject = new Comment(); |
| 35 | + |
| 36 | + self::assertSame('', $subject->getComment()); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * @test |
| 41 | + */ |
| 42 | + public function getCommentInitiallyReturnsCommentPassedToConstructor() |
| 43 | + { |
| 44 | + $comment = 'There is no spoon.'; |
| 45 | + $subject = new Comment($comment); |
| 46 | + |
| 47 | + self::assertSame($comment, $subject->getComment()); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * @test |
| 52 | + */ |
| 53 | + public function setCommentSetsComments() |
| 54 | + { |
| 55 | + $comment = 'There is no spoon.'; |
| 56 | + $subject = new Comment(); |
| 57 | + |
| 58 | + $subject->setComment($comment); |
| 59 | + |
| 60 | + self::assertSame($comment, $subject->getComment()); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * @test |
| 65 | + */ |
| 66 | + public function getLineNoOnEmptyInstanceReturnsReturnsZero() |
| 67 | + { |
| 68 | + $subject = new Comment(); |
| 69 | + |
| 70 | + self::assertSame(0, $subject->getLineNo()); |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * @test |
| 75 | + */ |
| 76 | + public function getLineNoInitiallyReturnsLineNumberPassedToConstructor() |
| 77 | + { |
| 78 | + $lineNumber = 42; |
| 79 | + $subject = new Comment('', $lineNumber); |
| 80 | + |
| 81 | + self::assertSame($lineNumber, $subject->getLineNo()); |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * @test |
| 86 | + */ |
| 87 | + public function toStringRendersCommentEnclosedInCommentDelimiters() |
| 88 | + { |
| 89 | + $comment = 'There is no spoon.'; |
| 90 | + $subject = new Comment(); |
| 91 | + |
| 92 | + $subject->setComment($comment); |
| 93 | + |
| 94 | + self::assertSame('/*' . $comment . '*/', (string)$subject); |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * @test |
| 99 | + */ |
| 100 | + public function renderRendersCommentEnclosedInCommentDelimiters() |
| 101 | + { |
| 102 | + $comment = 'There is no spoon.'; |
| 103 | + $subject = new Comment(); |
| 104 | + |
| 105 | + $subject->setComment($comment); |
| 106 | + |
| 107 | + self::assertSame('/*' . $comment . '*/', $subject->render(new OutputFormat())); |
| 108 | + } |
| 109 | + |
17 | 110 | /**
|
18 | 111 | * @test
|
19 | 112 | */
|
|
0 commit comments