Skip to content

Commit

Permalink
Update tests to work on PHP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmai committed Jan 6, 2021
1 parent db057d2 commit 8dbda5c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
28 changes: 12 additions & 16 deletions tests/USBScaleReader/ReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
}
}

0 comments on commit 8dbda5c

Please sign in to comment.