Skip to content

Commit 2d1b071

Browse files
committed
Add TestCase and changelog entry
For now, the `TestCase` 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 2d1b071

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
77

88
### Added
99

10+
- Support `dvh`, `lvh` and `svh` length units (#415)
1011
- Add more tests (#449)
1112

1213
### 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 \Sabberworm\CSS\Value\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)