Skip to content

Commit 102dd83

Browse files
committed
Add unit tests for @Keyframes rules
1 parent 1051a87 commit 102dd83

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

tests/Sabberworm/CSS/ParserTest.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Sabberworm\CSS\Value\Size;
66
use Sabberworm\CSS\Property\Selector;
77
use Sabberworm\CSS\RuleSet\AtRule;
8+
use Sabberworm\CSS\CSSList\KeyFrame;
89

910
class ParserTest extends \PHPUnit_Framework_TestCase {
1011

@@ -149,14 +150,24 @@ function testSpecificity() {
149150

150151
function testManipulation() {
151152
$oDoc = $this->parsedStructureForFile('atrules');
152-
$this->assertSame('@charset "utf-8";@font-face {font-family: "CrassRoots";src: url("../media/cr.ttf");}html, body {font-size: 1.6em;}' . "\n", $oDoc->__toString());
153+
$this->assertSame('@charset "utf-8";@font-face {font-family: "CrassRoots";src: url("../media/cr.ttf");}html, body {font-size: 1.6em;}
154+
@keyframes mymove {from {top: 0px;}
155+
to {top: 200px;}
156+
}@-moz-keyframes some-move {from {top: 0px;}
157+
to {top: 200px;}
158+
}', $oDoc->__toString());
153159
foreach ($oDoc->getAllDeclarationBlocks() as $oBlock) {
154160
foreach ($oBlock->getSelectors() as $oSelector) {
155161
//Loop over all selector parts (the comma-separated strings in a selector) and prepend the id
156162
$oSelector->setSelector('#my_id ' . $oSelector->getSelector());
157163
}
158164
}
159-
$this->assertSame('@charset "utf-8";@font-face {font-family: "CrassRoots";src: url("../media/cr.ttf");}#my_id html, #my_id body {font-size: 1.6em;}' . "\n", $oDoc->__toString());
165+
$this->assertSame('@charset "utf-8";@font-face {font-family: "CrassRoots";src: url("../media/cr.ttf");}#my_id html, #my_id body {font-size: 1.6em;}
166+
@keyframes mymove {from {top: 0px;}
167+
to {top: 200px;}
168+
}@-moz-keyframes some-move {from {top: 0px;}
169+
to {top: 200px;}
170+
}', $oDoc->__toString());
160171

161172
$oDoc = $this->parsedStructureForFile('values');
162173
$this->assertSame('#header {margin: 10px 2em 1cm 2%;font-family: Verdana,Helvetica,"Gill Sans",sans-serif;font-size: 10px;color: red !important;}
@@ -252,9 +263,9 @@ function testPrefixedGradient() {
252263
function testListValueRemoval() {
253264
$oDoc = $this->parsedStructureForFile('atrules');
254265
foreach ($oDoc->getContents() as $oItem) {
255-
if ($oItem instanceof AtRule) {
266+
if ($oItem instanceof AtRule || $oItem instanceof KeyFrame) {
256267
$oDoc->remove($oItem);
257-
break;
268+
continue;
258269
}
259270
}
260271
$this->assertSame('@charset "utf-8";html, body {font-size: 1.6em;}' . "\n", $oDoc->__toString());

tests/files/atrules.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@
88
html, body {
99
font-size: 1.6em
1010
}
11+
12+
@keyframes mymove {
13+
from { top: 0px; }
14+
to { top: 200px; }
15+
}
16+
17+
@-moz-keyframes some-move {
18+
from { top: 0px; }
19+
to { top: 200px; }
20+
}

0 commit comments

Comments
 (0)