Skip to content

Commit 635c16e

Browse files
authored
Merge pull request #309 from oliverklee/task/assertsame
Use `assertSame` whereever possible in the tests
2 parents 780afb8 + 481f022 commit 635c16e

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

tests/ParserTest.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -407,21 +407,21 @@ public function slashedValues()
407407
$oRule = $oBlock->getRules('font');
408408
$oRule = $oRule[0];
409409
$oSpaceList = $oRule->getValue();
410-
self::assertEquals(' ', $oSpaceList->getListSeparator());
410+
self::assertSame(' ', $oSpaceList->getListSeparator());
411411
$oSlashList = $oSpaceList->getListComponents();
412412
$oCommaList = $oSlashList[1];
413413
$oSlashList = $oSlashList[0];
414-
self::assertEquals(',', $oCommaList->getListSeparator());
415-
self::assertEquals('/', $oSlashList->getListSeparator());
414+
self::assertSame(',', $oCommaList->getListSeparator());
415+
self::assertSame('/', $oSlashList->getListSeparator());
416416
$oRule = $oBlock->getRules('border-radius');
417417
$oRule = $oRule[0];
418418
$oSlashList = $oRule->getValue();
419-
self::assertEquals('/', $oSlashList->getListSeparator());
419+
self::assertSame('/', $oSlashList->getListSeparator());
420420
$oSpaceList1 = $oSlashList->getListComponents();
421421
$oSpaceList2 = $oSpaceList1[1];
422422
$oSpaceList1 = $oSpaceList1[0];
423-
self::assertEquals(' ', $oSpaceList1->getListSeparator());
424-
self::assertEquals(' ', $oSpaceList2->getListSeparator());
423+
self::assertSame(' ', $oSpaceList1->getListSeparator());
424+
self::assertSame(' ', $oSpaceList2->getListSeparator());
425425
}
426426
self::assertSame(
427427
'.test {font: 36px/1.5 Verdana,Arial,sans-serif;border-radius: 15px 30px 15px 30px/30px 15px 30px 15px;}',
@@ -922,12 +922,12 @@ public function missingPropertyValueLenient()
922922
self::assertCount(1, $rulesets);
923923
$block = $rulesets[0];
924924
self::assertTrue($block instanceof DeclarationBlock);
925-
self::assertEquals(['div'], $block->getSelectors());
925+
self::assertEquals([new Selector('div')], $block->getSelectors());
926926
$rules = $block->getRules();
927927
self::assertCount(1, $rules);
928928
$rule = $rules[0];
929-
self::assertEquals('display', $rule->getRule());
930-
self::assertEquals('inline-block', $rule->getValue());
929+
self::assertSame('display', $rule->getRule());
930+
self::assertSame('inline-block', $rule->getValue());
931931
}
932932

