Skip to content

Commit aa32320

Browse files
committed
fixing failing unit tests
1 parent 4fa7b72 commit aa32320

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

lib/Sabberworm/CSS/RuleSet/RuleSet.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,16 @@ public function addRule(Rule $oRule, Rule $oSibling = null) {
7878
$iSiblingPos = array_search($oSibling, $this->aRules[$sRule], true);
7979
if ($iSiblingPos !== false) {
8080
$iPosition = $iSiblingPos;
81-
$oRule->setPosition($oSibling->getLineNo(), $oSibling->getColNo() - 1);
81+
$oRule->setPosition($oSibling->getLineNo(), $oSibling->getColNo() - 1);
82+
}
83+
}
84+
if ($oRule->getLineNo() === 0 && $oRule->getColNo() === 0) {
85+
//this node is added manually, give it the next best line
86+
$rules = $this->getRules();
87+
$pos = count($rules);
88+
if ($pos > 0) {
89+
$last = $rules[$pos - 1];
90+
$oRule->setPosition($last->getLineNo() + 1, 0);
8291
}
8392
}
8493

tests/Sabberworm/CSS/RuleSet/DeclarationBlockTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,12 @@ public function testOrderOfElementsMatchingOriginalOrderAfterExpandingShorthands
276276
$oDeclaration = array_pop($aDocs);
277277
$oDeclaration->expandShorthands();
278278

279-
$this->assertEqual(
279+
$this->assertEquals(
280280
array(
281-
'padding-top' => 'padding-top:20px',
282-
'padding-left' => 'padding-top:5px',
283-
'padding-rigth' => 'padding-top:5px',
284-
'padding-bottom' => 'padding-top:5px',
281+
'padding-top' => 'padding-top: 20px;',
282+
'padding-right' => 'padding-right: 5px;',
283+
'padding-bottom' => 'padding-bottom: 5px;',
284+
'padding-left' => 'padding-left: 5px;',
285285
),
286286
array_map('strval', $oDeclaration->getRulesAssoc())
287287
);

0 commit comments

Comments
 (0)