🛀 extract Version

This commit is contained in:
codemasher
2020-11-22 00:47:13 +01:00
parent 1f1a363d9d
commit 6d8705b19b
5 changed files with 245 additions and 191 deletions
+4 -13
View File
@@ -12,6 +12,7 @@
namespace chillerlan\QRCodeTest\Data;
use chillerlan\QRCode\Common\Version;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
use chillerlan\QRCode\Data\{QRCodeDataException, QRMatrix};
@@ -43,7 +44,7 @@ final class QRMatrixTest extends TestCase{
* @internal
*/
protected function getMatrix(int $version):QRMatrix{
return new QRMatrix($version, QRCode::ECC_L);
return new QRMatrix(new Version($version), QRCode::ECC_L);
}
/**
@@ -53,16 +54,6 @@ final class QRMatrixTest extends TestCase{
$this::assertInstanceOf(QRMatrix::class, $this->matrix);
}
/**
* Tests if an exception is thrown when an invalid QR version was given
*/
public function testInvalidVersionException():void{
$this->expectException(QRCodeDataException::class);
$this->expectExceptionMessage('invalid QR Code version');
$this->matrix = new QRMatrix(42, 0);
}
/**
* Tests if an exception is thrown when an invalid ECC level was given
*/
@@ -70,7 +61,7 @@ final class QRMatrixTest extends TestCase{
$this->expectException(QRCodeDataException::class);
$this->expectExceptionMessage('invalid ecc level');
$this->matrix = new QRMatrix(1, 42);
$this->matrix = new QRMatrix(new Version(1), 42);
}
/**
@@ -190,7 +181,7 @@ final class QRMatrixTest extends TestCase{
->setAlignmentPattern()
;
$alignmentPattern = (new ReflectionClass(QRMatrix::class))->getConstant('alignmentPattern')[$version];
$alignmentPattern = Version::ALIGNMENT_PATTERN[$version];
foreach($alignmentPattern as $py){
foreach($alignmentPattern as $px){