Skip to content

Commit 169fad2

Browse files
authored
[TASK] Migrate part of CommentTests to unit tests (#821)
Part of #758.
1 parent 8cd39f4 commit 169fad2

File tree

2 files changed

+107
-93
lines changed

2 files changed

+107
-93
lines changed

tests/Comment/CommentTest.php

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

77
use PHPUnit\Framework\TestCase;
8-
use Sabberworm\CSS\Comment\Comment;
98
use Sabberworm\CSS\OutputFormat;
10-
use Sabberworm\CSS\Renderable;
119
use Sabberworm\CSS\Tests\ParserTest as TestsParserTest;
1210

1311
/**
@@ -17,97 +15,6 @@
1715
*/
1816
final class CommentTest extends TestCase
1917
{
20-
/**
21-
* @test
22-
*/
23-
public function implementsRenderable(): void
24-
{
25-
$subject = new Comment();
26-
27-
self::assertInstanceOf(Renderable::class, $subject);
28-
}
29-
30-
/**
31-
* @test
32-
*/
33-
public function getCommentOnEmptyInstanceReturnsReturnsEmptyString(): void
34-
{
35-
$subject = new Comment();
36-
37-
self::assertSame('', $subject->getComment());
38-
}
39-
40-
/**
41-
* @test
42-
*/
43-
public function getCommentInitiallyReturnsCommentPassedToConstructor(): void
44-
{
45-
$comment = 'There is no spoon.';
46-
$subject = new Comment($comment);
47-
48-
self::assertSame($comment, $subject->getComment());
49-
}
50-
51-
/**
52-
* @test
53-
*/
54-
public function setCommentSetsComments(): void
55-
{
56-
$comment = 'There is no spoon.';
57-
$subject = new Comment();
58-
59-
$subject->setComment($comment);
60-
61-
self::assertSame($comment, $subject->getComment());
62-
}
63-
64-
/**
65-
* @test
66-
*/
67-
public function getLineNoOnEmptyInstanceReturnsReturnsZero(): void
68-
{
69-
$subject = new Comment();
70-
71-
self::assertSame(0, $subject->getLineNo());
72-
}
73-
74-
/**
75-
* @test
76-
*/
77-
public function getLineNoInitiallyReturnsLineNumberPassedToConstructor(): void
78-
{
79-
$lineNumber = 42;
80-
$subject = new Comment('', $lineNumber);
81-
82-
self::assertSame($lineNumber, $subject->getLineNo());
83-
}
84-
85-
/**
86-
* @test
87-
*/
88-
public function toStringRendersCommentEnclosedInCommentDelimiters(): void
89-
{
90-
$comment = 'There is no spoon.';
91-
$subject = new Comment();
92-
93-
$subject->setComment($comment);
94-
95-
self::assertSame('/*' . $comment . '*/', (string) $subject);
96-
}
97-
98-
/**
99-
* @test
100-
*/
101-
public function renderRendersCommentEnclosedInCommentDelimiters(): void
102-
{
103-
$comment = 'There is no spoon.';
104-
$subject = new Comment();
105-
106-
$subject->setComment($comment);
107-
108-
self::assertSame('/*' . $comment . '*/', $subject->render(new OutputFormat()));
109-
}
110-
11118
/**
11219
* @test
11320
*/

tests/Unit/Comment/CommentTest.php

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

0 commit comments

Comments
 (0)