Skip to content

Commit 7498bef

Browse files
committed
Add TestCase.
For now, this just tests that all the unit values are parsed. (Other tests can be added here, but are beyond the scope of this change.)
1 parent 2a192bc commit 7498bef

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

tests/Value/SizeTest.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace Sabberworm\CSS\Tests\Value;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Sabberworm\CSS\Parsing\ParserState;
7+
use Sabberworm\CSS\Settings;
8+
use Sabberworm\CSS\Value\Size;
9+
10+
/**
11+
* @covers Size
12+
*/
13+
final class SizeTest extends TestCase
14+
{
15+
/**
16+
* @return array<string, array{0: string}>
17+
*/
18+
public static function provideUnit(): array
19+
{
20+
$units = [
21+
'px', 'pt', 'pc',
22+
'cm', 'mm', 'mozmm', 'in',
23+
'vh', 'dvh', 'svh', 'lvh',
24+
'vw', 'vmin', 'vmax', 'rem',
25+
'%', 'em', 'ex', 'ch', 'fr',
26+
'deg', 'grad', 'rad', 's', 'ms', 'turn', 'Hz', 'kHz',
27+
];
28+
29+
return \array_combine(
30+
$units,
31+
\array_map(
32+
function(string $unit): array {
33+
return [$unit];
34+
},
35+
$units
36+
)
37+
);
38+
}
39+
40+
/**
41+
* @test
42+
*
43+
* @dataProvider provideUnit
44+
*/
45+
public function parsesUnit(string $unit)
46+
{
47+
$subject = Size::parse(new ParserState('1' . $unit, Settings::create()));
48+
49+
self::assertSame($unit, $subject->getUnit());
50+
}
51+
}

0 commit comments

Comments
 (0)