🔥 v6.0 first pass: PHP 8.2, remove deprecated elements, add type hints

This commit is contained in:
smiley
2023-11-25 12:49:56 +01:00
parent a301af5b7f
commit 39e3dfe83b
80 changed files with 332 additions and 1029 deletions
+35
View File
@@ -12,6 +12,8 @@
namespace chillerlan\QRCodeTest;
use chillerlan\QRCode\Common\EccLevel;
use chillerlan\QRCode\QRCodeException;
use chillerlan\QRCode\QROptions;
use chillerlan\QRCode\Common\Version;
use PHPUnit\Framework\TestCase;
@@ -68,6 +70,39 @@ final class QROptionsTest extends TestCase{
$this::assertSame($expectedMax, $o->versionMax);
}
/**
* Tests setting the ECC level from string or int
*/
public function testSetEccLevel():void{
$o = new QROptions(['eccLevel' => EccLevel::H]);
$this::assertSame(EccLevel::H, $o->eccLevel);
$o->eccLevel = 'q';
$this::assertSame(EccLevel::Q, $o->eccLevel);
}
/**
* Tests if an exception is thrown when attempting to set an invalid ECC level integer
*/
public function testSetEccLevelFromIntException():void{
$this->expectException(QRCodeException::class);
$this->expectExceptionMessage('Invalid ECC level: "42"');
/** @phan-suppress-next-line PhanNoopNew */
new QROptions(['eccLevel' => 42]);
}
/**
* Tests if an exception is thrown when attempting to set an invalid ECC level string
*/
public function testSetEccLevelFromStringException():void{
$this->expectException(QRCodeException::class);
$this->expectExceptionMessage('Invalid ECC level: "FOO"');
/** @phan-suppress-next-line PhanNoopNew */
new QROptions(['eccLevel' => 'foo']);
}
/**
* @return int[][][]
*/