Skip to content

Commit 0f37bfd

Browse files
authored
Merge pull request #333 from oliverklee/task/tests/at-rule-block-list
Make the tests for `AtRuleBlockList` more fine-grained
2 parents 8e5a086 + 5c8d74b commit 0f37bfd

File tree

1 file changed

+37
-15
lines changed

1 file changed

+37
-15
lines changed

tests/CSSList/AtRuleBlockListTest.php

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,49 @@
55
use PHPUnit\Framework\TestCase;
66
use Sabberworm\CSS\Parser;
77

8+
/**
9+
* @covers \Sabberworm\CSS\CSSList\AtRuleBlockList
10+
*/
811
class AtRuleBlockListTest extends TestCase
912
{
13+
/**
14+
* @return array<string, array<int, string>>
15+
*/
16+
public function mediaRuleDataProvider()
17+
{
18+
return [
19+
'without spaces around arguments' => ['@media(min-width: 768px){.class{color:red}}'],
20+
'with spaces around arguments' => ['@media (min-width: 768px) {.class{color:red}}'],
21+
];
22+
}
23+
24+
/**
25+
* @test
26+
*
27+
* @param string $css
28+
*
29+
* @dataProvider mediaRuleDataProvider
30+
*/
31+
public function parsesRuleNameOfMediaQueries($css)
32+
{
33+
$contents = (new Parser($css))->parse()->getContents();
34+
$atRuleBlockList = $contents[0];
35+
36+
self::assertSame('media', $atRuleBlockList->atRuleName());
37+
}
38+
1039
/**
1140
* @test
41+
*
42+
* @param string $css
43+
*
44+
* @dataProvider mediaRuleDataProvider
1245
*/
13-
public function mediaQueries()
46+
public function parsesArgumentsOfMediaQueries($css)
1447
{
15-
$sCss = '@media(min-width: 768px){.class{color:red}}';
16-
$oParser = new Parser($sCss);
17-
$oDoc = $oParser->parse();
18-
$aContents = $oDoc->getContents();
19-
$oMediaQuery = $aContents[0];
20-
self::assertSame('media', $oMediaQuery->atRuleName(), 'Does not interpret the type as a function');
21-
self::assertSame('(min-width: 768px)', $oMediaQuery->atRuleArgs(), 'The media query is the value');
48+
$contents = (new Parser($css))->parse()->getContents();
49+
$atRuleBlockList = $contents[0];
2250

23-
$sCss = '@media (min-width: 768px) {.class{color:red}}';
24-
$oParser = new Parser($sCss);
25-
$oDoc = $oParser->parse();
26-
$aContents = $oDoc->getContents();
27-
$oMediaQuery = $aContents[0];
28-
self::assertSame('media', $oMediaQuery->atRuleName(), 'Does not interpret the type as a function');
29-
self::assertSame('(min-width: 768px)', $oMediaQuery->atRuleArgs(), 'The media query is the value');
51+
self::assertSame('(min-width: 768px)', $atRuleBlockList->atRuleArgs());
3052
}
3153
}

0 commit comments

Comments
 (0)