Skip to content

[TASK] Add more unit tests for Size #1165

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
Mar 13, 2025
Merged
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
32 changes: 29 additions & 3 deletions tests/Unit/Value/SizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,39 @@
use PHPUnit\Framework\TestCase;
use Sabberworm\CSS\Parsing\ParserState;
use Sabberworm\CSS\Settings;
use Sabberworm\CSS\Value\PrimitiveValue;
use Sabberworm\CSS\Value\Size;
use Sabberworm\CSS\Value\Value;

/**
* @covers \Sabberworm\CSS\Value\PrimitiveValue
* @covers \Sabberworm\CSS\Value\Size
* @covers \Sabberworm\CSS\Value\Value
*/
final class SizeTest extends TestCase
{
/**
* @return array<string, array{0: string}>
* @test
*/
public function isPrimitiveValue(): void
{
$subject = new Size(1);

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

/**
* @test
*/
public function isValue(): void
{
$subject = new Size(1);

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

/**
* @return array<string, array{0: non-empty-string}>
*/
public static function provideUnit(): array
{
Expand Down Expand Up @@ -64,12 +88,14 @@ static function (string $unit): array {
/**
* @test
*
* @param non-empty-string $unit
*
* @dataProvider provideUnit
*/
public function parsesUnit(string $unit): void
{
$subject = Size::parse(new ParserState('1' . $unit, Settings::create()));
$parsedSize = Size::parse(new ParserState('1' . $unit, Settings::create()));

self::assertSame($unit, $subject->getUnit());
self::assertSame($unit, $parsedSize->getUnit());
}
}