summaryrefslogtreecommitdiff
path: root/vendor/chillerlan/php-qrcode/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/chillerlan/php-qrcode/tests')
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Data/AlphaNumTest.php44
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Data/ByteTest.php38
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Data/DatainterfaceTestAbstract.php65
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Data/KanjiTest.php50
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Data/MaskPatternTesterTest.php29
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Data/NumberTest.php44
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Data/QRMatrixTest.php260
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Helpers/BitBufferTest.php53
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Helpers/PolynomialTest.php42
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Output/QRFpdfTest.php83
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Output/QRImageTest.php69
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Output/QRImagickTest.php66
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Output/QRMarkupTest.php79
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Output/QROutputTestAbstract.php71
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Output/QRStringTest.php56
-rw-r--r--vendor/chillerlan/php-qrcode/tests/QRCodeTest.php140
-rw-r--r--vendor/chillerlan/php-qrcode/tests/QROptionsTest.php80
-rw-r--r--vendor/chillerlan/php-qrcode/tests/QRTestAbstract.php72
18 files changed, 1341 insertions, 0 deletions
diff --git a/vendor/chillerlan/php-qrcode/tests/Data/AlphaNumTest.php b/vendor/chillerlan/php-qrcode/tests/Data/AlphaNumTest.php
new file mode 100644
index 000000000..c29b1f639
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Data/AlphaNumTest.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Class AlphaNumTest
+ *
+ * @filesource AlphaNumTest.php
+ * @created 24.11.2017
+ * @package chillerlan\QRCodeTest\Data
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Data;
+
+use chillerlan\QRCode\Data\{AlphaNum, QRCodeDataException};
+
+class AlphaNumTest extends DatainterfaceTestAbstract{
+
+ protected $FQCN = AlphaNum::class;
+ protected $testdata = '0 $%*+-./:';
+ protected $expected = [
+ 32, 80, 36, 212, 252, 15, 175, 251,
+ 176, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 112, 43, 9, 248, 200, 194, 75, 25,
+ 205, 173, 154, 68, 191, 16, 128,
+ 92, 112, 20, 198, 27
+ ];
+
+ public function testGetCharCodeException(){
+ $this->expectException(QRCodeDataException::class);
+ $this->expectExceptionMessage('illegal char: "#" [35]');
+
+ $this->dataInterface->setData('#');
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Data/ByteTest.php b/vendor/chillerlan/php-qrcode/tests/Data/ByteTest.php
new file mode 100644
index 000000000..cbfe1fab2
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Data/ByteTest.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Class ByteTest
+ *
+ * @filesource ByteTest.php
+ * @created 24.11.2017
+ * @package chillerlan\QRCodeTest\Data
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Data;
+
+use chillerlan\QRCode\Data\Byte;
+
+class ByteTest extends DatainterfaceTestAbstract{
+
+ protected $FQCN = Byte::class;
+ protected $testdata = '[¯\_(ツ)_/¯]';
+ protected $expected = [
+ 64, 245, 188, 42, 245, 197, 242, 142,
+ 56, 56, 66, 149, 242, 252, 42, 245,
+ 208, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 79, 89, 226, 48, 209, 89, 151, 1,
+ 12, 73, 42, 163, 11, 34, 255, 205,
+ 21, 47, 250, 101
+ ];
+
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Data/DatainterfaceTestAbstract.php b/vendor/chillerlan/php-qrcode/tests/Data/DatainterfaceTestAbstract.php
new file mode 100644
index 000000000..19d74617a
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Data/DatainterfaceTestAbstract.php
@@ -0,0 +1,65 @@
+<?php
+/**
+ * Class DatainterfaceTestAbstract
+ *
+ * @filesource DatainterfaceTestAbstract.php
+ * @created 24.11.2017
+ * @package chillerlan\QRCodeTest\Data
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Data;
+
+use chillerlan\QRCode\QROptions;
+use chillerlan\QRCode\Data\{QRCodeDataException, QRDataInterface, QRMatrix};
+use chillerlan\QRCodeTest\QRTestAbstract;
+
+abstract class DatainterfaceTestAbstract extends QRTestAbstract{
+
+ /**
+ * @var \chillerlan\QRCode\Data\QRDataAbstract
+ */
+ protected $dataInterface;
+
+ protected $testdata;
+ protected $expected;
+
+ protected function setUp():void{
+ parent::setUp();
+
+ $this->dataInterface = $this->reflection->newInstanceArgs([new QROptions(['version' => 4])]);
+ }
+
+ public function testInstance(){
+ $this->dataInterface = $this->reflection->newInstanceArgs([new QROptions, $this->testdata]);
+
+ $this->assertInstanceOf(QRDataInterface::class, $this->dataInterface);
+ }
+
+ public function testSetData(){
+ $this->dataInterface->setData($this->testdata);
+
+ $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);
+ }
+
+ public function testGetMinimumVersion(){
+ $this->assertSame(1, $this->getMethod('getMinimumVersion')->invoke($this->dataInterface));
+ }
+
+ public function testGetMinimumVersionException(){
+ $this->expectException(QRCodeDataException::class);
+ $this->expectExceptionMessage('data exceeds');
+
+ $this->getProperty('strlen')->setValue($this->dataInterface, 13370);
+ $this->getMethod('getMinimumVersion')->invoke($this->dataInterface);
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Data/KanjiTest.php b/vendor/chillerlan/php-qrcode/tests/Data/KanjiTest.php
new file mode 100644
index 000000000..108b8fed7
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Data/KanjiTest.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Class KanjiTest
+ *
+ * @filesource KanjiTest.php
+ * @created 24.11.2017
+ * @package chillerlan\QRCodeTest\Data
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Data;
+
+use chillerlan\QRCode\Data\{Kanji, QRCodeDataException};
+
+class KanjiTest extends DatainterfaceTestAbstract{
+
+ protected $FQCN = Kanji::class;
+ protected $testdata = '茗荷茗荷茗荷茗荷茗荷';
+ protected $expected = [
+ 128, 173, 85, 26, 95, 85, 70, 151,
+ 213, 81, 165, 245, 84, 105, 125, 85,
+ 26, 92, 0, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 195, 11, 221, 91, 141, 220, 163, 46,
+ 165, 37, 163, 176, 79, 0, 64, 68,
+ 96, 113, 54, 191
+ ];
+
+ public function testIllegalCharException1(){
+ $this->expectException(QRCodeDataException::class);
+ $this->expectExceptionMessage('illegal char at 1 [16191]');
+
+ $this->dataInterface->setData('ÃÃ');
+ }
+
+ public function testIllegalCharException2(){
+ $this->expectException(QRCodeDataException::class);
+ $this->expectExceptionMessage('illegal char at 1');
+
+ $this->dataInterface->setData('Ã');
+ }
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Data/MaskPatternTesterTest.php b/vendor/chillerlan/php-qrcode/tests/Data/MaskPatternTesterTest.php
new file mode 100644
index 000000000..ae4af9f29
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Data/MaskPatternTesterTest.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Class MaskPatternTesterTest
+ *
+ * @filesource MaskPatternTesterTest.php
+ * @created 24.11.2017
+ * @package chillerlan\QRCodeTest\Data
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Data;
+
+use chillerlan\QRCode\{QROptions, Data\Byte, Data\MaskPatternTester};
+use chillerlan\QRCodeTest\QRTestAbstract;
+
+class MaskPatternTesterTest extends QRTestAbstract{
+
+ protected $FQCN = MaskPatternTester::class;
+
+ // coverage
+ public function testMaskpattern(){
+ $matrix = (new Byte(new QROptions(['version' => 10]), 'test'))->initMatrix(3, true);
+
+ $this->assertSame(4243, (new MaskPatternTester($matrix))->testPattern());
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Data/NumberTest.php b/vendor/chillerlan/php-qrcode/tests/Data/NumberTest.php
new file mode 100644
index 000000000..983346a34
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Data/NumberTest.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Class NumberTest
+ *
+ * @filesource NumberTest.php
+ * @created 24.11.2017
+ * @package chillerlan\QRCodeTest\Data
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Data;
+
+use chillerlan\QRCode\Data\{Number, QRCodeDataException};
+
+class NumberTest extends DatainterfaceTestAbstract{
+
+ protected $FQCN = Number::class;
+ protected $testdata = '0123456789';
+ protected $expected = [
+ 16, 40, 12, 86, 106, 105, 0, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 17, 236, 17, 236, 17, 236, 17, 236,
+ 201, 141, 102, 116, 238, 162, 239, 230,
+ 222, 37, 79, 192, 42, 109, 188, 72,
+ 89, 63, 168, 151
+ ];
+
+ public function testGetCharCodeException(){
+ $this->expectException(QRCodeDataException::class);
+ $this->expectExceptionMessage('illegal char: "#" [35]');
+
+ $this->dataInterface->setData('#');
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Data/QRMatrixTest.php b/vendor/chillerlan/php-qrcode/tests/Data/QRMatrixTest.php
new file mode 100644
index 000000000..531c82eb2
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Data/QRMatrixTest.php
@@ -0,0 +1,260 @@
+<?php
+/**
+ * Class QRMatrixTest
+ *
+ * @filesource QRMatrixTest.php
+ * @created 17.11.2017
+ * @package chillerlan\QRCodeTest\Data
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Data;
+
+use chillerlan\QRCode\QRCode;
+use chillerlan\QRCode\QROptions;
+use chillerlan\QRCode\Data\{QRCodeDataException, QRMatrix};
+use chillerlan\QRCodeTest\QRTestAbstract;
+use ReflectionClass;
+
+class QRMatrixTest extends QRTestAbstract{
+
+ protected $FQCN = QRMatrix::class;
+
+ protected $version = 7;
+
+ /**
+ * @var \chillerlan\QRCode\Data\QRMatrix
+ */
+ protected $matrix;
+
+ protected function setUp():void{
+ parent::setUp();
+
+ $this->matrix = $this->reflection->newInstanceArgs([$this->version, QRCode::ECC_L]);
+ }
+
+ public function testInvalidVersionException(){
+ $this->expectException(QRCodeDataException::class);
+ $this->expectExceptionMessage('invalid QR Code version');
+
+ $this->reflection->newInstanceArgs([42, 0]);
+ }
+
+ public function testInvalidEccException(){
+ $this->expectException(QRCodeDataException::class);
+ $this->expectExceptionMessage('invalid ecc level');
+
+ $this->reflection->newInstanceArgs([1, 42]);
+ }
+
+ public function testInstance(){
+ $this->assertInstanceOf($this->FQCN, $this->matrix);
+ }
+
+ public function testSize(){
+ $this->assertCount($this->matrix->size(), $this->matrix->matrix());
+ }
+
+ public function testVersion(){
+ $this->assertSame($this->version, $this->matrix->version());
+ }
+
+ public function testECC(){
+ $this->assertSame(QRCode::ECC_L, $this->matrix->eccLevel());
+ }
+
+ public function testMaskPattern(){
+ $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->matrix->set(20, 20, false, QRMatrix::M_TEST);
+ $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));
+ }
+
+ 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));
+ }
+
+ 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));
+ }
+
+ public function testSetAlignmentPattern(){
+ $this->matrix
+ ->setFinderPattern()
+ ->setAlignmentPattern()
+ ;
+
+ $alignmentPattern = (new ReflectionClass(QRMatrix::class))->getConstant('alignmentPattern')[$this->version];
+
+ foreach($alignmentPattern as $py){
+ 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');
+ continue;
+ }
+
+ $this->assertSame(QRMatrix::M_ALIGNMENT << 8, $this->matrix->get($px, $py));
+ }
+ }
+
+ }
+
+ public function testSetTimingPattern(){
+ $this->matrix
+ ->setAlignmentPattern()
+ ->setTimingPattern()
+ ;
+
+ $size = $this->matrix->size();
+
+ for($i = 7; $i < $size - 7; $i++){
+ if($i % 2 === 0){
+ $p1 = $this->matrix->get(6, $i);
+
+ if($p1 === QRMatrix::M_ALIGNMENT << 8){
+ $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));
+ }
+ }
+ }
+
+ 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));
+ }
+
+ 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));
+ }
+
+ public function testSetQuietZone(){
+ $size = $this->matrix->size();
+ $q = 5;
+
+ $this->matrix->set(0, 0, true, QRMatrix::M_TEST);
+ $this->matrix->set($size - 1, $size - 1, true, QRMatrix::M_TEST);
+
+ $this->matrix->setQuietZone($q);
+
+ $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_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(){
+ $this->expectException(QRCodeDataException::class);
+ $this->expectExceptionMessage('use only after writing data');
+
+ $this->matrix->setQuietZone();
+ }
+
+ public function testSetLogoSpaceOrientation():void{
+ $o = new QROptions;
+ $o->version = 10;
+ $o->eccLevel = QRCode::ECC_H;
+ $o->addQuietzone = false;
+
+ $matrix = (new QRCode($o))->getMatrix('testdata');
+ // also testing size adjustment to uneven numbers
+ $matrix->setLogoSpace(20, 14);
+
+ // NW corner
+ $this::assertNotSame(QRMatrix::M_LOGO, $matrix->get(17, 20));
+ $this::assertSame(QRMatrix::M_LOGO, $matrix->get(18, 21));
+
+ // SE corner
+ $this::assertSame(QRMatrix::M_LOGO, $matrix->get(38, 35));
+ $this::assertNotSame(QRMatrix::M_LOGO, $matrix->get(39, 36));
+ }
+
+ public function testSetLogoSpacePosition():void{
+ $o = new QROptions;
+ $o->version = 10;
+ $o->eccLevel = QRCode::ECC_H;
+ $o->addQuietzone = true;
+ $o->quietzoneSize = 10;
+
+ $m = (new QRCode($o))->getMatrix('testdata');
+
+ // logo space should not overwrite quiet zone & function patterns
+ $m->setLogoSpace(21, 21, -10, -10);
+ $this::assertSame(QRMatrix::M_QUIETZONE, $m->get(9, 9));
+ $this::assertSame(QRMatrix::M_FINDER << 8, $m->get(10, 10));
+ $this::assertSame(QRMatrix::M_FINDER << 8, $m->get(16, 16));
+ $this::assertSame(QRMatrix::M_SEPARATOR, $m->get(17, 17));
+ $this::assertSame(QRMatrix::M_FORMAT << 8, $m->get(18, 18));
+ $this::assertSame(QRMatrix::M_LOGO, $m->get(19, 19));
+ $this::assertSame(QRMatrix::M_LOGO, $m->get(20, 20));
+ $this::assertNotSame(QRMatrix::M_LOGO, $m->get(21, 21));
+
+ // i just realized that setLogoSpace() could be called multiple times
+ // on the same instance and i'm not going to do anything about it :P
+ $m->setLogoSpace(21, 21, 45, 45);
+ $this::assertNotSame(QRMatrix::M_LOGO, $m->get(54, 54));
+ $this::assertSame(QRMatrix::M_LOGO, $m->get(55, 55));
+ $this::assertSame(QRMatrix::M_QUIETZONE, $m->get(67, 67));
+ }
+
+ public function testSetLogoSpaceInvalidEccException():void{
+ $this->expectException(QRCodeDataException::class);
+ $this->expectExceptionMessage('ECC level "H" required to add logo space');
+
+ (new QRCode)->getMatrix('testdata')->setLogoSpace(50, 50);
+ }
+
+ public function testSetLogoSpaceMaxSizeException():void{
+ $this->expectException(QRCodeDataException::class);
+ $this->expectExceptionMessage('logo space exceeds the maximum error correction capacity');
+
+ $o = new QROptions;
+ $o->version = 5;
+ $o->eccLevel = QRCode::ECC_H;
+
+ (new QRCode($o))->getMatrix('testdata')->setLogoSpace(50, 50);
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Helpers/BitBufferTest.php b/vendor/chillerlan/php-qrcode/tests/Helpers/BitBufferTest.php
new file mode 100644
index 000000000..25d1c3504
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Helpers/BitBufferTest.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Class BitBufferTest
+ *
+ * @filesource BitBufferTest.php
+ * @created 08.02.2016
+ * @package chillerlan\QRCodeTest\Helpers
+ * @author Smiley <[email protected]>
+ * @copyright 2015 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Helpers;
+
+use chillerlan\QRCode\{QRCode, Helpers\BitBuffer};
+use chillerlan\QRCodeTest\QRTestAbstract;
+
+class BitBufferTest extends QRTestAbstract{
+
+ /**
+ * @var \chillerlan\QRCode\Helpers\BitBuffer
+ */
+ protected $bitBuffer;
+
+ protected function setUp():void{
+ $this->bitBuffer = new BitBuffer;
+ }
+
+ public function bitProvider(){
+ return [
+ 'number' => [QRCode::DATA_NUMBER, 16],
+ 'alphanum' => [QRCode::DATA_ALPHANUM, 32],
+ 'byte' => [QRCode::DATA_BYTE, 64],
+ 'kanji' => [QRCode::DATA_KANJI, 128],
+ ];
+ }
+
+ /**
+ * @dataProvider bitProvider
+ */
+ public function testPut($data, $value){
+ $this->bitBuffer->put($data, 4);
+ $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);
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Helpers/PolynomialTest.php b/vendor/chillerlan/php-qrcode/tests/Helpers/PolynomialTest.php
new file mode 100644
index 000000000..7f6da303c
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Helpers/PolynomialTest.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Class PolynomialTest
+ *
+ * @filesource PolynomialTest.php
+ * @created 09.02.2016
+ * @package chillerlan\QRCodeTest\Helpers
+ * @author Smiley <[email protected]>
+ * @copyright 2015 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Helpers;
+
+use chillerlan\QRCode\Helpers\Polynomial;
+use chillerlan\QRCode\QRCodeException;
+use chillerlan\QRCodeTest\QRTestAbstract;
+
+class PolynomialTest extends QRTestAbstract{
+
+ /**
+ * @var \chillerlan\QRCode\Helpers\Polynomial
+ */
+ protected $polynomial;
+
+ protected function setUp():void{
+ $this->polynomial = new Polynomial;
+ }
+
+ public function testGexp(){
+ $this->assertSame(142, $this->polynomial->gexp(-1));
+ $this->assertSame(133, $this->polynomial->gexp(128));
+ $this->assertSame(2, $this->polynomial->gexp(256));
+ }
+
+ public function testGlogException(){
+ $this->expectException(QRCodeException::class);
+ $this->expectExceptionMessage('log(0)');
+
+ $this->polynomial->glog(0);
+ }
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Output/QRFpdfTest.php b/vendor/chillerlan/php-qrcode/tests/Output/QRFpdfTest.php
new file mode 100644
index 000000000..1b49182d2
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Output/QRFpdfTest.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Class QRFpdfTest
+ *
+ * @filesource QRFpdfTest.php
+ * @created 03.06.2020
+ * @package chillerlan\QRCodeTest\Output
+ * @author smiley <[email protected]>
+ * @copyright 2020 smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Output;
+
+use FPDF;
+use chillerlan\QRCode\Output\{QRFpdf, QROutputInterface};
+use chillerlan\QRCode\{QRCode, QROptions};
+
+use function class_exists, substr;
+
+/**
+ * Tests the QRFpdf output module
+ */
+class QRFpdfTest extends QROutputTestAbstract{
+
+ protected $FQCN = QRFpdf::class;
+
+ /**
+ * @inheritDoc
+ * @internal
+ */
+ public function setUp():void{
+
+ if(!class_exists(FPDF::class)){
+ $this->markTestSkipped('FPDF not available');
+ return;
+ }
+
+ parent::setUp();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function testSetModuleValues():void{
+
+ $this->options->moduleValues = [
+ // data
+ 1024 => [0, 0, 0],
+ 4 => [255, 255, 255],
+ ];
+
+ $this->outputInterface->dump();
+
+ $this::assertTrue(true); // tricking the code coverage
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function testRenderImage():void{
+ $type = QRCode::OUTPUT_FPDF;
+
+ $this->options->outputType = $type;
+ $this->options->imageBase64 = false;
+ $this->outputInterface->dump($this::cachefile.$type);
+
+ // substr() to avoid CreationDate
+ $expected = substr(file_get_contents($this::cachefile.$type), 0, 2000);
+ $actual = substr($this->outputInterface->dump(), 0, 2000);
+
+ $this::assertSame($expected, $actual);
+ }
+
+ public function testOutputGetResource():void{
+ $this->options->returnResource = true;
+
+ $this->setOutputInterface();
+
+ $this::assertInstanceOf(FPDF::class, $this->outputInterface->dump());
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Output/QRImageTest.php b/vendor/chillerlan/php-qrcode/tests/Output/QRImageTest.php
new file mode 100644
index 000000000..34ecf4f91
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Output/QRImageTest.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Class QRImageTest
+ *
+ * @filesource QRImageTest.php
+ * @created 24.12.2017
+ * @package chillerlan\QRCodeTest\Output
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Output;
+
+use chillerlan\QRCode\{QRCode, Output\QRImage};
+
+class QRImageTest extends QROutputTestAbstract{
+
+ protected $FQCN = QRImage::class;
+
+ public function types(){
+ return [
+ 'png' => [QRCode::OUTPUT_IMAGE_PNG],
+ 'gif' => [QRCode::OUTPUT_IMAGE_GIF],
+ 'jpg' => [QRCode::OUTPUT_IMAGE_JPG],
+ ];
+ }
+
+ /**
+ * @dataProvider types
+ * @param $type
+ */
+ public function testImageOutput($type){
+ $this->options->outputType = $type;
+ $this->options->imageBase64 = false;
+
+ $this->setOutputInterface();
+ $this->outputInterface->dump($this::cachefile.$type);
+ $img = $this->outputInterface->dump();
+
+ if($type === QRCode::OUTPUT_IMAGE_JPG){ // jpeg encoding may cause different results
+ $this->markAsRisky();
+ }
+
+ $this->assertSame($img, file_get_contents($this::cachefile.$type));
+ }
+
+ public function testSetModuleValues(){
+
+ $this->options->moduleValues = [
+ // data
+ 1024 => [0, 0, 0],
+ 4 => [255, 255, 255],
+ ];
+
+ $this->setOutputInterface()->dump();
+
+ $this->assertTrue(true); // tricking the code coverage
+ }
+
+ public function testOutputGetResource():void{
+ $this->options->returnResource = true;
+
+ $this->setOutputInterface();
+
+ $this::assertIsResource($this->outputInterface->dump());
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Output/QRImagickTest.php b/vendor/chillerlan/php-qrcode/tests/Output/QRImagickTest.php
new file mode 100644
index 000000000..c927cc64e
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Output/QRImagickTest.php
@@ -0,0 +1,66 @@
+<?php
+/**
+ * Class QRImagickTest
+ *
+ * @filesource QRImagickTest.php
+ * @created 04.07.2018
+ * @package chillerlan\QRCodeTest\Output
+ * @author smiley <[email protected]>
+ * @copyright 2018 smiley
+ * @license MIT
+ *
+ * @noinspection PhpComposerExtensionStubsInspection
+ */
+
+namespace chillerlan\QRCodeTest\Output;
+
+use Imagick;
+use chillerlan\QRCode\{QRCode, Output\QRImagick};
+
+class QRImagickTest extends QROutputTestAbstract{
+
+ protected $FQCN = QRImagick::class;
+
+ public function setUp():void{
+
+ if(!extension_loaded('imagick')){
+ $this->markTestSkipped('ext-imagick not loaded');
+ return;
+ }
+
+ parent::setUp();
+ }
+
+ public function testImageOutput(){
+ $type = QRCode::OUTPUT_IMAGICK;
+
+ $this->options->outputType = $type;
+ $this->setOutputInterface();
+ $this->outputInterface->dump($this::cachefile.$type);
+ $img = $this->outputInterface->dump();
+
+ $this->assertSame($img, file_get_contents($this::cachefile.$type));
+ }
+
+ public function testSetModuleValues(){
+
+ $this->options->moduleValues = [
+ // data
+ 1024 => '#4A6000',
+ 4 => '#ECF9BE',
+ ];
+
+ $this->setOutputInterface()->dump();
+
+ $this->assertTrue(true); // tricking the code coverage
+ }
+
+ public function testOutputGetResource():void{
+ $this->options->returnResource = true;
+
+ $this->setOutputInterface();
+
+ $this::assertInstanceOf(Imagick::class, $this->outputInterface->dump());
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Output/QRMarkupTest.php b/vendor/chillerlan/php-qrcode/tests/Output/QRMarkupTest.php
new file mode 100644
index 000000000..24fdc3ce6
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Output/QRMarkupTest.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Class QRMarkupTest
+ *
+ * @filesource QRMarkupTest.php
+ * @created 24.12.2017
+ * @package chillerlan\QRCodeTest\Output
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Output;
+
+use chillerlan\QRCode\{QRCode, Output\QRMarkup};
+
+class QRMarkupTest extends QROutputTestAbstract{
+
+ protected $FQCN = QRMarkup::class;
+
+ public function types(){
+ return [
+ 'html' => [QRCode::OUTPUT_MARKUP_HTML],
+ 'svg' => [QRCode::OUTPUT_MARKUP_SVG],
+ ];
+ }
+
+ /**
+ * @dataProvider types
+ * @param $type
+ */
+ public function testMarkupOutputFile($type){
+ $this->options->outputType = $type;
+ $this->options->cachefile = $this::cachefile.$type;
+ $this->setOutputInterface();
+ $data = $this->outputInterface->dump();
+
+ $this->assertSame($data, file_get_contents($this->options->cachefile));
+ }
+
+ /**
+ * @dataProvider types
+ * @param $type
+ */
+ public function testMarkupOutput($type){
+ $this->options->imageBase64 = false;
+ $this->options->outputType = $type;
+ $this->setOutputInterface();
+
+ $expected = explode($this->options->eol, file_get_contents($this::cachefile.$type));
+ // cut off the doctype & head
+ array_shift($expected);
+
+ if($type === QRCode::OUTPUT_MARKUP_HTML){
+ // cut off the </body> tag
+ array_pop($expected);
+ }
+
+ $expected = implode($this->options->eol, $expected);
+
+ $this->assertSame(trim($expected), trim($this->outputInterface->dump()));
+ }
+
+ public function testSetModuleValues(){
+
+ $this->options->imageBase64 = false;
+ $this->options->moduleValues = [
+ // data
+ 1024 => '#4A6000',
+ 4 => '#ECF9BE',
+ ];
+
+ $this->setOutputInterface();
+ $data = $this->outputInterface->dump();
+ $this->assertStringContainsString('#4A6000', $data);
+ $this->assertStringContainsString('#ECF9BE', $data);
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Output/QROutputTestAbstract.php b/vendor/chillerlan/php-qrcode/tests/Output/QROutputTestAbstract.php
new file mode 100644
index 000000000..6cd95d080
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Output/QROutputTestAbstract.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Class QROutputTestAbstract
+ *
+ * @filesource QROutputTestAbstract.php
+ * @created 24.12.2017
+ * @package chillerlan\QRCodeTest\Output
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Output;
+
+use chillerlan\QRCode\QROptions;
+use chillerlan\QRCode\Data\Byte;
+use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
+use chillerlan\QRCodeTest\QRTestAbstract;
+
+use function dirname, file_exists, mkdir;
+
+abstract class QROutputTestAbstract extends QRTestAbstract{
+
+ const cachefile = __DIR__.'/../../.build/output_test/test.';
+
+ /**
+ * @var \chillerlan\QRCode\Output\QROutputInterface
+ */
+ protected $outputInterface;
+
+ /**
+ * @var \chillerlan\QRCode\QROptions
+ */
+ protected $options;
+
+ /**
+ * @var \chillerlan\QRCode\Data\QRMatrix
+ */
+ protected $matrix;
+
+ protected function setUp():void{
+ parent::setUp();
+
+ $buildDir = dirname($this::cachefile);
+ if(!file_exists($buildDir)){
+ mkdir($buildDir, 0777, true);
+ }
+
+ $this->options = new QROptions;
+ $this->setOutputInterface();
+ }
+
+ protected function setOutputInterface(){
+ $this->outputInterface = $this->reflection->newInstanceArgs([$this->options, (new Byte($this->options, 'testdata'))->initMatrix(0)]);
+ return $this->outputInterface;
+ }
+
+ public function testInstance(){
+ $this->assertInstanceOf(QROutputInterface::class, $this->outputInterface);
+ }
+
+ public function testSaveException(){
+ $this->expectException(QRCodeOutputException::class);
+ $this->expectExceptionMessage('Could not write data to cache file: /foo');
+
+ $this->options->cachefile = '/foo';
+ $this->setOutputInterface();
+ $this->outputInterface->dump();
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Output/QRStringTest.php b/vendor/chillerlan/php-qrcode/tests/Output/QRStringTest.php
new file mode 100644
index 000000000..5dbd34010
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Output/QRStringTest.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Class QRStringTest
+ *
+ * @filesource QRStringTest.php
+ * @created 24.12.2017
+ * @package chillerlan\QRCodeTest\Output
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Output;
+
+use chillerlan\QRCode\{QRCode, Output\QRString};
+
+class QRStringTest extends QROutputTestAbstract{
+
+ protected $FQCN = QRString::class;
+
+ public function types(){
+ return [
+ 'json' => [QRCode::OUTPUT_STRING_JSON],
+ 'text' => [QRCode::OUTPUT_STRING_TEXT],
+ ];
+ }
+
+ /**
+ * @dataProvider types
+ * @param $type
+ */
+ public function testStringOutput($type){
+ $this->options->outputType = $type;
+ $this->options->cachefile = $this::cachefile.$type;
+ $this->setOutputInterface();
+ $data = $this->outputInterface->dump();
+
+ $this->assertSame($data, file_get_contents($this->options->cachefile));
+ }
+
+ public function testSetModuleValues(){
+
+ $this->options->moduleValues = [
+ // data
+ 1024 => 'A',
+ 4 => 'B',
+ ];
+
+ $this->setOutputInterface();
+ $data = $this->outputInterface->dump();
+
+ $this->assertStringContainsString('A', $data);
+ $this->assertStringContainsString('B', $data);
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/QRCodeTest.php b/vendor/chillerlan/php-qrcode/tests/QRCodeTest.php
new file mode 100644
index 000000000..8613c961f
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/QRCodeTest.php
@@ -0,0 +1,140 @@
+<?php
+/**
+ * Class QRCodeTest
+ *
+ * @filesource QRCodeTest.php
+ * @created 17.11.2017
+ * @package chillerlan\QRCodeTest
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest;
+
+use chillerlan\QRCode\{QROptions, QRCode};
+use chillerlan\QRCode\Data\{AlphaNum, Byte, Number, QRCodeDataException};
+use chillerlan\QRCode\Output\QRCodeOutputException;
+use chillerlan\QRCodeExamples\MyCustomOutput;
+
+use function random_bytes;
+
+class QRCodeTest extends QRTestAbstract{
+
+ protected $FQCN = QRCode::class;
+
+ /**
+ * @var \chillerlan\QRCode\QRCode
+ */
+ protected $qrcode;
+
+ protected function setUp():void{
+ parent::setUp();
+
+ $this->qrcode = $this->reflection->newInstance();
+ }
+
+ public function testIsNumber(){
+ $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'));
+ }
+
+ public function testIsKanji(){
+ $this->assertTrue($this->qrcode->isKanji('茗荷'));
+ $this->assertFalse($this->qrcode->isKanji('Ã'));
+ }
+
+ // coverage
+
+ public function typeDataProvider(){
+ return [
+ 'png' => [QRCode::OUTPUT_IMAGE_PNG, 'data:image/png;base64,'],
+ 'gif' => [QRCode::OUTPUT_IMAGE_GIF, 'data:image/gif;base64,'],
+ 'jpg' => [QRCode::OUTPUT_IMAGE_JPG, 'data:image/jpg;base64,'],
+ 'svg' => [QRCode::OUTPUT_MARKUP_SVG, 'data:image/svg+xml;base64,'],
+ 'html' => [QRCode::OUTPUT_MARKUP_HTML, '<div><span style="background:'],
+ 'text' => [QRCode::OUTPUT_STRING_TEXT, '⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕'.PHP_EOL],
+ 'json' => [QRCode::OUTPUT_STRING_JSON, '[[18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18],'],
+ ];
+ }
+
+ /**
+ * @dataProvider typeDataProvider
+ * @param $type
+ */
+ public function testRenderImage($type, $expected){
+ $this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['outputType' => $type])]);
+
+ $this->assertStringContainsString($expected, $this->qrcode->render('test'));
+ }
+
+ public function testInitDataInterfaceException(){
+ $this->expectException(QRCodeOutputException::class);
+ $this->expectExceptionMessage('invalid output type');
+
+ (new QRCode(new QROptions(['outputType' => 'foo'])))->render('test');
+ }
+
+ public function testGetMatrixException(){
+ $this->expectException(QRCodeDataException::class);
+ $this->expectExceptionMessage('QRCode::getMatrix() No data given.');
+
+ $this->qrcode->getMatrix('');
+ }
+
+ public function testTrim() {
+ $m1 = $this->qrcode->getMatrix('hello');
+ $m2 = $this->qrcode->getMatrix('hello '); // added space
+
+ $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);
+ }
+
+ public function testCustomOutput(){
+
+ $options = new QROptions([
+ 'version' => 5,
+ 'eccLevel' => QRCode::ECC_L,
+ 'outputType' => QRCode::OUTPUT_CUSTOM,
+ 'outputInterface' => MyCustomOutput::class,
+ ]);
+
+ $expected = '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111110111010000101111010000011111110000000010000010111000001101011000001010000010000000010111010101101011000001101011010111010000000010111010110100111110010100111010111010000000010111010000001101011000001101010111010000000010000010100111110010100111110010000010000000011111110101010101010101010101011111110000000000000000010010100111110010100000000000000000011001110000101111010000101111001011110000000000000000111010000101111010000111100010000000001011010100111110010100111110011001010000000010000101111101011000001101011110011110000000000011010100011000001101011000101110100000000011001100001001101011000001101010011010000000010110111110000001101011000001100110100000000010000100100010100111110010100001100100000000011111110111101111010000101111010100110000000011010000111010000101111010000111100100000000010101111111111110010100111110011001000000000010110001110101011000001101011110011010000000001001111100011000001101011000101110010000000011000100110001101011000001101010011100000000001000011001000001101011000001100110000000000011101001011010100111110010100001100000000000010111010001101111010000101111010100110000000011100000001010000101111010000111100000000000000001110110111110010100111110011001000000000000011001011101011000001101011110011100000000011111110101011000001101011001111110110000000000000000110001101011000001101000111100000000011111110001000001101011000011010110000000000010000010101010100111110010101000100100000000010111010111101111010000101111111100110000000010111010011010000101111010001101100010000000010111010000111110010100111100101101100000000010000010101101011000001101001100111100000000011111110101011000001101011000110010110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';
+
+ $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->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)));
+ }
+
+ public function testDataModeOverrideError(){
+ $this->expectException(QRCodeDataException::class);
+ $this->expectExceptionMessage('illegal char:');
+
+ $this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['dataMode' => 'AlphaNum'])]);
+
+ $this->qrcode->initDataInterface(random_bytes(32));
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/QROptionsTest.php b/vendor/chillerlan/php-qrcode/tests/QROptionsTest.php
new file mode 100644
index 000000000..41bf69ced
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/QROptionsTest.php
@@ -0,0 +1,80 @@
+<?php
+/**
+ * Class QROptionsTest
+ *
+ * @filesource QROptionsTest.php
+ * @created 08.11.2018
+ * @package chillerlan\QRCodeTest
+ * @author smiley <[email protected]>
+ * @copyright 2018 smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest;
+
+use chillerlan\QRCode\{QRCode, QRCodeException, QROptions};
+use PHPUnit\Framework\TestCase;
+
+class QROptionsTest extends TestCase{
+
+ /**
+ * @var \chillerlan\QRCode\QROptions
+ */
+ protected $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
+ }
+
+ public function testVersionMinMaxClamp(){
+ // normal clamp
+ $o = new QROptions(['versionMin' => 5, 'versionMax' => 10]);
+ $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);
+
+ // min > max
+ $o = new QROptions(['versionMin' => 10, 'versionMax' => 5]);
+ $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);
+ }
+
+ 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
+ }
+
+ public function testInvalidEccLevelException(){
+ $this->expectException(QRCodeException::class);
+ $this->expectExceptionMessage('Invalid error correct level: 42');
+
+ new QROptions(['eccLevel' => 42]);
+ }
+
+ 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]);
+ }
+
+ public function testInvalidRGBValueException(){
+ $this->expectException(QRCodeException::class);
+ $this->expectExceptionMessage('Invalid RGB value.');
+
+ new QROptions(['imageTransparencyBG' => ['r', 'g', 'b']]);
+ }
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/QRTestAbstract.php b/vendor/chillerlan/php-qrcode/tests/QRTestAbstract.php
new file mode 100644
index 000000000..7b9eb8049
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/QRTestAbstract.php
@@ -0,0 +1,72 @@
+<?php
+/**
+ * Class QRTestAbstract
+ *
+ * @filesource QRTestAbstract.php
+ * @created 17.11.2017
+ * @package chillerlan\QRCodeTest
+ * @author Smiley <[email protected]>
+ * @copyright 2017 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest;
+
+use PHPUnit\Framework\TestCase;
+use ReflectionClass, ReflectionMethod, ReflectionProperty;
+
+abstract class QRTestAbstract extends TestCase{
+
+ /**
+ * @var \ReflectionClass
+ */
+ protected $reflection;
+
+ /**
+ * @var string
+ */
+ protected $FQCN;
+
+ protected function setUp():void{
+ $this->reflection = new ReflectionClass($this->FQCN);
+ }
+
+ /**
+ * @param string $method
+ *
+ * @return \ReflectionMethod
+ */
+ protected function getMethod(string $method):ReflectionMethod {
+ $method = $this->reflection->getMethod($method);
+ $method->setAccessible(true);
+
+ return $method;
+ }
+
+ /**
+ * @param string $property
+ *
+ * @return \ReflectionProperty
+ */
+ protected function getProperty(string $property):ReflectionProperty{
+ $property = $this->reflection->getProperty($property);
+ $property->setAccessible(true);
+
+ return $property;
+ }
+
+ /**
+ * @param $object
+ * @param string $property
+ * @param $value
+ *
+ * @return void
+ */
+ protected function setProperty($object, string $property, $value){
+ $property = $this->getProperty($property);
+ $property->setAccessible(true);
+ $property->setValue($object, $value);
+ }
+
+
+}