mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-10-09 05:15:49 +00:00
🛀 test overhaul
This commit is contained in:
+14
-19
@@ -13,7 +13,7 @@ namespace chillerlan\QRCodeTest\Common;
|
||||
|
||||
use chillerlan\QRCode\QRCodeException;
|
||||
use chillerlan\QRCode\Common\Mode;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\{Test, TestWith};
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
@@ -22,34 +22,29 @@ use PHPUnit\Framework\TestCase;
|
||||
final class ModeTest extends TestCase{
|
||||
|
||||
/**
|
||||
* version breakpoints for numeric mode
|
||||
*
|
||||
* @phpstan-return array<int, array{0: int, 1: int}>
|
||||
* Tests the version breakpoints for numeric mode
|
||||
*/
|
||||
public static function versionProvider():array{
|
||||
return [
|
||||
[ 1, 10],
|
||||
[ 9, 10],
|
||||
[10, 12],
|
||||
[26, 12],
|
||||
[27, 14],
|
||||
[40, 14],
|
||||
];
|
||||
}
|
||||
|
||||
#[DataProvider('versionProvider')]
|
||||
public function testGetLengthBitsForVersionBreakpoints(int $version, int $expected):void{
|
||||
#[Test]
|
||||
#[TestWith([ 1, 10], '10 low')]
|
||||
#[TestWith([ 9, 10], '10 high')]
|
||||
#[TestWith([10, 12], '12 low')]
|
||||
#[TestWith([26, 12], '12 high')]
|
||||
#[TestWith([27, 14], '14 low')]
|
||||
#[TestWith([40, 14], '14 high')]
|
||||
public function getLengthBitsForVersionBreakpoints(int $version, int $expected):void{
|
||||
$this::assertSame($expected, Mode::getLengthBitsForVersion(Mode::NUMBER, $version));
|
||||
}
|
||||
|
||||
public function testGetLengthBitsForVersionInvalidModeException():void{
|
||||
#[Test]
|
||||
public function getLengthBitsForVersionInvalidModeException():void{
|
||||
$this->expectException(QRCodeException::class);
|
||||
$this->expectExceptionMessage('invalid mode given');
|
||||
|
||||
Mode::getLengthBitsForVersion(42, 69);
|
||||
}
|
||||
|
||||
public function testGetLengthBitsForVersionInvalidVersionException():void{
|
||||
#[Test]
|
||||
public function getLengthBitsForVersionInvalidVersionException():void{
|
||||
$this->expectException(QRCodeException::class);
|
||||
$this->expectExceptionMessage('invalid version number');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user