forked from MyIntervals/PHP-CSS-Parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…Intervals#627) Fixes MyIntervals#412 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.) Co-authored-by: Kai König <[email protected]> Co-authored-by: Jake Hotson <[email protected]>
- Loading branch information
1 parent
2487bde
commit ab0baf7
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Sabberworm\CSS\Tests\Value; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Sabberworm\CSS\Parsing\ParserState; | ||
use Sabberworm\CSS\Settings; | ||
use Sabberworm\CSS\Value\Size; | ||
|
||
/** | ||
* @covers \Sabberworm\CSS\Value\Size | ||
*/ | ||
final class SizeTest extends TestCase | ||
{ | ||
/** | ||
* @return array<string, array{0: string}> | ||
*/ | ||
public static function provideUnit() | ||
{ | ||
$units = [ | ||
'px', 'pt', 'pc', | ||
'cm', 'mm', 'mozmm', 'in', | ||
'vh', 'dvh', 'svh', 'lvh', | ||
'vw', 'vmin', 'vmax', 'rem', | ||
'%', 'em', 'ex', 'ch', 'fr', | ||
'deg', 'grad', 'rad', 's', 'ms', 'turn', 'Hz', 'kHz', | ||
]; | ||
|
||
return \array_combine( | ||
$units, | ||
\array_map( | ||
function ($unit) { | ||
return [$unit]; | ||
}, | ||
$units | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* @test | ||
* | ||
* @dataProvider provideUnit | ||
*/ | ||
public function parsesUnit($unit) | ||
{ | ||
$subject = Size::parse(new ParserState('1' . $unit, Settings::create())); | ||
|
||
self::assertSame($unit, $subject->getUnit()); | ||
} | ||
} |