From 8dbda5ca159573b917eaa0e254d46d494e51f77b Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Wed, 6 Jan 2021 14:05:29 +0900 Subject: [PATCH] Update tests to work on PHP 8 --- .php_cs.dist | 1 + composer.json | 2 +- tests/USBScaleReader/ReaderTest.php | 28 ++++++++++++---------------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index cc209aa..ed2afb3 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -8,6 +8,7 @@ return PhpCsFixer\Config::create() ->setRiskyAllowed(true) ->setRules([ '@Symfony' => true, + '@PHPUnit84Migration:risky' => true, 'array_syntax' => ['syntax' => 'short'], 'declare_strict_types' => true, 'explicit_indirect_variable' => true, diff --git a/composer.json b/composer.json index fb844dc..f9ce1f0 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.13", - "phpunit/phpunit": "^6.5 || ^7.4" + "phpunit/phpunit": "^6.5 || ^7.4 || ^9" }, "autoload": { "psr-4": { diff --git a/tests/USBScaleReader/ReaderTest.php b/tests/USBScaleReader/ReaderTest.php index 46fe0a5..78651ab 100644 --- a/tests/USBScaleReader/ReaderTest.php +++ b/tests/USBScaleReader/ReaderTest.php @@ -49,40 +49,36 @@ public function testWeightInOunces() $this->assertEquals(221.126280375, $reader->getWeight()); } - /** - * @expectedException \USBScaleReader\Exception - * @expectedExceptionCode 1 - */ public function testInvalidStatus() { + $this->expectException(\USBScaleReader\Exception::class); + $this->expectExceptionCode(1); + $reader = $this->readerFromHex('03020bff0000'); } - /** - * @expectedException \USBScaleReader\Exception - * @expectedExceptionCode 1 - */ public function testNegativeWeight() { + $this->expectException(\USBScaleReader\Exception::class); + $this->expectExceptionCode(1); + $reader = $this->readerFromHex('03050bff0000'); } - /** - * @expectedException \USBScaleReader\Exception - * @expectedExceptionCode 2 - */ public function testUnknownUnit() { + $this->expectException(\USBScaleReader\Exception::class); + $this->expectExceptionCode(2); + $reader = $this->readerFromHex('030400009000'); $reader->getWeight(); } - /** - * @expectedException \USBScaleReader\Exception - * @expectedExceptionCode 3 - */ public function testUnreadableDevice() { + $this->expectException(\USBScaleReader\Exception::class); + $this->expectExceptionCode(3); + Reader::fromDevice(''); } }