mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-10-08 12:55:59 +00:00
🔥 v6.0 first pass: PHP 8.2, remove deprecated elements, add type hints
This commit is contained in:
@@ -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[][][]
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user