mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-09-15 12:16:25 +00:00
🚿 static calls to TestCase::assert*
This commit is contained in:
@@ -33,23 +33,23 @@ abstract class DatainterfaceTestAbstract extends QRTestAbstract{
|
||||
public function testInstance(){
|
||||
$this->dataInterface = $this->reflection->newInstanceArgs([new QROptions, $this->testdata]);
|
||||
|
||||
$this->assertInstanceOf(QRDataInterface::class, $this->dataInterface);
|
||||
$this::assertInstanceOf(QRDataInterface::class, $this->dataInterface);
|
||||
}
|
||||
|
||||
public function testSetData(){
|
||||
$this->dataInterface->setData($this->testdata);
|
||||
|
||||
$this->assertSame($this->expected, $this->getProperty('matrixdata')->getValue($this->dataInterface));
|
||||
$this::assertSame($this->expected, $this->getProperty('matrixdata')->getValue($this->dataInterface));
|
||||
}
|
||||
|
||||
public function testInitMatrix(){
|
||||
$m = $this->dataInterface->setData($this->testdata)->initMatrix(0);
|
||||
|
||||
$this->assertInstanceOf(QRMatrix::class, $m);
|
||||
$this::assertInstanceOf(QRMatrix::class, $m);
|
||||
}
|
||||
|
||||
public function testGetMinimumVersion(){
|
||||
$this->assertSame(1, $this->getMethod('getMinimumVersion')->invoke($this->dataInterface));
|
||||
$this::assertSame(1, $this->getMethod('getMinimumVersion')->invoke($this->dataInterface));
|
||||
}
|
||||
|
||||
public function testGetMinimumVersionException(){
|
||||
|
||||
@@ -23,7 +23,7 @@ class MaskPatternTesterTest extends QRTestAbstract{
|
||||
public function testMaskpattern(){
|
||||
$matrix = (new Byte(new QROptions(['version' => 10]), 'test'))->initMatrix(0, true);
|
||||
|
||||
$this->assertSame(6178, (new MaskPatternTester($matrix))->testPattern());
|
||||
$this::assertSame(6178, (new MaskPatternTester($matrix))->testPattern());
|
||||
}
|
||||
|
||||
|
||||
|
||||
+36
-36
@@ -46,56 +46,56 @@ class QRMatrixTest extends QRTestAbstract{
|
||||
}
|
||||
|
||||
public function testInstance(){
|
||||
$this->assertInstanceOf($this->FQCN, $this->matrix);
|
||||
$this::assertInstanceOf($this->FQCN, $this->matrix);
|
||||
}
|
||||
|
||||
public function testSize(){
|
||||
$this->assertCount($this->matrix->size(), $this->matrix->matrix());
|
||||
$this::assertCount($this->matrix->size(), $this->matrix->matrix());
|
||||
}
|
||||
|
||||
public function testVersion(){
|
||||
$this->assertSame($this->version, $this->matrix->version());
|
||||
$this::assertSame($this->version, $this->matrix->version());
|
||||
}
|
||||
|
||||
public function testECC(){
|
||||
$this->assertSame(QRCode::ECC_L, $this->matrix->eccLevel());
|
||||
$this::assertSame(QRCode::ECC_L, $this->matrix->eccLevel());
|
||||
}
|
||||
|
||||
public function testMaskPattern(){
|
||||
$this->assertSame(-1, $this->matrix->maskPattern());
|
||||
$this::assertSame(-1, $this->matrix->maskPattern());
|
||||
}
|
||||
|
||||
public function testGetSetCheck(){
|
||||
$this->matrix->set(10, 10, true, QRMatrix::M_TEST);
|
||||
$this->assertSame(65280, $this->matrix->get(10, 10));
|
||||
$this->assertTrue($this->matrix->check(10, 10));
|
||||
$this::assertSame(65280, $this->matrix->get(10, 10));
|
||||
$this::assertTrue($this->matrix->check(10, 10));
|
||||
|
||||
$this->matrix->set(20, 20, false, QRMatrix::M_TEST);
|
||||
$this->assertSame(255, $this->matrix->get(20, 20));
|
||||
$this->assertFalse($this->matrix->check(20, 20));
|
||||
$this::assertSame(255, $this->matrix->get(20, 20));
|
||||
$this::assertFalse($this->matrix->check(20, 20));
|
||||
}
|
||||
|
||||
public function testSetDarkModule(){
|
||||
$this->matrix->setDarkModule();
|
||||
|
||||
$this->assertSame(QRMatrix::M_DARKMODULE << 8, $this->matrix->get(8, $this->matrix->size() - 8));
|
||||
$this::assertSame(QRMatrix::M_DARKMODULE << 8, $this->matrix->get(8, $this->matrix->size() - 8));
|
||||
}
|
||||
|
||||
public function testSetFinderPattern(){
|
||||
$this->matrix->setFinderPattern();
|
||||
|
||||
$this->assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get(0, 0));
|
||||
$this->assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get(0, $this->matrix->size() - 1));
|
||||
$this->assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get($this->matrix->size() - 1, 0));
|
||||
$this::assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get(0, 0));
|
||||
$this::assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get(0, $this->matrix->size() - 1));
|
||||
$this::assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get($this->matrix->size() - 1, 0));
|
||||
}
|
||||
|
||||
public function testSetSeparators(){
|
||||
$this->matrix->setSeparators();
|
||||
|
||||
$this->assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get(7, 0));
|
||||
$this->assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get(0, 7));
|
||||
$this->assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get(0, $this->matrix->size() - 8));
|
||||
$this->assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get($this->matrix->size() - 8, 0));
|
||||
$this::assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get(7, 0));
|
||||
$this::assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get(0, 7));
|
||||
$this::assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get(0, $this->matrix->size() - 8));
|
||||
$this::assertSame(QRMatrix::M_SEPARATOR, $this->matrix->get($this->matrix->size() - 8, 0));
|
||||
}
|
||||
|
||||
public function testSetAlignmentPattern(){
|
||||
@@ -110,11 +110,11 @@ class QRMatrixTest extends QRTestAbstract{
|
||||
foreach($alignmentPattern as $px){
|
||||
|
||||
if($this->matrix->get($px, $py) === QRMatrix::M_FINDER << 8){
|
||||
$this->assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get($px, $py), 'skipped finder pattern');
|
||||
$this::assertSame(QRMatrix::M_FINDER << 8, $this->matrix->get($px, $py), 'skipped finder pattern');
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->assertSame(QRMatrix::M_ALIGNMENT << 8, $this->matrix->get($px, $py));
|
||||
$this::assertSame(QRMatrix::M_ALIGNMENT << 8, $this->matrix->get($px, $py));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,12 +133,12 @@ class QRMatrixTest extends QRTestAbstract{
|
||||
$p1 = $this->matrix->get(6, $i);
|
||||
|
||||
if($p1 === QRMatrix::M_ALIGNMENT << 8){
|
||||
$this->assertSame(QRMatrix::M_ALIGNMENT << 8, $p1, 'skipped alignment pattern');
|
||||
$this::assertSame(QRMatrix::M_ALIGNMENT << 8, $p1, 'skipped alignment pattern');
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->assertSame(QRMatrix::M_TIMING << 8, $p1);
|
||||
$this->assertSame(QRMatrix::M_TIMING << 8, $this->matrix->get($i, 6));
|
||||
$this::assertSame(QRMatrix::M_TIMING << 8, $p1);
|
||||
$this::assertSame(QRMatrix::M_TIMING << 8, $this->matrix->get($i, 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,19 +146,19 @@ class QRMatrixTest extends QRTestAbstract{
|
||||
public function testSetVersionNumber(){
|
||||
$this->matrix->setVersionNumber(true);
|
||||
|
||||
$this->assertSame(QRMatrix::M_VERSION, $this->matrix->get($this->matrix->size() - 9, 0));
|
||||
$this->assertSame(QRMatrix::M_VERSION, $this->matrix->get($this->matrix->size() - 11, 5));
|
||||
$this->assertSame(QRMatrix::M_VERSION, $this->matrix->get(0, $this->matrix->size() - 9));
|
||||
$this->assertSame(QRMatrix::M_VERSION, $this->matrix->get(5, $this->matrix->size() - 11));
|
||||
$this::assertSame(QRMatrix::M_VERSION, $this->matrix->get($this->matrix->size() - 9, 0));
|
||||
$this::assertSame(QRMatrix::M_VERSION, $this->matrix->get($this->matrix->size() - 11, 5));
|
||||
$this::assertSame(QRMatrix::M_VERSION, $this->matrix->get(0, $this->matrix->size() - 9));
|
||||
$this::assertSame(QRMatrix::M_VERSION, $this->matrix->get(5, $this->matrix->size() - 11));
|
||||
}
|
||||
|
||||
public function testSetFormatInfo(){
|
||||
$this->matrix->setFormatInfo(0, true);
|
||||
|
||||
$this->assertSame(QRMatrix::M_FORMAT, $this->matrix->get(8, 0));
|
||||
$this->assertSame(QRMatrix::M_FORMAT, $this->matrix->get(0, 8));
|
||||
$this->assertSame(QRMatrix::M_FORMAT, $this->matrix->get($this->matrix->size() - 1, 8));
|
||||
$this->assertSame(QRMatrix::M_FORMAT, $this->matrix->get($this->matrix->size() - 8, 8));
|
||||
$this::assertSame(QRMatrix::M_FORMAT, $this->matrix->get(8, 0));
|
||||
$this::assertSame(QRMatrix::M_FORMAT, $this->matrix->get(0, 8));
|
||||
$this::assertSame(QRMatrix::M_FORMAT, $this->matrix->get($this->matrix->size() - 1, 8));
|
||||
$this::assertSame(QRMatrix::M_FORMAT, $this->matrix->get($this->matrix->size() - 8, 8));
|
||||
}
|
||||
|
||||
public function testSetQuietZone(){
|
||||
@@ -170,15 +170,15 @@ class QRMatrixTest extends QRTestAbstract{
|
||||
|
||||
$this->matrix->setQuietZone($q);
|
||||
|
||||
$this->assertCount($size + 2 * $q, $this->matrix->matrix());
|
||||
$this->assertCount($size + 2 * $q, $this->matrix->matrix()[$size - 1]);
|
||||
$this::assertCount($size + 2 * $q, $this->matrix->matrix());
|
||||
$this::assertCount($size + 2 * $q, $this->matrix->matrix()[$size - 1]);
|
||||
|
||||
$size = $this->matrix->size();
|
||||
$this->assertSame(QRMatrix::M_QUIETZONE, $this->matrix->get(0, 0));
|
||||
$this->assertSame(QRMatrix::M_QUIETZONE, $this->matrix->get($size - 1, $size - 1));
|
||||
$this::assertSame(QRMatrix::M_QUIETZONE, $this->matrix->get(0, 0));
|
||||
$this::assertSame(QRMatrix::M_QUIETZONE, $this->matrix->get($size - 1, $size - 1));
|
||||
|
||||
$this->assertSame(QRMatrix::M_TEST << 8, $this->matrix->get($q, $q));
|
||||
$this->assertSame(QRMatrix::M_TEST << 8, $this->matrix->get($size - 1 - $q, $size - 1 - $q));
|
||||
$this::assertSame(QRMatrix::M_TEST << 8, $this->matrix->get($q, $q));
|
||||
$this::assertSame(QRMatrix::M_TEST << 8, $this->matrix->get($size - 1 - $q, $size - 1 - $q));
|
||||
}
|
||||
|
||||
public function testSetQuietZoneException(){
|
||||
|
||||
@@ -37,14 +37,14 @@ class BitBufferTest extends QRTestAbstract{
|
||||
*/
|
||||
public function testPut($data, $value){
|
||||
$this->bitBuffer->put($data, 4);
|
||||
$this->assertSame($value, $this->bitBuffer->buffer[0]);
|
||||
$this->assertSame(4, $this->bitBuffer->length);
|
||||
$this::assertSame($value, $this->bitBuffer->buffer[0]);
|
||||
$this::assertSame(4, $this->bitBuffer->length);
|
||||
}
|
||||
|
||||
public function testClear(){
|
||||
$this->bitBuffer->clear();
|
||||
$this->assertSame([], $this->bitBuffer->buffer);
|
||||
$this->assertSame(0, $this->bitBuffer->length);
|
||||
$this::assertSame([], $this->bitBuffer->buffer);
|
||||
$this::assertSame(0, $this->bitBuffer->length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ class PolynomialTest extends QRTestAbstract{
|
||||
}
|
||||
|
||||
public function testGexp(){
|
||||
$this->assertSame(142, $this->polynomial->gexp(-1));
|
||||
$this->assertSame(133, $this->polynomial->gexp(128));
|
||||
$this->assertSame(2, $this->polynomial->gexp(256));
|
||||
$this::assertSame(142, $this->polynomial->gexp(-1));
|
||||
$this::assertSame(133, $this->polynomial->gexp(128));
|
||||
$this::assertSame(2, $this->polynomial->gexp(256));
|
||||
}
|
||||
|
||||
public function testGlogException(){
|
||||
|
||||
@@ -42,7 +42,7 @@ class QRImageTest extends QROutputTestAbstract{
|
||||
$this->markAsRisky();
|
||||
}
|
||||
|
||||
$this->assertSame($img, file_get_contents($this::cachefile.$type));
|
||||
$this::assertSame($img, file_get_contents($this::cachefile.$type));
|
||||
}
|
||||
|
||||
public function testSetModuleValues(){
|
||||
@@ -55,7 +55,7 @@ class QRImageTest extends QROutputTestAbstract{
|
||||
|
||||
$this->setOutputInterface()->dump();
|
||||
|
||||
$this->assertTrue(true); // tricking the code coverage
|
||||
$this::assertTrue(true); // tricking the code coverage
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class QRImagickTest extends QROutputTestAbstract{
|
||||
$this->outputInterface->dump($this::cachefile.$type);
|
||||
$img = $this->outputInterface->dump();
|
||||
|
||||
$this->assertSame($img, file_get_contents($this::cachefile.$type));
|
||||
$this::assertSame($img, file_get_contents($this::cachefile.$type));
|
||||
}
|
||||
|
||||
public function testSetModuleValues(){
|
||||
@@ -49,7 +49,7 @@ class QRImagickTest extends QROutputTestAbstract{
|
||||
|
||||
$this->setOutputInterface()->dump();
|
||||
|
||||
$this->assertTrue(true); // tricking the code coverage
|
||||
$this::assertTrue(true); // tricking the code coverage
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class QRMarkupTest extends QROutputTestAbstract{
|
||||
$this->setOutputInterface();
|
||||
$data = $this->outputInterface->dump();
|
||||
|
||||
$this->assertSame($data, file_get_contents($this->options->cachefile));
|
||||
$this::assertSame($data, file_get_contents($this->options->cachefile));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ class QRMarkupTest extends QROutputTestAbstract{
|
||||
|
||||
$expected = implode($this->options->eol, $expected);
|
||||
|
||||
$this->assertSame(trim($expected), trim($this->outputInterface->dump()));
|
||||
$this::assertSame(trim($expected), trim($this->outputInterface->dump()));
|
||||
}
|
||||
|
||||
public function testSetModuleValues(){
|
||||
@@ -70,8 +70,8 @@ class QRMarkupTest extends QROutputTestAbstract{
|
||||
|
||||
$this->setOutputInterface();
|
||||
$data = $this->outputInterface->dump();
|
||||
$this->assertStringContainsString('#4A6000', $data);
|
||||
$this->assertStringContainsString('#ECF9BE', $data);
|
||||
$this::assertStringContainsString('#4A6000', $data);
|
||||
$this::assertStringContainsString('#ECF9BE', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ abstract class QROutputTestAbstract extends QRTestAbstract{
|
||||
}
|
||||
|
||||
public function testInstance(){
|
||||
$this->assertInstanceOf(QROutputInterface::class, $this->outputInterface);
|
||||
$this::assertInstanceOf(QROutputInterface::class, $this->outputInterface);
|
||||
}
|
||||
|
||||
public function testSaveException(){
|
||||
|
||||
@@ -35,7 +35,7 @@ class QRStringTest extends QROutputTestAbstract{
|
||||
$this->setOutputInterface();
|
||||
$data = $this->outputInterface->dump();
|
||||
|
||||
$this->assertSame($data, file_get_contents($this->options->cachefile));
|
||||
$this::assertSame($data, file_get_contents($this->options->cachefile));
|
||||
}
|
||||
|
||||
public function testSetModuleValues(){
|
||||
@@ -49,8 +49,8 @@ class QRStringTest extends QROutputTestAbstract{
|
||||
$this->setOutputInterface();
|
||||
$data = $this->outputInterface->dump();
|
||||
|
||||
$this->assertStringContainsString('A', $data);
|
||||
$this->assertStringContainsString('B', $data);
|
||||
$this::assertStringContainsString('A', $data);
|
||||
$this::assertStringContainsString('B', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-16
@@ -35,18 +35,18 @@ class QRCodeTest extends QRTestAbstract{
|
||||
}
|
||||
|
||||
public function testIsNumber(){
|
||||
$this->assertTrue($this->qrcode->isNumber('0123456789'));
|
||||
$this->assertFalse($this->qrcode->isNumber('ABC'));
|
||||
$this::assertTrue($this->qrcode->isNumber('0123456789'));
|
||||
$this::assertFalse($this->qrcode->isNumber('ABC'));
|
||||
}
|
||||
|
||||
public function testIsAlphaNum(){
|
||||
$this->assertTrue($this->qrcode->isAlphaNum('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:'));
|
||||
$this->assertFalse($this->qrcode->isAlphaNum('abc'));
|
||||
$this::assertTrue($this->qrcode->isAlphaNum('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:'));
|
||||
$this::assertFalse($this->qrcode->isAlphaNum('abc'));
|
||||
}
|
||||
|
||||
public function testIsKanji(){
|
||||
$this->assertTrue($this->qrcode->isKanji('茗荷'));
|
||||
$this->assertFalse($this->qrcode->isKanji('Ã'));
|
||||
$this::assertTrue($this->qrcode->isKanji('茗荷'));
|
||||
$this::assertFalse($this->qrcode->isKanji('Ã'));
|
||||
}
|
||||
|
||||
// coverage
|
||||
@@ -70,7 +70,7 @@ class QRCodeTest extends QRTestAbstract{
|
||||
public function testRenderImage($type, $expected){
|
||||
$this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['outputType' => $type])]);
|
||||
|
||||
$this->assertStringContainsString($expected, $this->qrcode->render('test'));
|
||||
$this::assertStringContainsString($expected, $this->qrcode->render('test'));
|
||||
}
|
||||
|
||||
public function testInitDataInterfaceException(){
|
||||
@@ -91,13 +91,13 @@ class QRCodeTest extends QRTestAbstract{
|
||||
$m1 = $this->qrcode->getMatrix('hello');
|
||||
$m2 = $this->qrcode->getMatrix('hello '); // added space
|
||||
|
||||
$this->assertNotEquals($m1, $m2);
|
||||
$this::assertNotEquals($m1, $m2);
|
||||
}
|
||||
|
||||
public function testImageTransparencyBGDefault(){
|
||||
$this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['imageTransparencyBG' => ['foo']])]);
|
||||
|
||||
$this->assertSame([255,255,255], $this->getProperty('options')->getValue($this->qrcode)->imageTransparencyBG);
|
||||
$this::assertSame([255,255,255], $this->getProperty('options')->getValue($this->qrcode)->imageTransparencyBG);
|
||||
}
|
||||
|
||||
public function testCustomOutput(){
|
||||
@@ -111,21 +111,21 @@ class QRCodeTest extends QRTestAbstract{
|
||||
|
||||
$expected = '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111110111010000101111010000011111110000000010000010111000001101011000001010000010000000010111010101101011000001101011010111010000000010111010110100111110010100111010111010000000010111010000001101011000001101010111010000000010000010100111110010100111110010000010000000011111110101010101010101010101011111110000000000000000010010100111110010100000000000000000011001110000101111010000101111001011110000000000000000111010000101111010000111100010000000001011010100111110010100111110011001010000000010000101111101011000001101011110011110000000000011010100011000001101011000101110100000000011001100001001101011000001101010011010000000010110111110000001101011000001100110100000000010000100100010100111110010100001100100000000011111110111101111010000101111010100110000000011010000111010000101111010000111100100000000010101111111111110010100111110011001000000000010110001110101011000001101011110011010000000001001111100011000001101011000101110010000000011000100110001101011000001101010011100000000001000011001000001101011000001100110000000000011101001011010100111110010100001100000000000010111010001101111010000101111010100110000000011100000001010000101111010000111100000000000000001110110111110010100111110011001000000000000011001011101011000001101011110011100000000011111110101011000001101011001111110110000000000000000110001101011000001101000111100000000011111110001000001101011000011010110000000000010000010101010100111110010101000100100000000010111010111101111010000101111111100110000000010111010011010000101111010001101100010000000010111010000111110010100111100101101100000000010000010101101011000001101001100111100000000011111110101011000001101011000110010110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';
|
||||
|
||||
$this->assertSame($expected, $this->reflection->newInstanceArgs([$options])->render('test'));
|
||||
$this::assertSame($expected, $this->reflection->newInstanceArgs([$options])->render('test'));
|
||||
}
|
||||
|
||||
public function testDataModeOverride(){
|
||||
$this->qrcode = $this->reflection->newInstance();
|
||||
|
||||
$this->assertInstanceOf(Number::class, $this->qrcode->initDataInterface('123'));
|
||||
$this->assertInstanceOf(AlphaNum::class, $this->qrcode->initDataInterface('ABC123'));
|
||||
$this->assertInstanceOf(Byte::class, $this->qrcode->initDataInterface(random_bytes(32)));
|
||||
$this::assertInstanceOf(Number::class, $this->qrcode->initDataInterface('123'));
|
||||
$this::assertInstanceOf(AlphaNum::class, $this->qrcode->initDataInterface('ABC123'));
|
||||
$this::assertInstanceOf(Byte::class, $this->qrcode->initDataInterface(random_bytes(32)));
|
||||
|
||||
$this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['dataMode' => 'Byte'])]);
|
||||
|
||||
$this->assertInstanceOf(Byte::class, $this->qrcode->initDataInterface('123'));
|
||||
$this->assertInstanceOf(Byte::class, $this->qrcode->initDataInterface('ABC123'));
|
||||
$this->assertInstanceOf(Byte::class, $this->qrcode->initDataInterface(random_bytes(32)));
|
||||
$this::assertInstanceOf(Byte::class, $this->qrcode->initDataInterface('123'));
|
||||
$this::assertInstanceOf(Byte::class, $this->qrcode->initDataInterface('ABC123'));
|
||||
$this::assertInstanceOf(Byte::class, $this->qrcode->initDataInterface(random_bytes(32)));
|
||||
}
|
||||
|
||||
public function testDataModeOverrideError(){
|
||||
|
||||
+18
-18
@@ -22,37 +22,37 @@ class QROptionsTest extends TestCase{
|
||||
protected SettingsContainerInterface $options;
|
||||
|
||||
public function testVersionClamp(){
|
||||
$this->assertSame(40, (new QROptions(['version' => 42]))->version);
|
||||
$this->assertSame(1, (new QROptions(['version' => -42]))->version);
|
||||
$this->assertSame(21, (new QROptions(['version' => 21]))->version);
|
||||
$this->assertSame(QRCode::VERSION_AUTO, (new QROptions)->version); // QRCode::VERSION_AUTO = -1, default
|
||||
$this::assertSame(40, (new QROptions(['version' => 42]))->version);
|
||||
$this::assertSame(1, (new QROptions(['version' => -42]))->version);
|
||||
$this::assertSame(21, (new QROptions(['version' => 21]))->version);
|
||||
$this::assertSame(QRCode::VERSION_AUTO, (new QROptions)->version); // QRCode::VERSION_AUTO = -1, default
|
||||
}
|
||||
|
||||
public function testVersionMinMaxClamp(){
|
||||
// normal clamp
|
||||
$o = new QROptions(['versionMin' => 5, 'versionMax' => 10]);
|
||||
$this->assertSame(5, $o->versionMin);
|
||||
$this->assertSame(10, $o->versionMax);
|
||||
$this::assertSame(5, $o->versionMin);
|
||||
$this::assertSame(10, $o->versionMax);
|
||||
|
||||
// exceeding values
|
||||
$o = new QROptions(['versionMin' => -42, 'versionMax' => 42]);
|
||||
$this->assertSame(1, $o->versionMin);
|
||||
$this->assertSame(40, $o->versionMax);
|
||||
$this::assertSame(1, $o->versionMin);
|
||||
$this::assertSame(40, $o->versionMax);
|
||||
|
||||
// min > max
|
||||
$o = new QROptions(['versionMin' => 10, 'versionMax' => 5]);
|
||||
$this->assertSame(5, $o->versionMin);
|
||||
$this->assertSame(10, $o->versionMax);
|
||||
$this::assertSame(5, $o->versionMin);
|
||||
$this::assertSame(10, $o->versionMax);
|
||||
|
||||
$o = new QROptions(['versionMin' => 42, 'versionMax' => -42]);
|
||||
$this->assertSame(1, $o->versionMin);
|
||||
$this->assertSame(40, $o->versionMax);
|
||||
$this::assertSame(1, $o->versionMin);
|
||||
$this::assertSame(40, $o->versionMax);
|
||||
}
|
||||
|
||||
public function testMaskPatternClamp(){
|
||||
$this->assertSame(7, (new QROptions(['maskPattern' => 42]))->maskPattern);
|
||||
$this->assertSame(0, (new QROptions(['maskPattern' => -42]))->maskPattern);
|
||||
$this->assertSame(QRCode::MASK_PATTERN_AUTO, (new QROptions)->maskPattern); // QRCode::MASK_PATTERN_AUTO = -1, default
|
||||
$this::assertSame(7, (new QROptions(['maskPattern' => 42]))->maskPattern);
|
||||
$this::assertSame(0, (new QROptions(['maskPattern' => -42]))->maskPattern);
|
||||
$this::assertSame(QRCode::MASK_PATTERN_AUTO, (new QROptions)->maskPattern); // QRCode::MASK_PATTERN_AUTO = -1, default
|
||||
}
|
||||
|
||||
public function testInvalidEccLevelException(){
|
||||
@@ -65,9 +65,9 @@ class QROptionsTest extends TestCase{
|
||||
public function testClampRGBValues(){
|
||||
$o = new QROptions(['imageTransparencyBG' => [-1, 0, 999]]);
|
||||
|
||||
$this->assertSame(0, $o->imageTransparencyBG[0]);
|
||||
$this->assertSame(0, $o->imageTransparencyBG[1]);
|
||||
$this->assertSame(255, $o->imageTransparencyBG[2]);
|
||||
$this::assertSame(0, $o->imageTransparencyBG[0]);
|
||||
$this::assertSame(0, $o->imageTransparencyBG[1]);
|
||||
$this::assertSame(255, $o->imageTransparencyBG[2]);
|
||||
}
|
||||
|
||||
public function testInvalidRGBValueException(){
|
||||
|
||||
Reference in New Issue
Block a user