🛀 test overhaul

This commit is contained in:
smiley
2025-11-02 00:48:56 +01:00
parent b9d2059743
commit c99f5d4022
36 changed files with 356 additions and 333 deletions
+14 -19
View File
@@ -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');