|
5 | 5 | use PHPUnit\Framework\TestCase;
|
6 | 6 | use Sabberworm\CSS\Parser;
|
7 | 7 |
|
| 8 | +/** |
| 9 | + * @covers \Sabberworm\CSS\CSSList\AtRuleBlockList |
| 10 | + */ |
8 | 11 | class AtRuleBlockListTest extends TestCase
|
9 | 12 | {
|
| 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 | + |
10 | 39 | /**
|
11 | 40 | * @test
|
| 41 | + * |
| 42 | + * @param string $css |
| 43 | + * |
| 44 | + * @dataProvider mediaRuleDataProvider |
12 | 45 | */
|
13 |
| - public function mediaQueries() |
| 46 | + public function parsesArgumentsOfMediaQueries($css) |
14 | 47 | {
|
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]; |
22 | 50 |
|
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()); |
30 | 52 | }
|
31 | 53 | }
|
0 commit comments