Skip to content

Commit 5581cb7

Browse files
committed
Move tests to appropriate testing class.
1 parent bbc2d73 commit 5581cb7

File tree

2 files changed

+52
-17
lines changed

2 files changed

+52
-17
lines changed

tests/CSSList/AtRuleBlockListTest.php

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,46 @@
77
use Sabberworm\CSS\CSSList\AtRuleBlockList;
88
use Sabberworm\CSS\Parser;
99
use Sabberworm\CSS\Renderable;
10+
use Sabberworm\CSS\Settings;
1011

1112
/**
1213
* @covers \Sabberworm\CSS\CSSList\AtRuleBlockList
1314
*/
1415
final class AtRuleBlockListTest extends TestCase
1516
{
17+
/**
18+
* @return array<string, array<int, string>>
19+
*/
20+
public static function provideMinWidthMediaRule()
21+
{
22+
return [
23+
'without spaces around arguments' => ['@media(min-width: 768px){.class{color:red}}'],
24+
'with spaces around arguments' => ['@media (min-width: 768px) {.class{color:red}}'],
25+
];
26+
}
27+
28+
/**
29+
* @return array<string, array<int, string>>
30+
*/
31+
public static function provideSyntacticlyCorrectAtRule()
32+
{
33+
return [
34+
'media print' => ['@media print { html { background: white; color: black; } }'],
35+
'keyframes' => ['@keyframes mymove { from { top: 0px; } }'],
36+
'supports' => ['
37+
@supports (display: flex) {
38+
.flex-container > * {
39+
text-shadow: 0 0 2px blue;
40+
float: none;
41+
}
42+
.flex-container {
43+
display: flex;
44+
}
45+
}
46+
'],
47+
];
48+
}
49+
1650
/**
1751
* @test
1852
*/
@@ -43,23 +77,12 @@ public function implementsCommentable()
4377
self::assertInstanceOf(Commentable::class, $subject);
4478
}
4579

46-
/**
47-
* @return array<string, array<int, string>>
48-
*/
49-
public static function mediaRuleDataProvider()
50-
{
51-
return [
52-
'without spaces around arguments' => ['@media(min-width: 768px){.class{color:red}}'],
53-
'with spaces around arguments' => ['@media (min-width: 768px) {.class{color:red}}'],
54-
];
55-
}
56-
5780
/**
5881
* @test
5982
*
6083
* @param string $css
6184
*
62-
* @dataProvider mediaRuleDataProvider
85+
* @dataProvider provideMinWidthMediaRule
6386
*/
6487
public function parsesRuleNameOfMediaQueries($css)
6588
{
@@ -74,7 +97,7 @@ public function parsesRuleNameOfMediaQueries($css)
7497
*
7598
* @param string $css
7699
*
77-
* @dataProvider mediaRuleDataProvider
100+
* @dataProvider provideMinWidthMediaRule
78101
*/
79102
public function parsesArgumentsOfMediaQueries($css)
80103
{
@@ -83,4 +106,19 @@ public function parsesArgumentsOfMediaQueries($css)
83106

84107
self::assertSame('(min-width: 768px)', $atRuleBlockList->atRuleArgs());
85108
}
109+
110+
/**
111+
* @test
112+
*
113+
* @param string $css
114+
*
115+
* @dataProvider provideMinWidthMediaRule
116+
* @dataProvider provideSyntacticlyCorrectAtRule
117+
*/
118+
public function parsesSyntacticlyCorrectAtRuleInStrictMode($css)
119+
{
120+
$contents = (new Parser($css, Settings::create()->beStrict()))->parse()->getContents();
121+
122+
self::assertNotEmpty($contents, 'Failing CSS: `' . $css . '`');
123+
}
86124
}

tests/ParserTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ public function files()
7474
// or a future test of a as-of-now missing feature
7575
continue;
7676
}
77-
$oParser = new Parser(
78-
\file_get_contents($sDirectory . '/' . $sFileName),
79-
Settings::create()->withLenientParsing($sFileName[0] !== '=')
80-
);
77+
$oParser = new Parser(file_get_contents($sDirectory . '/' . $sFileName));
8178
try {
8279
self::assertNotEquals('', $oParser->parse()->render());
8380
} catch (\Exception $e) {

0 commit comments

Comments
 (0)