Skip to content
Draft
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"ext-iconv": "*"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36",
"codacy/coverage": "^1.4"
"codacy/coverage": "^1.4",
"phpunit/phpunit": "^9.5"
},
"suggest": {
"ext-mbstring": "for parsing UTF-8 CSS"
Expand Down
26 changes: 12 additions & 14 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd">
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion tests/CSSList/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DocumentTest extends TestCase
*/
private $subject;

protected function setUp()
protected function setUp(): void
{
$this->subject = new Document();
}
Expand Down
5 changes: 3 additions & 2 deletions tests/OutputFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class OutputFormatTest extends TestCase
*/
private $oDocument;

protected function setUp()
protected function setUp(): void
{
$this->oParser = new Parser(self::TEST_CSS);
$this->oDocument = $this->oParser->parse();
Expand Down Expand Up @@ -268,12 +268,13 @@ public function spaceBeforeBraces()
}

/**
* @expectedException \Sabberworm\CSS\Parsing\OutputException
*
*
* @test
*/
public function ignoreExceptionsOff()
{
$this->expectException(\Sabberworm\CSS\Parsing\OutputException::class);
$aBlocks = $this->oDocument->getAllDeclarationBlocks();
$oFirstBlock = $aBlocks[0];
$oFirstBlock->removeSelector('.main');
Expand Down
30 changes: 20 additions & 10 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,13 @@ public function listValueRemoval()
}

/**
* @expectedException \Sabberworm\CSS\Parsing\OutputException
*
*
* @test
*/
public function selectorRemoval()
{
$this->expectException(\Sabberworm\CSS\Parsing\OutputException::class);
$oDoc = $this->parsedStructureForFile('1readme');
$aBlocks = $oDoc->getAllDeclarationBlocks();
$oBlock1 = $aBlocks[0];
Expand Down Expand Up @@ -802,22 +803,24 @@ public function keyframeSelectors()
}

/**
* @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException
*
*
* @test
*/
public function lineNameFailure()
{
$this->expectException(\Sabberworm\CSS\Parsing\UnexpectedTokenException::class);
$this->parsedStructureForFile('-empty-grid-linename', Settings::create()->withLenientParsing(false));
}

/**
* @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException
*
*
* @test
*/
public function calcFailure()
{
$this->expectException(\Sabberworm\CSS\Parsing\UnexpectedTokenException::class);
$this->parsedStructureForFile('-calc-no-space-around-minus', Settings::create()->withLenientParsing(false));
}

Expand Down Expand Up @@ -884,45 +887,49 @@ public function trailingWhitespace()
}

/**
* @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException
*
*
* @test
*/
public function charsetFailure1()
{
$this->expectException(\Sabberworm\CSS\Parsing\UnexpectedTokenException::class);
$this->parsedStructureForFile('-charset-after-rule', Settings::create()->withLenientParsing(false));
}

/**
* @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException
*
*
* @test
*/
public function charsetFailure2()
{
$this->expectException(\Sabberworm\CSS\Parsing\UnexpectedTokenException::class);
$this->parsedStructureForFile('-charset-in-block', Settings::create()->withLenientParsing(false));
}

/**
* @expectedException \Sabberworm\CSS\Parsing\SourceException
*
*
* @test
*/
public function unopenedClosingBracketFailure()
{
$this->expectException(\Sabberworm\CSS\Parsing\SourceException::class);
$this->parsedStructureForFile('-unopened-close-brackets', Settings::create()->withLenientParsing(false));
}

/**
* Ensure that a missing property value raises an exception.
*
* @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException
*
* @covers \Sabberworm\CSS\Value\Value::parseValue()
*
* @test
*/
public function missingPropertyValueStrict()
{
$this->expectException(\Sabberworm\CSS\Parsing\UnexpectedTokenException::class);
$this->parsedStructureForFile('missing-property-value', Settings::create()->withLenientParsing(false));
}

Expand Down Expand Up @@ -1022,12 +1029,13 @@ public function lineNumbersParsing()
}

/**
* @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException
*
*
* @test
*/
public function unexpectedTokenExceptionLineNo()
{
$this->expectException(\Sabberworm\CSS\Parsing\UnexpectedTokenException::class);
$oParser = new Parser("\ntest: 1;", Settings::create()->beStrict());
try {
$oParser->parse();
Expand All @@ -1038,12 +1046,13 @@ public function unexpectedTokenExceptionLineNo()
}

/**
* @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException
*
*
* @test
*/
public function ieHacksStrictParsing()
{
$this->expectException(\Sabberworm\CSS\Parsing\UnexpectedTokenException::class);
// We can't strictly parse IE hacks.
$this->parsedStructureForFile('ie-hacks', Settings::create()->beStrict());
}
Expand Down Expand Up @@ -1147,12 +1156,13 @@ public function topLevelCommentExtracting()
}

/**
* @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException
*
*
* @test
*/
public function microsoftFilterStrictParsing()
{
$this->expectException(\Sabberworm\CSS\Parsing\UnexpectedTokenException::class);
$oDoc = $this->parsedStructureForFile('ms-filter', Settings::create()->beStrict());
}

Expand Down
9 changes: 6 additions & 3 deletions tests/RuleSet/LenientParsingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
class LenientParsingTest extends TestCase
{
/**
* @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException
*
*
* @test
*/
public function faultToleranceOff()
{
$this->expectException(\Sabberworm\CSS\Parsing\UnexpectedTokenException::class);
$sFile = __DIR__ . '/../fixtures/-fault-tolerance.css';
$oParser = new Parser(file_get_contents($sFile), Settings::create()->beStrict());
$oParser->parse();
Expand All @@ -48,24 +49,26 @@ public function faultToleranceOn()
}

/**
* @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException
*
*
* @test
*/
public function endToken()
{
$this->expectException(\Sabberworm\CSS\Parsing\UnexpectedTokenException::class);
$sFile = __DIR__ . '/../fixtures/-end-token.css';
$oParser = new Parser(file_get_contents($sFile), Settings::create()->beStrict());
$oParser->parse();
}

/**
* @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException
*
*
* @test
*/
public function endToken2()
{
$this->expectException(\Sabberworm\CSS\Parsing\UnexpectedTokenException::class);
$sFile = __DIR__ . '/../fixtures/-end-token-2.css';
$oParser = new Parser(file_get_contents($sFile), Settings::create()->beStrict());
$oParser->parse();
Expand Down