Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions tests/RuleSet/LenientParsingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Sabberworm\CSS\Parsing\UnexpectedTokenException;
use Sabberworm\CSS\Settings;

use function Safe\file_get_contents;

/**
* @coversNothing
*/
Expand All @@ -23,7 +25,7 @@ public function faultToleranceOff(): void
$this->expectException(UnexpectedTokenException::class);

$pathToFile = __DIR__ . '/../fixtures/-fault-tolerance.css';
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->beStrict());
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->beStrict());
$parser->parse();
}

Expand All @@ -33,7 +35,7 @@ public function faultToleranceOff(): void
public function faultToleranceOn(): void
{
$pathToFile = __DIR__ . '/../fixtures/-fault-tolerance.css';
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
$result = $parser->parse();
self::assertSame(
'.test1 {}' . "\n" . '.test2 {hello: 2.2;hello: 2000000000000.2;}' . "\n" . '#test {}' . "\n"
Expand All @@ -50,7 +52,7 @@ public function endToken(): void
$this->expectException(UnexpectedTokenException::class);

$pathToFile = __DIR__ . '/../fixtures/-end-token.css';
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->beStrict());
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->beStrict());
$parser->parse();
}

Expand All @@ -62,7 +64,7 @@ public function endToken2(): void
$this->expectException(UnexpectedTokenException::class);

$pathToFile = __DIR__ . '/../fixtures/-end-token-2.css';
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->beStrict());
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->beStrict());
$parser->parse();
}

Expand All @@ -72,7 +74,7 @@ public function endToken2(): void
public function endTokenPositive(): void
{
$pathToFile = __DIR__ . '/../fixtures/-end-token.css';
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
$result = $parser->parse();
self::assertSame('', $result->render());
}
Expand All @@ -83,7 +85,7 @@ public function endTokenPositive(): void
public function endToken2Positive(): void
{
$pathToFile = __DIR__ . '/../fixtures/-end-token-2.css';
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
$result = $parser->parse();
self::assertSame(
'#home .bg-layout {background-image: url("/bundles/main/img/bg1.png?5");}',
Expand All @@ -98,7 +100,7 @@ public function localeTrap(): void
{
\setlocale(LC_ALL, 'pt_PT', 'no');
$pathToFile = __DIR__ . '/../fixtures/-fault-tolerance.css';
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
$result = $parser->parse();
self::assertSame(
'.test1 {}' . "\n" . '.test2 {hello: 2.2;hello: 2000000000000.2;}' . "\n" . '#test {}' . "\n"
Expand All @@ -113,7 +115,7 @@ public function localeTrap(): void
public function caseInsensitivity(): void
{
$pathToFile = __DIR__ . '/../fixtures/case-insensitivity.css';
$parser = new Parser(\file_get_contents($pathToFile));
$parser = new Parser(file_get_contents($pathToFile));
$result = $parser->parse();

self::assertSame(
Expand All @@ -132,7 +134,7 @@ public function caseInsensitivity(): void
public function cssWithInvalidColorStillGetsParsedAsDocument(): void
{
$pathToFile = __DIR__ . '/../fixtures/invalid-color.css';
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
$result = $parser->parse();

self::assertInstanceOf(Document::class, $result);
Expand All @@ -146,7 +148,7 @@ public function invalidColorStrict(): void
$this->expectException(UnexpectedTokenException::class);

$pathToFile = __DIR__ . '/../fixtures/invalid-color.css';
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->beStrict());
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->beStrict());
$parser->parse();
}
}