Skip to content

Commit 2685076

Browse files
authored
Merge pull request MyIntervals#381 from oliverklee/task/more-comment-tests
2 parents 5bf29fe + 4986743 commit 2685076

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

tests/Comment/CommentTest.php

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace Sabberworm\CSS\Tests\Comment;
44

55
use PHPUnit\Framework\TestCase;
6+
use Sabberworm\CSS\Comment\Comment;
67
use Sabberworm\CSS\OutputFormat;
8+
use Sabberworm\CSS\Renderable;
79
use Sabberworm\CSS\Tests\ParserTest as TestsParserTest;
810

911
/**
@@ -14,6 +16,97 @@
1416
*/
1517
class CommentTest extends TestCase
1618
{
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+
17110
/**
18111
* @test
19112
*/

0 commit comments

Comments
 (0)