Skip to content

[TASK] Migrate part of CommentTests to unit tests #821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 0 additions & 93 deletions tests/Comment/CommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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
*/
Expand Down
107 changes: 107 additions & 0 deletions tests/Unit/Comment/CommentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

declare(strict_types=1);

namespace Sabberworm\CSS\Tests\Unit\Comment;

use PHPUnit\Framework\TestCase;
use Sabberworm\CSS\Comment\Comment;
use Sabberworm\CSS\OutputFormat;
use Sabberworm\CSS\Renderable;

/**
* @covers \Sabberworm\CSS\Comment\Comment
*/
final class CommentTest extends TestCase
{
/**
* @test
*/
public function implementsRenderable(): void
{
$subject = new Comment();

self::assertInstanceOf(Renderable::class, $subject);
}

/**
* @test
*/
public function getCommentOnEmptyInstanceReturnsEmptyString(): 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 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()));
}
}