Skip to content

Commit 822c875

Browse files
committed
[TASK] Make the tests more strict
1 parent 537f5e8 commit 822c875

File tree

2 files changed

+18
-30
lines changed

2 files changed

+18
-30
lines changed

config/phpstan-baseline.neon

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,3 @@ parameters:
395395
identifier: method.notFound
396396
count: 1
397397
path: ../src/Value/ValueList.php
398-
399-
-
400-
message: '#^Dynamic call to static method Sabberworm\\CSS\\Tests\\ParserTest\:\:parsedStructureForFile\(\)\.$#'
401-
identifier: staticMethod.dynamicCall
402-
count: 2
403-
path: ../tests/ParserTest.php
404-
405-
-
406-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
407-
identifier: equal.notAllowed
408-
count: 11
409-
path: ../tests/ParserTest.php
410-

tests/ParserTest.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Sabberworm\CSS\RuleSet\DeclarationBlock;
2222
use Sabberworm\CSS\RuleSet\RuleSet;
2323
use Sabberworm\CSS\Settings;
24+
use Sabberworm\CSS\Value\CalcFunction;
2425
use Sabberworm\CSS\Value\Color;
2526
use Sabberworm\CSS\Value\Size;
2627
use Sabberworm\CSS\Value\URL;
@@ -193,37 +194,37 @@ public function unicodeParsing(): void
193194
}
194195
$contentRules = $ruleSet->getRules('content');
195196
$firstContentRuleAsString = $contentRules[0]->getValue()->__toString();
196-
if ($selector == '.test-1') {
197+
if ($selector === '.test-1') {
197198
self::assertSame('" "', $firstContentRuleAsString);
198199
}
199-
if ($selector == '.test-2') {
200+
if ($selector === '.test-2') {
200201
self::assertSame('"é"', $firstContentRuleAsString);
201202
}
202-
if ($selector == '.test-3') {
203+
if ($selector === '.test-3') {
203204
self::assertSame('" "', $firstContentRuleAsString);
204205
}
205-
if ($selector == '.test-4') {
206+
if ($selector === '.test-4') {
206207
self::assertSame('"𝄞"', $firstContentRuleAsString);
207208
}
208-
if ($selector == '.test-5') {
209+
if ($selector === '.test-5') {
209210
self::assertSame('"水"', $firstContentRuleAsString);
210211
}
211-
if ($selector == '.test-6') {
212+
if ($selector === '.test-6') {
212213
self::assertSame('"¥"', $firstContentRuleAsString);
213214
}
214-
if ($selector == '.test-7') {
215+
if ($selector === '.test-7') {
215216
self::assertSame('"\\A"', $firstContentRuleAsString);
216217
}
217-
if ($selector == '.test-8') {
218+
if ($selector === '.test-8') {
218219
self::assertSame('"\\"\\""', $firstContentRuleAsString);
219220
}
220-
if ($selector == '.test-9') {
221+
if ($selector === '.test-9') {
221222
self::assertSame('"\\"\\\'"', $firstContentRuleAsString);
222223
}
223-
if ($selector == '.test-10') {
224+
if ($selector === '.test-10') {
224225
self::assertSame('"\\\'\\\\"', $firstContentRuleAsString);
225226
}
226-
if ($selector == '.test-11') {
227+
if ($selector === '.test-11') {
227228
self::assertSame('"test"', $firstContentRuleAsString);
228229
}
229230
}
@@ -1158,8 +1159,8 @@ public function flatCommentExtractingTwoComments(): void
11581159
$rule2Comments = $divRules[1]->getComments();
11591160
self::assertCount(1, $rule1Comments);
11601161
self::assertCount(1, $rule2Comments);
1161-
self::assertEquals('Find Me!', $rule1Comments[0]->getComment());
1162-
self::assertEquals('Find Me Too!', $rule2Comments[0]->getComment());
1162+
self::assertSame('Find Me!', $rule1Comments[0]->getComment());
1163+
self::assertSame('Find Me Too!', $rule2Comments[0]->getComment());
11631164
}
11641165

11651166
/**
@@ -1211,7 +1212,7 @@ public function largeSizeValuesInFile(): void
12111212
*/
12121213
public function scientificNotationSizeValuesInFile(): void
12131214
{
1214-
$document = $this->parsedStructureForFile(
1215+
$document = self::parsedStructureForFile(
12151216
'scientific-notation-numbers',
12161217
Settings::create()->withMultibyteSupport(false)
12171218
);
@@ -1233,12 +1234,12 @@ public function lonelyImport(): void
12331234

12341235
public function escapedSpecialCaseTokens(): void
12351236
{
1236-
$document = $this->parsedStructureForFile('escaped-tokens');
1237+
$document = self::parsedStructureForFile('escaped-tokens');
12371238
$contents = $document->getContents();
12381239
$rules = $contents[0]->getRules();
12391240
$urlRule = $rules[0];
12401241
$calcRule = $rules[1];
1241-
self::assertTrue(\is_a($urlRule->getValue(), '\\Sabberworm\\CSS\\Value\\URL'));
1242-
self::assertTrue(\is_a($calcRule->getValue(), '\\Sabberworm\\CSS\\Value\\CalcFunction'));
1242+
self::assertInstanceOf(URL::class, $urlRule->getValue());
1243+
self::assertInstanceOf(CalcFunction::class, $calcRule->getValue());
12431244
}
12441245
}

0 commit comments

Comments
 (0)