933933
/**
@@ -991,16 +991,16 @@ public function lineNumbersParsing()
991991
$aRules = $oDeclBlock->getRules();
992992
// Choose the 2nd one
993993
$oColor = $aRules[1]->getValue();
994-
self::assertEquals(27, $aRules[1]->getLineNo());
994+
self::assertSame(27, $aRules[1]->getLineNo());
995995

996996
$aActualColorLines = [];
997997
foreach ($oColor->getColor() as $oSize) {
998998
$aActualColorLines[] = $oSize->getLineNo();
999999
}
10001000

1001-
self::assertEquals($aExpectedColorLines, $aActualColorLines);
1002-
self::assertEquals($aUrlExpected, $aUrlActual);
1003-
self::assertEquals($aExpected, $aActual);
1001+
self::assertSame($aExpectedColorLines, $aActualColorLines);
1002+
self::assertSame($aUrlExpected, $aUrlActual);
1003+
self::assertSame($aExpected, $aActual);
10041004
}
10051005

10061006
/**
@@ -1040,7 +1040,7 @@ public function ieHacksParsing()
10401040
$oDoc = $this->parsedStructureForFile('ie-hacks', Settings::create()->withLenientParsing(true));
10411041
$sExpected = 'p {padding-right: .75rem \9;background-image: none \9;color: red \9\0;'
10421042
. 'background-color: red \9\0;background-color: red \9\0 !important;content: "red \0";content: "red઼";}';
1043-
self::assertEquals($sExpected, $oDoc->render());
1043+
self::assertSame($sExpected, $oDoc->render());
10441044
}
10451045

10461046
/**
@@ -1056,22 +1056,22 @@ public function commentExtracting()
10561056
// Import property.
10571057
$importComments = $aNodes[0]->getComments();
10581058
self::assertCount(1, $importComments);
1059-
self::assertEquals("*\n * Comments Hell.\n ", $importComments[0]->getComment());
1059+
self::assertSame("*\n * Comments Hell.\n ", $importComments[0]->getComment());
10601060

10611061
// Declaration block.
10621062
$fooBarBlock = $aNodes[1];
10631063
$fooBarBlockComments = $fooBarBlock->getComments();
10641064
// TODO Support comments in selectors.
10651065
// $this->assertCount(2, $fooBarBlockComments);
1066-
// $this->assertEquals("* Number 4 *", $fooBarBlockComments[0]->getComment());
1067-
// $this->assertEquals("* Number 5 *", $fooBarBlockComments[1]->getComment());
1066+
// $this->assertSame("* Number 4 *", $fooBarBlockComments[0]->getComment());
1067+
// $this->assertSame("* Number 5 *", $fooBarBlockComments[1]->getComment());
10681068

10691069
// Declaration rules.
10701070
$fooBarRules = $fooBarBlock->getRules();
10711071
$fooBarRule = $fooBarRules[0];
10721072
$fooBarRuleComments = $fooBarRule->getComments();
10731073
self::assertCount(1, $fooBarRuleComments);
1074-
self::assertEquals(" Number 6 ", $fooBarRuleComments[0]->getComment());
1074+
self::assertSame(" Number 6 ", $fooBarRuleComments[0]->getComment());
10751075

10761076
// Media property.
10771077
$mediaComments = $aNodes[2]->getComments();
@@ -1081,13 +1081,13 @@ public function commentExtracting()
10811081
$mediaRules = $aNodes[2]->getContents();
10821082
$fooBarComments = $mediaRules[0]->getComments();
10831083
self::assertCount(1, $fooBarComments);
1084-
self::assertEquals("* Number 10 *", $fooBarComments[0]->getComment());
1084+
self::assertSame("* Number 10 *", $fooBarComments[0]->getComment());
10851085

10861086
// Media -> declaration -> rule.
10871087
$fooBarRules = $mediaRules[0]->getRules();
10881088
$fooBarChildComments = $fooBarRules[0]->getComments();
10891089
self::assertCount(1, $fooBarChildComments);
1090-
self::assertEquals("* Number 10b *", $fooBarChildComments[0]->getComment());
1090+
self::assertSame("* Number 10b *", $fooBarChildComments[0]->getComment());
10911091
}
10921092

10931093
/**
@@ -1101,7 +1101,7 @@ public function flatCommentExtracting()
11011101
$divRules = $contents[0]->getRules();
11021102
$comments = $divRules[0]->getComments();
11031103
self::assertCount(1, $comments);
1104-
self::assertEquals("Find Me!", $comments[0]->getComment());
1104+
self::assertSame("Find Me!", $comments[0]->getComment());
11051105
}
11061106

11071107
/**
@@ -1114,7 +1114,7 @@ public function topLevelCommentExtracting()
11141114
$contents = $doc->getContents();
11151115
$comments = $contents[0]->getComments();
11161116
self::assertCount(1, $comments);
1117-
self::assertEquals("Find Me!", $comments[0]->getComment());
1117+
self::assertSame("Find Me!", $comments[0]->getComment());
11181118
}
11191119

11201120
/**

tests/RuleSet/DeclarationBlockTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ public function overrideRules()
325325

326326
$aRules = $oWrapper->getRules();
327327
self::assertCount(1, $aRules);
328-
self::assertEquals('right', $aRules[0]->getRule());
329-
self::assertEquals('-10px', $aRules[0]->getValue());
328+
self::assertSame('right', $aRules[0]->getRule());
329+
self::assertSame('-10px', $aRules[0]->getValue());
330330
}
331331

332332
/**
@@ -377,6 +377,8 @@ public function ruleInsertion()
377377

378378
/**
379379
* @test
380+
*
381+
* TODO: The order is different on PHP 5.6 than on PHP >= 7.0.
380382
*/
381383
public function orderOfElementsMatchingOriginalOrderAfterExpandingShorthands()
382384
{

0 commit comments

Comments
 (0)