From 2af55800abfd0b1300f2f40fd1fc7057544dbc8d Mon Sep 17 00:00:00 2001 From: Cody Finegan Date: Thu, 21 Jul 2022 15:48:23 +1200 Subject: [PATCH] Upgrading to PHPUnit 9 --- composer.json | 4 ++-- phpunit.xml | 26 +++++++++++------------- tests/CSSList/DocumentTest.php | 2 +- tests/OutputFormatTest.php | 5 +++-- tests/ParserTest.php | 30 ++++++++++++++++++---------- tests/RuleSet/LenientParsingTest.php | 9 ++++++--- 6 files changed, 44 insertions(+), 32 deletions(-) diff --git a/composer.json b/composer.json index e192dd56a..c883f5edb 100644 --- a/composer.json +++ b/composer.json @@ -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" diff --git a/phpunit.xml b/phpunit.xml index 5f3dd4588..6b5ee82f9 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,15 +1,13 @@ - - - - tests - - - - - - src - - + + + + + src + + + + + tests + + diff --git a/tests/CSSList/DocumentTest.php b/tests/CSSList/DocumentTest.php index d43a33bef..f12403f48 100644 --- a/tests/CSSList/DocumentTest.php +++ b/tests/CSSList/DocumentTest.php @@ -17,7 +17,7 @@ class DocumentTest extends TestCase */ private $subject; - protected function setUp() + protected function setUp(): void { $this->subject = new Document(); } diff --git a/tests/OutputFormatTest.php b/tests/OutputFormatTest.php index 9e0d4c4e4..40c92f784 100644 --- a/tests/OutputFormatTest.php +++ b/tests/OutputFormatTest.php @@ -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(); @@ -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'); diff --git a/tests/ParserTest.php b/tests/ParserTest.php index d4c320030..bd6d001a8 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -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]; @@ -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)); } @@ -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)); } @@ -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(); @@ -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()); } @@ -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()); } diff --git a/tests/RuleSet/LenientParsingTest.php b/tests/RuleSet/LenientParsingTest.php index 65218db4f..a1e88acc5 100644 --- a/tests/RuleSet/LenientParsingTest.php +++ b/tests/RuleSet/LenientParsingTest.php @@ -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(); @@ -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();