diff --git a/vendor/bacon/bacon-qr-code/.gitignore b/vendor/bacon/bacon-qr-code/.gitignore deleted file mode 100644 index 35c1bcdf..00000000 --- a/vendor/bacon/bacon-qr-code/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -nbproject -.idea -.buildpath -.project -.DS_Store -.*.sw* -.*.un~ diff --git a/vendor/bacon/bacon-qr-code/.travis.yml b/vendor/bacon/bacon-qr-code/.travis.yml deleted file mode 100644 index 4e554be6..00000000 --- a/vendor/bacon/bacon-qr-code/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: php -php: - - 5.3 - - 5.4 - - 5.5 - - 7.0 - - hhvm - -script: phpunit --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml tests \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/composer.json b/vendor/bacon/bacon-qr-code/composer.json deleted file mode 100644 index 01b16bc2..00000000 --- a/vendor/bacon/bacon-qr-code/composer.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "bacon/bacon-qr-code", - "description": "BaconQrCode is a QR code generator for PHP.", - "license" : "BSD-2-Clause", - "homepage": "https://github.com/Bacon/BaconQrCode", - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-gd": "to generate QR code images" - }, - "authors": [ - { - "name": "Ben Scholzen 'DASPRiD'", - "email": "mail@dasprids.de", - "homepage": "http://www.dasprids.de", - "role": "Developer" - } - ], - "autoload": { - "psr-0": { - "BaconQrCode": "src/" - } - } -} diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitArrayTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitArrayTest.php deleted file mode 100644 index 06aa4e16..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitArrayTest.php +++ /dev/null @@ -1,197 +0,0 @@ -assertFalse($array->get($i)); - $array->set($i); - $this->assertTrue($array->get($i)); - } - } - - public function testGetNextSet1() - { - $array = new BitArray(32); - - for ($i = 0; $i < $array->getSize(); $i++) { - $this->assertEquals($i, 32, '', $array->getNextSet($i)); - } - - $array = new BitArray(33); - - for ($i = 0; $i < $array->getSize(); $i++) { - $this->assertEquals($i, 33, '', $array->getNextSet($i)); - } - } - - public function testGetNextSet2() - { - $array = new BitArray(33); - - for ($i = 0; $i < $array->getSize(); $i++) { - $this->assertEquals($i, $i <= 31 ? 31 : 33, '', $array->getNextSet($i)); - } - - $array = new BitArray(33); - - for ($i = 0; $i < $array->getSize(); $i++) { - $this->assertEquals($i, 32, '', $array->getNextSet($i)); - } - } - - public function testGetNextSet3() - { - $array = new BitArray(63); - $array->set(31); - $array->set(32); - - for ($i = 0; $i < $array->getSize(); $i++) { - if ($i <= 31) { - $expected = 31; - } elseif ($i <= 32) { - $expected = 32; - } else { - $expected = 63; - } - - $this->assertEquals($i, $expected, '', $array->getNextSet($i)); - } - } - - public function testGetNextSet4() - { - $array = new BitArray(63); - $array->set(33); - $array->set(40); - - for ($i = 0; $i < $array->getSize(); $i++) { - if ($i <= 33) { - $expected = 33; - } elseif ($i <= 40) { - $expected = 40; - } else { - $expected = 63; - } - - $this->assertEquals($i, $expected, '', $array->getNextSet($i)); - } - } - - public function testGetNextSet5() - { - mt_srand(hexdec('deadbeef')); - - for ($i = 0; $i < 10; $i++) { - $array = new BitArray(mt_rand(1, 100)); - $numSet = mt_rand(0, 19); - - for ($j = 0; $j < $numSet; $j++) { - $array->set(mt_rand(0, $array->getSize() - 1)); - } - - $numQueries = mt_rand(0, 19); - - for ($j = 0; $j < $numQueries; $j++) { - $query = mt_rand(0, $array->getSize() - 1); - $expected = $query; - - while ($expected < $array->getSize() && !$array->get($expected)) { - $expected++; - } - - $actual = $array->getNextSet($query); - - if ($actual !== $expected) { - $array->getNextSet($query); - } - - $this->assertEquals($expected, $actual); - } - } - } - - public function testSetBulk() - { - $array = new BitArray(64); - $array->setBulk(32, 0xFFFF0000); - - for ($i = 0; $i < 48; $i++) { - $this->assertFalse($array->get($i)); - } - - for ($i = 48; $i < 64; $i++) { - $this->assertTrue($array->get($i)); - } - } - - public function testClear() - { - $array = new BitArray(32); - - for ($i = 0; $i < 32; $i++) { - $array->set($i); - } - - $array->clear(); - - for ($i = 0; $i < 32; $i++) { - $this->assertFalse($array->get($i)); - } - } - - public function testGetArray() - { - $array = new BitArray(64); - $array->set(0); - $array->set(63); - - $ints = $array->getBitArray(); - - $this->assertEquals(1, $ints[0]); - $this->assertEquals(0x80000000, $ints[1]); - } - - public function testIsRange() - { - $array = new BitArray(64); - $this->assertTrue($array->isRange(0, 64, false)); - $this->assertFalse($array->isRange(0, 64, true)); - - $array->set(32); - $this->assertTrue($array->isRange(32, 33, true)); - - $array->set(31); - $this->assertTrue($array->isRange(31, 33, true)); - - $array->set(34); - $this->assertFalse($array->isRange(31, 35, true)); - - for ($i = 0; $i < 31; $i++) { - $array->set($i); - } - - $this->assertTrue($array->isRange(0, 33, true)); - - for ($i = 33; $i < 64; $i++) { - $array->set($i); - } - - $this->assertTrue($array->isRange(0, 64, true)); - $this->assertFalse($array->isRange(0, 64, false)); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitMatrixTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitMatrixTest.php deleted file mode 100644 index 89a58812..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitMatrixTest.php +++ /dev/null @@ -1,119 +0,0 @@ -assertEquals(33, $matrix->getHeight()); - - for ($y = 0; $y < 33; $y++) { - for ($x = 0; $x < 33; $x++) { - if ($y * $x % 3 === 0) { - $matrix->set($x, $y); - } - } - } - - for ($y = 0; $y < 33; $y++) { - for ($x = 0; $x < 33; $x++) { - $this->assertEquals($x * $y % 3 === 0, $matrix->get($x, $y)); - } - } - } - - public function testSetRegion() - { - $matrix = new BitMatrix(5); - $matrix->setRegion(1, 1, 3, 3); - - for ($y = 0; $y < 5; $y++) { - for ($x = 0; $x < 5; $x++) { - $this->assertEquals($y >= 1 && $y <= 3 && $x >= 1 && $x <= 3, $matrix->get($x, $y)); - } - } - } - - public function testRectangularMatrix() - { - $matrix = new BitMatrix(75, 20); - $this->assertEquals(75, $matrix->getWidth()); - $this->assertEquals(20, $matrix->getHeight()); - - $matrix->set(10, 0); - $matrix->set(11, 1); - $matrix->set(50, 2); - $matrix->set(51, 3); - $matrix->flip(74, 4); - $matrix->flip(0, 5); - - $this->assertTrue($matrix->get(10, 0)); - $this->assertTrue($matrix->get(11, 1)); - $this->assertTrue($matrix->get(50, 2)); - $this->assertTrue($matrix->get(51, 3)); - $this->assertTrue($matrix->get(74, 4)); - $this->assertTrue($matrix->get(0, 5)); - - $matrix->flip(50, 2); - $matrix->flip(51, 3); - - $this->assertFalse($matrix->get(50, 2)); - $this->assertFalse($matrix->get(51, 3)); - } - - public function testRectangularSetRegion() - { - $matrix = new BitMatrix(320, 240); - $this->assertEquals(320, $matrix->getWidth()); - $this->assertEquals(240, $matrix->getHeight()); - - $matrix->setRegion(105, 22, 80, 12); - - for ($y = 0; $y < 240; $y++) { - for ($x = 0; $x < 320; $x++) { - $this->assertEquals($y >= 22 && $y < 34 && $x >= 105 && $x < 185, $matrix->get($x, $y)); - } - } - } - - public function testGetRow() - { - $matrix = new BitMatrix(102, 5); - - for ($x = 0; $x < 102; $x++) { - if ($x & 3 === 0) { - $matrix->set($x, 2); - } - } - - $array1 = $matrix->getRow(2, null); - $this->assertEquals(102, $array1->getSize()); - - $array2 = new BitArray(60); - $array2 = $matrix->getRow(2, $array2); - $this->assertEquals(102, $array2->getSize()); - - $array3 = new BitArray(200); - $array3 = $matrix->getRow(2, $array3); - $this->assertEquals(200, $array3->getSize()); - - for ($x = 0; $x < 102; $x++) { - $on = ($x & 3 === 0); - - $this->assertEquals($on, $array1->get($x)); - $this->assertEquals($on, $array2->get($x)); - $this->assertEquals($on, $array3->get($x)); - } - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitUtilsTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitUtilsTest.php deleted file mode 100644 index b80ff7df..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitUtilsTest.php +++ /dev/null @@ -1,30 +0,0 @@ -assertEquals(1, BitUtils::unsignedRightShift(1, 0)); - $this->assertEquals(1, BitUtils::unsignedRightShift(10, 3)); - $this->assertEquals(536870910, BitUtils::unsignedRightShift(-10, 3)); - } - - public function testNumberOfTrailingZeros() - { - $this->assertEquals(32, BitUtils::numberOfTrailingZeros(0)); - $this->assertEquals(1, BitUtils::numberOfTrailingZeros(10)); - $this->assertEquals(0, BitUtils::numberOfTrailingZeros(15)); - $this->assertEquals(2, BitUtils::numberOfTrailingZeros(20)); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ErrorCorrectionLevelTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ErrorCorrectionLevelTest.php deleted file mode 100644 index 736e995d..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ErrorCorrectionLevelTest.php +++ /dev/null @@ -1,40 +0,0 @@ -assertEquals(0x0, ErrorCorrectionLevel::M); - $this->assertEquals(0x1, ErrorCorrectionLevel::L); - $this->assertEquals(0x2, ErrorCorrectionLevel::H); - $this->assertEquals(0x3, ErrorCorrectionLevel::Q); - } - - public function testInvalidErrorCorrectionLevelThrowsException() - { - $this->setExpectedException( - 'BaconQrCode\Exception\UnexpectedValueException', - 'Value not a const in enum BaconQrCode\Common\ErrorCorrectionLevel' - ); - new ErrorCorrectionLevel(4); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/FormatInformationTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/FormatInformationTest.php deleted file mode 100644 index 5f6ee58c..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/FormatInformationTest.php +++ /dev/null @@ -1,104 +0,0 @@ -unmaskedTestFormatInfo = $this->maskedTestFormatInfo ^ 0x5412; - } - - - public function testBitsDiffering() - { - $this->assertEquals(0, FormatInformation::numBitsDiffering(1, 1)); - $this->assertEquals(1, FormatInformation::numBitsDiffering(0, 2)); - $this->assertEquals(2, FormatInformation::numBitsDiffering(1, 2)); - $this->assertEquals(32, FormatInformation::numBitsDiffering(-1, 0)); - } - - public function testDecode() - { - $expected = FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo, - $this->maskedTestFormatInfo - ); - - $this->assertNotNull($expected); - $this->assertEquals(7, $expected->getDataMask()); - $this->assertEquals(ErrorCorrectionLevel::Q, $expected->getErrorCorrectionLevel()->get()); - - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - $this->unmaskedTestFormatInfo, - $this->maskedTestFormatInfo - ) - ); - } - - public function testDecodeWithBitDifference() - { - $expected = FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo, - $this->maskedTestFormatInfo - ); - - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo ^ 0x1, - $this->maskedTestFormatInfo ^ 0x1 - ) - ); - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo ^ 0x3, - $this->maskedTestFormatInfo ^ 0x3 - ) - ); - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo ^ 0x7, - $this->maskedTestFormatInfo ^ 0x7 - ) - ); - $this->assertNull( - FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo ^ 0xf, - $this->maskedTestFormatInfo ^ 0xf - ) - ); - } - - public function testDecodeWithMisRead() - { - $expected = FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo, - $this->maskedTestFormatInfo - ); - - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo ^ 0x3, - $this->maskedTestFormatInfo ^ 0xf - ) - ); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ModeTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ModeTest.php deleted file mode 100644 index 4daab7c3..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ModeTest.php +++ /dev/null @@ -1,42 +0,0 @@ -assertEquals(0x0, Mode::TERMINATOR); - $this->assertEquals(0x1, Mode::NUMERIC); - $this->assertEquals(0x2, Mode::ALPHANUMERIC); - $this->assertEquals(0x4, Mode::BYTE); - $this->assertEquals(0x8, Mode::KANJI); - } - - public function testInvalidModeThrowsException() - { - $this->setExpectedException( - 'BaconQrCode\Exception\UnexpectedValueException', - 'Value not a const in enum BaconQrCode\Common\Mode' - ); - new Mode(10); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ReedSolomonCodecTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ReedSolomonCodecTest.php deleted file mode 100644 index 99a6c725..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ReedSolomonCodecTest.php +++ /dev/null @@ -1,107 +0,0 @@ -encode($block, $parity); - - // Copy parity into test blocks - for ($i = 0; $i < $numRoots; $i++) { - $block[$i + $dataSize] = $parity[$i]; - $tBlock[$i + $dataSize] = $parity[$i]; - } - - // Seed with errors - for ($i = 0; $i < $errors; $i++) { - $errorValue = mt_rand(1, $blockSize); - - do { - $errorLocation = mt_rand(0, $blockSize); - } while ($errorLocations[$errorLocation] !== 0); - - $errorLocations[$errorLocation] = 1; - - if (mt_rand(0, 1)) { - $erasures[] = $errorLocation; - } - - $tBlock[$errorLocation] ^= $errorValue; - } - - $erasures = SplFixedArray::fromArray($erasures, false); - - // Decode the errored block - $foundErrors = $codec->decode($tBlock, $erasures); - - if ($errors > 0 && $foundErrors === null) { - $this->assertEquals($block, $tBlock, 'Decoder failed to correct errors'); - } - - $this->assertEquals($errors, $foundErrors, 'Found errors do not equal expected errors'); - - for ($i = 0; $i < $foundErrors; $i++) { - if ($errorLocations[$erasures[$i]] === 0) { - $this->fail(sprintf('Decoder indicates error in location %d without error', $erasures[$i])); - } - } - - $this->assertEquals($block, $tBlock, 'Decoder did not correct errors'); - } - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/VersionTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/VersionTest.php deleted file mode 100644 index 8b3fc01f..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/VersionTest.php +++ /dev/null @@ -1,88 +0,0 @@ -assertNotNull($version); - $this->assertEquals($versionNumber, $version->getVersionNumber()); - $this->assertNotNull($version->getAlignmentPatternCenters()); - - if ($versionNumber > 1) { - $this->assertTrue(count($version->getAlignmentPatternCenters()) > 0); - } - - $this->assertEquals($dimension, $version->getDimensionForVersion()); - $this->assertNotNull($version->getEcBlocksForLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::H))); - $this->assertNotNull($version->getEcBlocksForLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::L))); - $this->assertNotNull($version->getEcBlocksForLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::M))); - $this->assertNotNull($version->getEcBlocksForLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::Q))); - $this->assertNotNull($version->buildFunctionPattern()); - } - - /** - * @dataProvider versionProvider - * @param integer $versionNumber - * @param integer $dimension - */ - public function testGetProvisionalVersionForDimension($versionNumber, $dimension) - { - $this->assertEquals( - $versionNumber, - Version::getProvisionalVersionForDimension($dimension)->getVersionNumber() - ); - } - - /** - * @dataProvider decodeInformationProvider - * @param integer $expectedVersion - * @param integer $mask - */ - public function testDecodeVersionInformation($expectedVersion, $mask) - { - $version = Version::decodeVersionInformation($mask); - $this->assertNotNull($version); - $this->assertEquals($expectedVersion, $version->getVersionNumber()); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/EncoderTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/EncoderTest.php deleted file mode 100644 index 31cdaa4e..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/EncoderTest.php +++ /dev/null @@ -1,468 +0,0 @@ -getMethods(ReflectionMethod::IS_STATIC) as $method) { - $method->setAccessible(true); - $this->methods[$method->getName()] = $method; - } - } - - public function testGetAlphanumericCode() - { - // The first ten code points are numbers. - for ($i = 0; $i < 10; $i++) { - $this->assertEquals($i, $this->methods['getAlphanumericCode']->invoke(null, ord('0') + $i)); - } - - // The next 26 code points are capital alphabet letters. - for ($i = 10; $i < 36; $i++) { - // The first ten code points are numbers - $this->assertEquals($i, $this->methods['getAlphanumericCode']->invoke(null, ord('A') + $i - 10)); - } - - // Others are symbol letters. - $this->assertEquals(36, $this->methods['getAlphanumericCode']->invoke(null, ' ')); - $this->assertEquals(37, $this->methods['getAlphanumericCode']->invoke(null, '$')); - $this->assertEquals(38, $this->methods['getAlphanumericCode']->invoke(null, '%')); - $this->assertEquals(39, $this->methods['getAlphanumericCode']->invoke(null, '*')); - $this->assertEquals(40, $this->methods['getAlphanumericCode']->invoke(null, '+')); - $this->assertEquals(41, $this->methods['getAlphanumericCode']->invoke(null, '-')); - $this->assertEquals(42, $this->methods['getAlphanumericCode']->invoke(null, '.')); - $this->assertEquals(43, $this->methods['getAlphanumericCode']->invoke(null, '/')); - $this->assertEquals(44, $this->methods['getAlphanumericCode']->invoke(null, ':')); - - // Should return -1 for other letters. - $this->assertEquals(-1, $this->methods['getAlphanumericCode']->invoke(null, 'a')); - $this->assertEquals(-1, $this->methods['getAlphanumericCode']->invoke(null, '#')); - $this->assertEquals(-1, $this->methods['getAlphanumericCode']->invoke(null, "\0")); - } - - public function testChooseMode() - { - // Numeric mode - $this->assertSame(Mode::NUMERIC, $this->methods['chooseMode']->invoke(null, '0')->get()); - $this->assertSame(Mode::NUMERIC, $this->methods['chooseMode']->invoke(null, '0123456789')->get()); - - // Alphanumeric mode - $this->assertSame(Mode::ALPHANUMERIC, $this->methods['chooseMode']->invoke(null, 'A')->get()); - $this->assertSame(Mode::ALPHANUMERIC, $this->methods['chooseMode']->invoke(null, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:')->get()); - - // 8-bit byte mode - $this->assertSame(Mode::BYTE, $this->methods['chooseMode']->invoke(null, 'a')->get()); - $this->assertSame(Mode::BYTE, $this->methods['chooseMode']->invoke(null, '#')->get()); - $this->assertSame(Mode::BYTE, $this->methods['chooseMode']->invoke(null, '')->get()); - - // AIUE in Hiragana in SHIFT-JIS - $this->assertSame(Mode::BYTE, $this->methods['chooseMode']->invoke(null, "\x8\xa\x8\xa\x8\xa\x8\xa6")->get()); - - // Nihon in Kanji in SHIFT-JIS - $this->assertSame(Mode::BYTE, $this->methods['chooseMode']->invoke(null, "\x9\xf\x9\x7b")->get()); - - // Sou-Utso-Byou in Kanji in SHIFT-JIS - $this->assertSame(Mode::BYTE, $this->methods['chooseMode']->invoke(null, "\xe\x4\x9\x5\x9\x61")->get()); - } - - public function testEncode() - { - $qrCode = Encoder::encode('ABCDEF', new ErrorCorrectionLevel(ErrorCorrectionLevel::H)); - $expected = "<<\n" - . " mode: ALPHANUMERIC\n" - . " ecLevel: H\n" - . " version: 1\n" - . " maskPattern: 0\n" - . " matrix:\n" - . " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0\n" - . " 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1\n" - . " 1 0 1 1 1 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0\n" - . " 0 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 1 0\n" - . " 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0\n" - . " 0 0 1 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 1 1 0\n" - . " 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0\n" - . " 1 1 1 1 1 1 1 0 0 0 1 0 1 0 1 1 0 0 0 0 1\n" - . " 1 0 0 0 0 0 1 0 1 1 1 1 0 1 0 1 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 0 1 0\n" - . " 1 0 1 1 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 0 1 1\n" - . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1\n" - . ">>\n"; - - $this->assertEquals($expected, $qrCode->__toString()); - } - - public function testSimpleUtf8Eci() - { - $qrCode = Encoder::encode('hello', new ErrorCorrectionLevel(ErrorCorrectionLevel::H), 'utf-8'); - $expected = "<<\n" - . " mode: BYTE\n" - . " ecLevel: H\n" - . " version: 1\n" - . " maskPattern: 3\n" - . " matrix:\n" - . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 1 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 1 1 0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 0 0\n" - . " 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 1 0 1 1 1 0\n" - . " 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 1 1 1\n" - . " 1 1 0 0 1 0 0 1 1 0 0 1 1 1 1 0 1 0 1 1 0\n" - . " 0 0 0 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0\n" - . " 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 1 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 0 0 0 1 1 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 1 1 1 0 1 0 0 0 1 1 0 0 0\n" - . " 1 0 1 1 1 0 1 0 1 1 0 0 0 1 0 0 1 0 0 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 1 1 0\n" - . " 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 1 1 0 0 0 0\n" - . ">>\n"; - - $this->assertEquals($expected, $qrCode->__toString()); - } - - public function testAppendModeInfo() - { - $bits = new BitArray(); - $this->methods['appendModeInfo']->invoke(null, new Mode(Mode::NUMERIC), $bits); - $this->assertEquals(' ...X', $bits->__toString()); - } - - public function testAppendLengthInfo() - { - // 1 letter (1/1), 10 bits. - $bits = new BitArray(); - $this->methods['appendLengthInfo']->invoke( - null, - 1, - Version::getVersionForNumber(1), - new Mode(Mode::NUMERIC), - $bits - ); - $this->assertEquals(' ........ .X', $bits->__toString()); - - // 2 letters (2/1), 11 bits. - $bits = new BitArray(); - $this->methods['appendLengthInfo']->invoke( - null, - 2, - Version::getVersionForNumber(10), - new Mode(Mode::ALPHANUMERIC), - $bits - ); - $this->assertEquals(' ........ .X.', $bits->__toString()); - - // 255 letters (255/1), 16 bits. - $bits = new BitArray(); - $this->methods['appendLengthInfo']->invoke( - null, - 255, - Version::getVersionForNumber(27), - new Mode(Mode::BYTE), - $bits - ); - $this->assertEquals(' ........ XXXXXXXX', $bits->__toString()); - - // 512 letters (1024/2), 12 bits. - $bits = new BitArray(); - $this->methods['appendLengthInfo']->invoke( - null, - 512, - Version::getVersionForNumber(40), - new Mode(Mode::KANJI), - $bits - ); - $this->assertEquals(' ..X..... ....', $bits->__toString()); - } - - public function testAppendBytes() - { - // Should use appendNumericBytes. - // 1 = 01 = 0001 in 4 bits. - $bits = new BitArray(); - $this->methods['appendBytes']->invoke( - null, - '1', - new Mode(Mode::NUMERIC), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertEquals(' ...X', $bits->__toString()); - - // Should use appendAlphaNumericBytes. - // A = 10 = 0xa = 001010 in 6 bits. - $bits = new BitArray(); - $this->methods['appendBytes']->invoke( - null, - 'A', - new Mode(Mode::ALPHANUMERIC), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertEquals(' ..X.X.', $bits->__toString()); - - // Should use append8BitBytes. - // 0x61, 0x62, 0x63 - $bits = new BitArray(); - $this->methods['appendBytes']->invoke( - null, - 'abc', - new Mode(Mode::BYTE), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertEquals(' .XX....X .XX...X. .XX...XX', $bits->__toString()); - - // Should use appendKanjiBytes. - // 0x93, 0x5f - $bits = new BitArray(); - $this->methods['appendBytes']->invoke( - null, - "\x93\x5f", - new Mode(Mode::KANJI), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertEquals(' .XX.XX.. XXXXX', $bits->__toString()); - - // Lower letters such as 'a' cannot be encoded in alphanumeric mode. - $this->setExpectedException( - 'BaconQrCode\Exception\WriterException', - 'Invalid alphanumeric code' - ); - $this->methods['appendBytes']->invoke( - null, - "a", - new Mode(Mode::ALPHANUMERIC), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - } - - public function testTerminateBits() - { - $bits = new BitArray(); - $this->methods['terminateBits']->invoke(null, 0, $bits); - $this->assertEquals('', $bits->__toString()); - - $bits = new BitArray(); - $this->methods['terminateBits']->invoke(null, 1, $bits); - $this->assertEquals(' ........', $bits->__toString()); - - $bits = new BitArray(); - $bits->appendBits(0, 3); - $this->methods['terminateBits']->invoke(null, 1, $bits); - $this->assertEquals(' ........', $bits->__toString()); - - $bits = new BitArray(); - $bits->appendBits(0, 5); - $this->methods['terminateBits']->invoke(null, 1, $bits); - $this->assertEquals(' ........', $bits->__toString()); - - $bits = new BitArray(); - $bits->appendBits(0, 8); - $this->methods['terminateBits']->invoke(null, 1, $bits); - $this->assertEquals(' ........', $bits->__toString()); - - $bits = new BitArray(); - $this->methods['terminateBits']->invoke(null, 2, $bits); - $this->assertEquals(' ........ XXX.XX..', $bits->__toString()); - - $bits = new BitArray(); - $bits->appendBits(0, 1); - $this->methods['terminateBits']->invoke(null, 3, $bits); - $this->assertEquals(' ........ XXX.XX.. ...X...X', $bits->__toString()); - } - - public function testGetNumDataBytesAndNumEcBytesForBlockId() - { - // Version 1-H. - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 26, 9, 1, 0); - $this->assertEquals(9, $numDataBytes); - $this->assertEquals(17, $numEcBytes); - - // Version 3-H. 2 blocks. - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 70, 26, 2, 0); - $this->assertEquals(13, $numDataBytes); - $this->assertEquals(22, $numEcBytes); - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 70, 26, 2, 1); - $this->assertEquals(13, $numDataBytes); - $this->assertEquals(22, $numEcBytes); - - // Version 7-H. (4 + 1) blocks. - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 196, 66, 5, 0); - $this->assertEquals(13, $numDataBytes); - $this->assertEquals(26, $numEcBytes); - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 196, 66, 5, 4); - $this->assertEquals(14, $numDataBytes); - $this->assertEquals(26, $numEcBytes); - - // Version 40-H. (20 + 61) blocks. - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 3706, 1276, 81, 0); - $this->assertEquals(15, $numDataBytes); - $this->assertEquals(30, $numEcBytes); - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 3706, 1276, 81, 20); - $this->assertEquals(16, $numDataBytes); - $this->assertEquals(30, $numEcBytes); - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 3706, 1276, 81, 80); - $this->assertEquals(16, $numDataBytes); - $this->assertEquals(30, $numEcBytes); - } - - public function testInterleaveWithEcBytes() - { - $dataBytes = SplFixedArray::fromArray(array(32, 65, 205, 69, 41, 220, 46, 128, 236), false); - $in = new BitArray(); - - foreach ($dataBytes as $dataByte) { - $in->appendBits($dataByte, 8); - } - - $outBits = $this->methods['interleaveWithEcBytes']->invoke(null, $in, 26, 9, 1); - $expected = SplFixedArray::fromArray(array( - // Data bytes. - 32, 65, 205, 69, 41, 220, 46, 128, 236, - // Error correction bytes. - 42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61, - ), false); - - $out = $outBits->toBytes(0, count($expected)); - - $this->assertEquals($expected, $out); - } - - public function testAppendNumericBytes() - { - // 1 = 01 = 0001 in 4 bits. - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '1', $bits); - $this->assertEquals(' ...X', $bits->__toString()); - - // 12 = 0xc = 0001100 in 7 bits. - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '12', $bits); - $this->assertEquals(' ...XX..', $bits->__toString()); - - // 123 = 0x7b = 0001111011 in 10 bits. - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '123', $bits); - $this->assertEquals(' ...XXXX. XX', $bits->__toString()); - - // 1234 = "123" + "4" = 0001111011 + 0100 in 14 bits. - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '1234', $bits); - $this->assertEquals(' ...XXXX. XX.X..', $bits->__toString()); - - // Empty - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '', $bits); - $this->assertEquals('', $bits->__toString()); - } - - public function testAppendAlphanumericBytes() - { - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, 'A', $bits); - $this->assertEquals(' ..X.X.', $bits->__toString()); - - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, 'AB', $bits); - $this->assertEquals(' ..XXX..X X.X', $bits->__toString()); - - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, 'ABC', $bits); - $this->assertEquals(' ..XXX..X X.X..XX. .', $bits->__toString()); - - // Empty - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, '', $bits); - $this->assertEquals('', $bits->__toString()); - - // Invalid data - $this->setExpectedException('BaconQrCode\Exception\WriterException', 'Invalid alphanumeric code'); - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, 'abc', $bits); - } - - public function testAppend8BitBytes() - { - // 0x61, 0x62, 0x63 - $bits = new BitArray(); - $this->methods['append8BitBytes']->invoke(null, 'abc', $bits, Encoder::DEFAULT_BYTE_MODE_ECODING); - $this->assertEquals(' .XX....X .XX...X. .XX...XX', $bits->__toString()); - - // Empty - $bits = new BitArray(); - $this->methods['append8BitBytes']->invoke(null, '', $bits, Encoder::DEFAULT_BYTE_MODE_ECODING); - $this->assertEquals('', $bits->__toString()); - } - - public function testAppendKanjiBytes() - { - // Numbers are from page 21 of JISX0510:2004 - $bits = new BitArray(); - $this->methods['appendKanjiBytes']->invoke(null, "\x93\x5f", $bits); - $this->assertEquals(' .XX.XX.. XXXXX', $bits->__toString()); - - $this->methods['appendKanjiBytes']->invoke(null, "\xe4\xaa", $bits); - $this->assertEquals(' .XX.XX.. XXXXXXX. X.X.X.X. X.', $bits->__toString()); - } - - public function testGenerateEcBytes() - { - // Numbers are from http://www.swetake.com/qr/qr3.html and - // http://www.swetake.com/qr/qr9.html - $dataBytes = SplFixedArray::fromArray(array(32, 65, 205, 69, 41, 220, 46, 128, 236), false); - $ecBytes = $this->methods['generateEcBytes']->invoke(null, $dataBytes, 17); - $expected = SplFixedArray::fromArray(array(42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61), false); - $this->assertEquals($expected, $ecBytes); - - $dataBytes = SplFixedArray::fromArray(array(67, 70, 22, 38, 54, 70, 86, 102, 118, 134, 150, 166, 182, 198, 214), false); - $ecBytes = $this->methods['generateEcBytes']->invoke(null, $dataBytes, 18); - $expected = SplFixedArray::fromArray(array(175, 80, 155, 64, 178, 45, 214, 233, 65, 209, 12, 155, 117, 31, 140, 214, 27, 187), false); - $this->assertEquals($expected, $ecBytes); - - // High-order zero coefficient case. - $dataBytes = SplFixedArray::fromArray(array(32, 49, 205, 69, 42, 20, 0, 236, 17), false); - $ecBytes = $this->methods['generateEcBytes']->invoke(null, $dataBytes, 17); - $expected = SplFixedArray::fromArray(array(0, 3, 130, 179, 194, 0, 55, 211, 110, 79, 98, 72, 170, 96, 211, 137, 213), false); - $this->assertEquals($expected, $ecBytes); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MaskUtilTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MaskUtilTest.php deleted file mode 100644 index a5c38656..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MaskUtilTest.php +++ /dev/null @@ -1,281 +0,0 @@ -fail('Data mask bit did not match'); - } - } - } - } - - public function testApplyMaskPenaltyRule1() - { - $matrix = new ByteMatrix(4, 1); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 0); - $matrix->set(3, 0, 0); - - $this->assertEquals(0, MaskUtil::applyMaskPenaltyRule1($matrix)); - - // Horizontal - $matrix = new ByteMatrix(6, 1); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 0); - $matrix->set(3, 0, 0); - $matrix->set(4, 0, 0); - $matrix->set(5, 0, 1); - $this->assertEquals(3, MaskUtil::applyMaskPenaltyRule1($matrix)); - $matrix->set(5, 0, 0); - $this->assertEquals(4, MaskUtil::applyMaskPenaltyRule1($matrix)); - - // Vertical - $matrix = new ByteMatrix(1, 6); - $matrix->set(0, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(0, 2, 0); - $matrix->set(0, 3, 0); - $matrix->set(0, 4, 0); - $matrix->set(0, 5, 1); - $this->assertEquals(3, MaskUtil::applyMaskPenaltyRule1($matrix)); - $matrix->set(0, 5, 0); - $this->assertEquals(4, MaskUtil::applyMaskPenaltyRule1($matrix)); - } - - public function testApplyMaskPenaltyRule2() - { - $matrix = new ByteMatrix(1, 1); - $matrix->set(0, 0, 0); - $this->assertEquals(0, MaskUtil::applyMaskPenaltyRule2($matrix)); - - $matrix = new ByteMatrix(2, 2); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(1, 1, 1); - $this->assertEquals(0, MaskUtil::applyMaskPenaltyRule2($matrix)); - - $matrix = new ByteMatrix(2, 2); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(1, 1, 0); - $this->assertEquals(3, MaskUtil::applyMaskPenaltyRule2($matrix)); - - $matrix = new ByteMatrix(3, 3); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(1, 1, 0); - $matrix->set(2, 1, 0); - $matrix->set(0, 2, 0); - $matrix->set(1, 2, 0); - $matrix->set(2, 2, 0); - $this->assertEquals(3 * 4, MaskUtil::applyMaskPenaltyRule2($matrix)); - } - - public function testApplyMaskPenalty3() - { - // Horizontal 00001011101 - $matrix = new ByteMatrix(11, 1); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 0); - $matrix->set(3, 0, 0); - $matrix->set(4, 0, 1); - $matrix->set(5, 0, 0); - $matrix->set(6, 0, 1); - $matrix->set(7, 0, 1); - $matrix->set(8, 0, 1); - $matrix->set(9, 0, 0); - $matrix->set(10, 0, 1); - $this->assertEquals(40, MaskUtil::applyMaskPenaltyRule3($matrix)); - - // Horizontal 10111010000 - $matrix = new ByteMatrix(11, 1); - $matrix->set(0, 0, 1); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 1); - $matrix->set(3, 0, 1); - $matrix->set(4, 0, 1); - $matrix->set(5, 0, 0); - $matrix->set(6, 0, 1); - $matrix->set(7, 0, 0); - $matrix->set(8, 0, 0); - $matrix->set(9, 0, 0); - $matrix->set(10, 0, 0); - $this->assertEquals(40, MaskUtil::applyMaskPenaltyRule3($matrix)); - - // Vertical 00001011101 - $matrix = new ByteMatrix(1, 11); - $matrix->set(0, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(0, 2, 0); - $matrix->set(0, 3, 0); - $matrix->set(0, 4, 1); - $matrix->set(0, 5, 0); - $matrix->set(0, 6, 1); - $matrix->set(0, 7, 1); - $matrix->set(0, 8, 1); - $matrix->set(0, 9, 0); - $matrix->set(0, 10, 1); - $this->assertEquals(40, MaskUtil::applyMaskPenaltyRule3($matrix)); - - // Vertical 10111010000 - $matrix = new ByteMatrix(1, 11); - $matrix->set(0, 0, 1); - $matrix->set(0, 1, 0); - $matrix->set(0, 2, 1); - $matrix->set(0, 3, 1); - $matrix->set(0, 4, 1); - $matrix->set(0, 5, 0); - $matrix->set(0, 6, 1); - $matrix->set(0, 7, 0); - $matrix->set(0, 8, 0); - $matrix->set(0, 9, 0); - $matrix->set(0, 10, 0); - $this->assertEquals(40, MaskUtil::applyMaskPenaltyRule3($matrix)); - } - - public function testApplyMaskPenaltyRule4() - { - // Dark cell ratio = 0% - $matrix = new ByteMatrix(1, 1); - $matrix->set(0, 0, 0); - $this->assertEquals(100, MaskUtil::applyMaskPenaltyRule4($matrix)); - - // Dark cell ratio = 5% - $matrix = new ByteMatrix(2, 1); - $matrix->set(0, 0, 0); - $matrix->set(0, 0, 1); - $this->assertEquals(0, MaskUtil::applyMaskPenaltyRule4($matrix)); - - // Dark cell ratio = 66.67% - $matrix = new ByteMatrix(6, 1); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 1); - $matrix->set(2, 0, 1); - $matrix->set(3, 0, 1); - $matrix->set(4, 0, 1); - $matrix->set(5, 0, 0); - $this->assertEquals(30, MaskUtil::applyMaskPenaltyRule4($matrix)); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MatrixUtilTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MatrixUtilTest.php deleted file mode 100644 index bf3544f0..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MatrixUtilTest.php +++ /dev/null @@ -1,336 +0,0 @@ -getMethods(ReflectionMethod::IS_STATIC) as $method) { - $method->setAccessible(true); - $this->methods[$method->getName()] = $method; - } - } - - public function testToString() - { - $matrix= new ByteMatrix(3, 3); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 1); - $matrix->set(2, 0, 0); - $matrix->set(0, 1, 1); - $matrix->set(1, 1, 0); - $matrix->set(2, 1, 1); - $matrix->set(0, 2, -1); - $matrix->set(1, 2, -1); - $matrix->set(2, 2, -1); - - $expected = " 0 1 0\n 1 0 1\n \n"; - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testClearMatrix() - { - $matrix = new ByteMatrix(2, 2); - MatrixUtil::clearMatrix($matrix); - - $this->assertEquals(-1, $matrix->get(0, 0)); - $this->assertEquals(-1, $matrix->get(1, 0)); - $this->assertEquals(-1, $matrix->get(0, 1)); - $this->assertEquals(-1, $matrix->get(1, 1)); - } - - public function testEmbedBasicPatterns1() - { - $matrix = new ByteMatrix(21, 21); - MatrixUtil::clearMatrix($matrix); - $this->methods['embedBasicPatterns']->invoke( - null, - Version::getVersionForNumber(1), - $matrix - ); - $expected = " 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 0 0 0 0 0 0 0 1 \n" - . " 1 1 1 1 1 1 1 0 \n" - . " 1 0 0 0 0 0 1 0 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 0 0 0 0 1 0 \n" - . " 1 1 1 1 1 1 1 0 \n"; - - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testEmbedBasicPatterns2() - { - $matrix = new ByteMatrix(25, 25); - MatrixUtil::clearMatrix($matrix); - $this->methods['embedBasicPatterns']->invoke( - null, - Version::getVersionForNumber(2), - $matrix - ); - $expected = " 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 \n" - . " 1 1 1 1 1 1 \n" - . " 0 0 0 0 0 0 0 0 1 1 0 0 0 1 \n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 \n" - . " 1 0 0 0 0 0 1 0 1 0 0 0 1 \n" - . " 1 0 1 1 1 0 1 0 1 1 1 1 1 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 0 0 0 0 1 0 \n" - . " 1 1 1 1 1 1 1 0 \n"; - - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testEmbedTypeInfo() - { - $matrix = new ByteMatrix(21, 21); - MatrixUtil::clearMatrix($matrix); - $this->methods['embedTypeInfo']->invoke( - null, - new ErrorCorrectionLevel(ErrorCorrectionLevel::M), - 5, - $matrix - ); - $expected = " 0 \n" - . " 1 \n" - . " 1 \n" - . " 1 \n" - . " 0 \n" - . " 0 \n" - . " \n" - . " 1 \n" - . " 1 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0\n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " 0 \n" - . " 0 \n" - . " 0 \n" - . " 0 \n" - . " 0 \n" - . " 0 \n" - . " 1 \n"; - - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testEmbedVersionInfo() - { - $matrix = new ByteMatrix(21, 21); - MatrixUtil::clearMatrix($matrix); - $this->methods['maybeEmbedVersionInfo']->invoke( - null, - Version::getVersionForNumber(7), - $matrix - ); - $expected = " 0 0 1 \n" - . " 0 1 0 \n" - . " 0 1 0 \n" - . " 0 1 1 \n" - . " 1 1 1 \n" - . " 0 0 0 \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " 0 0 0 0 1 0 \n" - . " 0 1 1 1 1 0 \n" - . " 1 0 0 1 1 0 \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n"; - - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testEmbedDataBits() - { - $matrix = new ByteMatrix(21, 21); - MatrixUtil::clearMatrix($matrix); - $this->methods['embedBasicPatterns']->invoke( - null, - Version::getVersionForNumber(1), - $matrix - ); - - $bits = new BitArray(); - $this->methods['embedDataBits']->invoke( - null, - $bits, - -1, - $matrix - ); - - $expected = " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"; - - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testBuildMatrix() - { - $bytes = array( - 32, 65, 205, 69, 41, 220, 46, 128, 236, 42, 159, 74, 221, 244, 169, - 239, 150, 138, 70, 237, 85, 224, 96, 74, 219 , 61 - ); - $bits = new BitArray(); - - foreach ($bytes as $byte) { - $bits->appendBits($byte, 8); - } - - $matrix = new ByteMatrix(21, 21); - MatrixUtil::buildMatrix( - $bits, - new ErrorCorrectionLevel(ErrorCorrectionLevel::H), - Version::getVersionForNumber(1), - 3, - $matrix - ); - - $expected = " 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 1 1 0 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0\n" - . " 0 0 1 1 0 0 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0\n" - . " 1 0 1 0 1 0 0 0 0 0 1 1 1 0 0 1 0 1 1 1 0\n" - . " 1 1 1 1 0 1 1 0 1 0 1 1 1 0 0 1 1 1 0 1 0\n" - . " 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 1 0 1 0\n" - . " 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 1\n" - . " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 0 1 0 1 1 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 1 0 1 1 1 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1\n" - . " 1 0 1 1 1 0 1 0 1 1 0 1 0 0 0 0 0 1 1 1 0\n" - . " 1 0 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0\n" - . " 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0\n"; - - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testFindMsbSet() - { - $this->assertEquals(0, $this->methods['findMsbSet']->invoke(null, 0)); - $this->assertEquals(1, $this->methods['findMsbSet']->invoke(null, 1)); - $this->assertEquals(8, $this->methods['findMsbSet']->invoke(null, 0x80)); - $this->assertEquals(32, $this->methods['findMsbSet']->invoke(null, 0x80000000)); - } - - public function testCalculateBchCode() - { - // Encoding of type information. - // From Appendix C in JISX0510:2004 (p 65) - $this->assertEquals(0xdc, $this->methods['calculateBchCode']->invoke(null, 5, 0x537)); - // From http://www.swetake.com/qr/qr6.html - $this->assertEquals(0x1c2, $this->methods['calculateBchCode']->invoke(null, 0x13, 0x537)); - // From http://www.swetake.com/qr/qr11.html - $this->assertEquals(0x214, $this->methods['calculateBchCode']->invoke(null, 0x1b, 0x537)); - - // Encoding of version information. - // From Appendix D in JISX0510:2004 (p 68) - $this->assertEquals(0xc94, $this->methods['calculateBchCode']->invoke(null, 7, 0x1f25)); - $this->assertEquals(0x5bc, $this->methods['calculateBchCode']->invoke(null, 8, 0x1f25)); - $this->assertEquals(0xa99, $this->methods['calculateBchCode']->invoke(null, 9, 0x1f25)); - $this->assertEquals(0x4d3, $this->methods['calculateBchCode']->invoke(null, 10, 0x1f25)); - $this->assertEquals(0x9a6, $this->methods['calculateBchCode']->invoke(null, 20, 0x1f25)); - $this->assertEquals(0xd75, $this->methods['calculateBchCode']->invoke(null, 30, 0x1f25)); - $this->assertEquals(0xc69, $this->methods['calculateBchCode']->invoke(null, 40, 0x1f25)); - } - - public function testMakeVersionInfoBits() - { - // From Appendix D in JISX0510:2004 (p 68) - $bits = new BitArray(); - $this->methods['makeVersionInfoBits']->invoke(null, Version::getVersionForNumber(7), $bits); - $this->assertEquals(' ...XXXXX ..X..X.X ..', $bits->__toString()); - } - - public function testMakeTypeInfoBits() - { - // From Appendix D in JISX0510:2004 (p 68) - $bits = new BitArray(); - $this->methods['makeTypeInfoBits']->invoke(null, new ErrorCorrectionLevel(ErrorCorrectionLevel::M), 5, $bits); - $this->assertEquals(' X......X X..XXX.', $bits->__toString()); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/HtmlTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/HtmlTest.php deleted file mode 100644 index 0c69dd2e..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/HtmlTest.php +++ /dev/null @@ -1,99 +0,0 @@ -renderer = new Html(); - $this->writer = new Writer($this->renderer); - } - - public function testBasicRender() - { - $content = 'foobar'; - $expected = - '
' . - " \n" . - " ███████ █████ ███████ \n" . - " █ █ █ █ █ █ \n" . - " █ ███ █ ██ █ ███ █ \n" . - " █ ███ █ ███ █ ███ █ \n" . - " █ ███ █ █ █ █ ███ █ \n" . - " █ █ ██ █ █ \n" . - " ███████ █ █ █ ███████ \n" . - " █████ \n" . - " ██ ██ █ ██ █ █ █ \n" . - " ██ ██ █ █ ██ \n" . - " ████████ █ ██ █ ██ \n" . - " ██ █ █ \n" . - " ██ ███ █ █ █ █ \n" . - " █ ███ █ █ \n" . - " ███████ ██ ██████ \n" . - " █ █ ████ ██ \n" . - " █ ███ █ ██ ██ ██ █ ██ \n" . - " █ ███ █ ██ ██ █ ██ \n" . - " █ ███ █ █ █ ██ ██ \n" . - " █ █ ███ ███ ████ \n" . - " ███████ ████ ██ \n" . - " \n" . - '' - ; - - $qrCode = Encoder::encode( - $content, - new ErrorCorrectionLevel(ErrorCorrectionLevel::L), - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertEquals($expected, $this->renderer->render($qrCode)); - } - - public function testSetStyle() - { - $content = 'foobar'; - $qrCode = Encoder::encode( - $content, - new ErrorCorrectionLevel(ErrorCorrectionLevel::L), - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->renderer->setStyle('bar'); - $this->assertEquals('bar', $this->renderer->getStyle()); - $this->assertStringMatchesFormat('%astyle="bar"%a', $this->renderer->render($qrCode)); - } - - public function testSetClass() - { - $content = 'foobar'; - $qrCode = Encoder::encode( - $content, - new ErrorCorrectionLevel(ErrorCorrectionLevel::L), - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->renderer->setClass('bar'); - $this->assertEquals('bar', $this->renderer->getClass()); - $this->assertStringMatchesFormat('%aclass="bar"%a', $this->renderer->render($qrCode)); - } -} diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/TextTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/TextTest.php deleted file mode 100644 index d94e8e5d..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/TextTest.php +++ /dev/null @@ -1,149 +0,0 @@ -renderer = new Plain(); - $this->writer = new Writer($this->renderer); - } - - public function testBasicRender() - { - $content = 'foobar'; - $expected = - " \n" . - " ███████ █████ ███████ \n" . - " █ █ █ █ █ █ \n" . - " █ ███ █ ██ █ ███ █ \n" . - " █ ███ █ ███ █ ███ █ \n" . - " █ ███ █ █ █ █ ███ █ \n" . - " █ █ ██ █ █ \n" . - " ███████ █ █ █ ███████ \n" . - " █████ \n" . - " ██ ██ █ ██ █ █ █ \n" . - " ██ ██ █ █ ██ \n" . - " ████████ █ ██ █ ██ \n" . - " ██ █ █ \n" . - " ██ ███ █ █ █ █ \n" . - " █ ███ █ █ \n" . - " ███████ ██ ██████ \n" . - " █ █ ████ ██ \n" . - " █ ███ █ ██ ██ ██ █ ██ \n" . - " █ ███ █ ██ ██ █ ██ \n" . - " █ ███ █ █ █ ██ ██ \n" . - " █ █ ███ ███ ████ \n" . - " ███████ ████ ██ \n" . - " \n" - ; - - $qrCode = Encoder::encode( - $content, - new ErrorCorrectionLevel(ErrorCorrectionLevel::L), - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertEquals($expected, $this->renderer->render($qrCode)); - } - - public function testBasicRenderNoMargins() - { - $content = 'foobar'; - $expected = - "███████ █████ ███████\n" . - "█ █ █ █ █ █\n" . - "█ ███ █ ██ █ ███ █\n" . - "█ ███ █ ███ █ ███ █\n" . - "█ ███ █ █ █ █ ███ █\n" . - "█ █ ██ █ █\n" . - "███████ █ █ █ ███████\n" . - " █████ \n" . - "██ ██ █ ██ █ █ █\n" . - " ██ ██ █ █ ██ \n" . - " ████████ █ ██ █ ██\n" . - " ██ █ █\n" . - " ██ ███ █ █ █ █\n" . - " █ ███ █ █ \n" . - "███████ ██ ██████ \n" . - "█ █ ████ ██ \n" . - "█ ███ █ ██ ██ ██ █ ██\n" . - "█ ███ █ ██ ██ █ ██ \n" . - "█ ███ █ █ █ ██ ██\n" . - "█ █ ███ ███ ████\n" . - "███████ ████ ██ \n" - ; - - $qrCode = Encoder::encode( - $content, - new ErrorCorrectionLevel(ErrorCorrectionLevel::L), - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->renderer->setMargin(0); - $this->assertEquals(0, $this->renderer->getMargin()); - $this->assertEquals($expected, $this->renderer->render($qrCode)); - } - - public function testBasicRenderCustomChar() - { - $content = 'foobar'; - $expected = - "-----------------------\n" . - "-#######-#####-#######-\n" . - "-#-----#--#-#--#-----#-\n" . - "-#-###-#--##---#-###-#-\n" . - "-#-###-#--###--#-###-#-\n" . - "-#-###-#---#-#-#-###-#-\n" . - "-#-----#----##-#-----#-\n" . - "-#######-#-#-#-#######-\n" . - "---------#####---------\n" . - "-##-##-#--##-#-#-----#-\n" . - "----##----##-#-#-##----\n" . - "--########-#--##-#--##-\n" . - "-----------##------#-#-\n" . - "--##--###--#---#--#--#-\n" . - "---------#-###----#-#--\n" . - "-#######--##-######----\n" . - "-#-----#---####---##---\n" . - "-#-###-#-##-##-##-#-##-\n" . - "-#-###-#-##-##--#-##---\n" . - "-#-###-#---#---#-##-##-\n" . - "-#-----#-###--###-####-\n" . - "-#######-####---##-----\n" . - "-----------------------\n" - ; - - $qrCode = Encoder::encode( - $content, - new ErrorCorrectionLevel(ErrorCorrectionLevel::L), - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->renderer->setFullBlock('#'); - $this->renderer->setEmptyBlock('-'); - $this->assertEquals('#', $this->renderer->getFullBlock()); - $this->assertEquals('-', $this->renderer->getEmptyBlock()); - $this->assertEquals($expected, $this->renderer->render($qrCode)); - } -} diff --git a/vendor/bacon/bacon-qr-code/tests/bootstrap.php b/vendor/bacon/bacon-qr-code/tests/bootstrap.php deleted file mode 100644 index 05a49415..00000000 --- a/vendor/bacon/bacon-qr-code/tests/bootstrap.php +++ /dev/null @@ -1,10 +0,0 @@ - -
Note: Make sure your server-time is NTP-synced! Depending on the $discrepancy allowed your time cannot drift too much from the users' time!
- ensureCorrectTime(); - echo 'Your hosts time seems to be correct / within margin'; - } catch (RobThree\Auth\TwoFactorAuthException $ex) { - echo 'Warning: Your hosts time seems to be off: ' . $ex->getMessage(); - } - ?> - - diff --git a/vendor/robthree/twofactorauth/demo/loader.php b/vendor/robthree/twofactorauth/demo/loader.php deleted file mode 100644 index 208f24d4..00000000 --- a/vendor/robthree/twofactorauth/demo/loader.php +++ /dev/null @@ -1,50 +0,0 @@ -=0;$i--) { - static::$parentPath = dirname(static::$parentPath); - } - static::$paths = array(); - static::$files = array(__FILE__); - } - - public static function register($path,$namespace) { - if (!static::$initialized) static::initialize(); - static::$paths[$namespace] = trim($path,DIRECTORY_SEPARATOR); - } - - public static function load($class) { - if (class_exists($class,false)) return; - if (!static::$initialized) static::initialize(); - - foreach (static::$paths as $namespace => $path) { - if (!$namespace || $namespace.static::$nsChar === substr($class, 0, strlen($namespace.static::$nsChar))) { - - $fileName = substr($class,strlen($namespace.static::$nsChar)-1); - $fileName = str_replace(static::$nsChar, DIRECTORY_SEPARATOR, ltrim($fileName,static::$nsChar)); - $fileName = static::$parentPath.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$fileName.'.php'; - - if (file_exists($fileName)) { - include $fileName; - return true; - } - } - } - return false; - } -} - -spl_autoload_register(array('Loader', 'load')); \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/logo.png b/vendor/robthree/twofactorauth/logo.png deleted file mode 100644 index 65af9b2e..00000000 Binary files a/vendor/robthree/twofactorauth/logo.png and /dev/null differ diff --git a/vendor/robthree/twofactorauth/multifactorauthforeveryone.png b/vendor/robthree/twofactorauth/multifactorauthforeveryone.png deleted file mode 100644 index 086bd928..00000000 Binary files a/vendor/robthree/twofactorauth/multifactorauthforeveryone.png and /dev/null differ diff --git a/vendor/robthree/twofactorauth/tests/TwoFactorAuthTest.php b/vendor/robthree/twofactorauth/tests/TwoFactorAuthTest.php deleted file mode 100644 index 587b19b8..00000000 --- a/vendor/robthree/twofactorauth/tests/TwoFactorAuthTest.php +++ /dev/null @@ -1,381 +0,0 @@ -assertEquals('543160', $tfa->getCode('VMR466AB62ZBOKHE', 1426847216)); - $this->assertEquals('538532', $tfa->getCode('VMR466AB62ZBOKHE', 0)); - } - - /** - * @expectedException \RobThree\Auth\TwoFactorAuthException - */ - public function testCreateSecretThrowsOnInsecureRNGProvider() { - $rng = new TestRNGProvider(); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, $rng); - $tfa->createSecret(); - } - - public function testCreateSecretOverrideSecureDoesNotThrowOnInsecureRNG() { - $rng = new TestRNGProvider(); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, $rng); - $this->assertEquals('ABCDEFGHIJKLMNOP', $tfa->createSecret(80, false)); - } - - public function testCreateSecretDoesNotThrowOnSecureRNGProvider() { - $rng = new TestRNGProvider(true); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, $rng); - $this->assertEquals('ABCDEFGHIJKLMNOP', $tfa->createSecret()); - } - - public function testCreateSecretGeneratesDesiredAmountOfEntropy() { - $rng = new TestRNGProvider(true); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, $rng); - $this->assertEquals('A', $tfa->createSecret(5)); - $this->assertEquals('AB', $tfa->createSecret(6)); - $this->assertEquals('ABCDEFGHIJKLMNOPQRSTUVWXYZ', $tfa->createSecret(128)); - $this->assertEquals('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', $tfa->createSecret(160)); - $this->assertEquals('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', $tfa->createSecret(320)); - $this->assertEquals('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKLMNOPQRSTUVWXYZ234567A', $tfa->createSecret(321)); - } - - public function testEnsureCorrectTimeDoesNotThrowForCorrectTime() { - $tpr1 = new TestTimeProvider(123); - $tpr2 = new TestTimeProvider(128); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, null, $tpr1); - $tfa->ensureCorrectTime(array($tpr2)); // 128 - 123 = 5 => within default leniency - } - - /** - * @expectedException \RobThree\Auth\TwoFactorAuthException - */ - public function testEnsureCorrectTimeThrowsOnIncorrectTime() { - $tpr1 = new TestTimeProvider(123); - $tpr2 = new TestTimeProvider(124); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, null, $tpr1); - $tfa->ensureCorrectTime(array($tpr2), 0); // We force a leniency of 0, 124-123 = 1 so this should throw - } - - - public function testEnsureDefaultTimeProviderReturnsCorrectTime() { - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1'); - $tfa->ensureCorrectTime(array(new TestTimeProvider(time())), 1); // Use a leniency of 1, should the time change between both time() calls - } - - public function testEnsureAllTimeProvidersReturnCorrectTime() { - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1'); - $tfa->ensureCorrectTime(array( - new RobThree\Auth\Providers\Time\ConvertUnixTimeDotComTimeProvider(), - new RobThree\Auth\Providers\Time\HttpTimeProvider(), // Uses google.com by default - new RobThree\Auth\Providers\Time\HttpTimeProvider('https://github.com'), - new RobThree\Auth\Providers\Time\HttpTimeProvider('https://yahoo.com'), - )); - } - - public function testVerifyCodeWorksCorrectly() { - - $tfa = new TwoFactorAuth('Test', 6, 30); - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 1, 1426847190)); - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 0, 1426847190 + 29)); //Test discrepancy - $this->assertEquals(false, $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 0, 1426847190 + 30)); //Test discrepancy - $this->assertEquals(false, $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 0, 1426847190 - 1)); //Test discrepancy - - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 1, 1426847205 + 0)); //Test discrepancy - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 1, 1426847205 + 35)); //Test discrepancy - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 1, 1426847205 - 35)); //Test discrepancy - - $this->assertEquals(false, $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 1, 1426847205 + 65)); //Test discrepancy - $this->assertEquals(false, $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 1, 1426847205 - 65)); //Test discrepancy - - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 2, 1426847205 + 65)); //Test discrepancy - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 2, 1426847205 - 65)); //Test discrepancy - } - - public function testTotpUriIsCorrect() { - $qr = new TestQrProvider(); - - $tfa = new TwoFactorAuth('Test&Issuer', 6, 30, 'sha1', $qr); - $data = $this->DecodeDataUri($tfa->getQRCodeImageAsDataUri('Test&Label', 'VMR466AB62ZBOKHE')); - $this->assertEquals('test/test', $data['mimetype']); - $this->assertEquals('base64', $data['encoding']); - $this->assertEquals('otpauth://totp/Test%26Label?secret=VMR466AB62ZBOKHE&issuer=Test%26Issuer&period=30&algorithm=SHA1&digits=6@200', $data['data']); - } - - /** - * @expectedException \RobThree\Auth\TwoFactorAuthException - */ - public function testGetQRCodeImageAsDataUriThrowsOnInvalidSize() { - $qr = new TestQrProvider(); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', $qr); - $tfa->getQRCodeImageAsDataUri('Test', 'VMR466AB62ZBOKHE', 0); - } - - /** - * @expectedException \RobThree\Auth\TwoFactorAuthException - */ - public function testGetCodeThrowsOnInvalidBase32String1() { - $tfa = new TwoFactorAuth('Test'); - $tfa->getCode('FOO1BAR8BAZ9'); //1, 8 & 9 are invalid chars - } - - /** - * @expectedException \RobThree\Auth\TwoFactorAuthException - */ - public function testGetCodeThrowsOnInvalidBase32String2() { - $tfa = new TwoFactorAuth('Test'); - $tfa->getCode('mzxw6==='); //Lowercase - } - - public function testKnownBase32DecodeTestVectors() { - // We usually don't test internals (e.g. privates) but since we rely heavily on base32 decoding and don't want - // to expose this method nor do we want to give people the possibility of implementing / providing their own base32 - // decoding/decoder (as we do with Rng/QR providers for example) we simply test the private base32Decode() method - // with some known testvectors **only** to ensure base32 decoding works correctly following RFC's so there won't - // be any bugs hiding in there. We **could** 'fool' ourselves by calling the public getCode() method (which uses - // base32decode internally) and then make sure getCode's output (in digits) equals expected output since that would - // mean the base32Decode() works as expected but that **could** hide some subtle bug(s) in decoding the base32 string. - - // "In general, you don't want to break any encapsulation for the sake of testing (or as Mom used to say, "don't - // expose your privates!"). Most of the time, you should be able to test a class by exercising its public methods." - // Dave Thomas and Andy Hunt -- "Pragmatic Unit Testing - $tfa = new TwoFactorAuth('Test'); - - $method = new ReflectionMethod('RobThree\Auth\TwoFactorAuth', 'base32Decode'); - $method->setAccessible(true); - - // Test vectors from: https://tools.ietf.org/html/rfc4648#page-12 - $this->assertEquals('', $method->invoke($tfa, '')); - $this->assertEquals('f', $method->invoke($tfa, 'MY======')); - $this->assertEquals('fo', $method->invoke($tfa, 'MZXQ====')); - $this->assertEquals('foo', $method->invoke($tfa, 'MZXW6===')); - $this->assertEquals('foob', $method->invoke($tfa, 'MZXW6YQ=')); - $this->assertEquals('fooba', $method->invoke($tfa, 'MZXW6YTB')); - $this->assertEquals('foobar', $method->invoke($tfa, 'MZXW6YTBOI======')); - } - - public function testKnownBase32DecodeUnpaddedTestVectors() { - // See testKnownBase32DecodeTestVectors() for the rationale behind testing the private base32Decode() method. - // This test ensures that strings without the padding-char ('=') are also decoded correctly. - // https://tools.ietf.org/html/rfc4648#page-4: - // "In some circumstances, the use of padding ("=") in base-encoded data is not required or used." - $tfa = new TwoFactorAuth('Test'); - - $method = new ReflectionMethod('RobThree\Auth\TwoFactorAuth', 'base32Decode'); - $method->setAccessible(true); - - // Test vectors from: https://tools.ietf.org/html/rfc4648#page-12 - $this->assertEquals('', $method->invoke($tfa, '')); - $this->assertEquals('f', $method->invoke($tfa, 'MY')); - $this->assertEquals('fo', $method->invoke($tfa, 'MZXQ')); - $this->assertEquals('foo', $method->invoke($tfa, 'MZXW6')); - $this->assertEquals('foob', $method->invoke($tfa, 'MZXW6YQ')); - $this->assertEquals('fooba', $method->invoke($tfa, 'MZXW6YTB')); - $this->assertEquals('foobar', $method->invoke($tfa, 'MZXW6YTBOI')); - } - - - public function testKnownTestVectors_sha1() { - //Known test vectors for SHA1: https://tools.ietf.org/html/rfc6238#page-15 - $secret = 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ'; //== base32encode('12345678901234567890') - $tfa = new TwoFactorAuth('Test', 8, 30, 'sha1'); - $this->assertEquals('94287082', $tfa->getCode($secret, 59)); - $this->assertEquals('07081804', $tfa->getCode($secret, 1111111109)); - $this->assertEquals('14050471', $tfa->getCode($secret, 1111111111)); - $this->assertEquals('89005924', $tfa->getCode($secret, 1234567890)); - $this->assertEquals('69279037', $tfa->getCode($secret, 2000000000)); - $this->assertEquals('65353130', $tfa->getCode($secret, 20000000000)); - } - - public function testKnownTestVectors_sha256() { - //Known test vectors for SHA256: https://tools.ietf.org/html/rfc6238#page-15 - $secret = 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZA'; //== base32encode('12345678901234567890123456789012') - $tfa = new TwoFactorAuth('Test', 8, 30, 'sha256'); - $this->assertEquals('46119246', $tfa->getCode($secret, 59)); - $this->assertEquals('68084774', $tfa->getCode($secret, 1111111109)); - $this->assertEquals('67062674', $tfa->getCode($secret, 1111111111)); - $this->assertEquals('91819424', $tfa->getCode($secret, 1234567890)); - $this->assertEquals('90698825', $tfa->getCode($secret, 2000000000)); - $this->assertEquals('77737706', $tfa->getCode($secret, 20000000000)); - } - - public function testKnownTestVectors_sha512() { - //Known test vectors for SHA512: https://tools.ietf.org/html/rfc6238#page-15 - $secret = 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNA'; //== base32encode('1234567890123456789012345678901234567890123456789012345678901234') - $tfa = new TwoFactorAuth('Test', 8, 30, 'sha512'); - $this->assertEquals('90693936', $tfa->getCode($secret, 59)); - $this->assertEquals('25091201', $tfa->getCode($secret, 1111111109)); - $this->assertEquals('99943326', $tfa->getCode($secret, 1111111111)); - $this->assertEquals('93441116', $tfa->getCode($secret, 1234567890)); - $this->assertEquals('38618901', $tfa->getCode($secret, 2000000000)); - $this->assertEquals('47863826', $tfa->getCode($secret, 20000000000)); - } - - /** - * @requires function random_bytes - */ - public function testCSRNGProvidersReturnExpectedNumberOfBytes() { - $rng = new \RobThree\Auth\Providers\Rng\CSRNGProvider(); - foreach ($this->getRngTestLengths() as $l) - $this->assertEquals($l, strlen($rng->getRandomBytes($l))); - $this->assertEquals(true, $rng->isCryptographicallySecure()); - } - - /** - * @requires function hash_algos - * @requires function hash - */ - public function testHashRNGProvidersReturnExpectedNumberOfBytes() { - $rng = new \RobThree\Auth\Providers\Rng\HashRNGProvider(); - foreach ($this->getRngTestLengths() as $l) - $this->assertEquals($l, strlen($rng->getRandomBytes($l))); - $this->assertEquals(false, $rng->isCryptographicallySecure()); - } - - /** - * @requires function mcrypt_create_iv - */ - public function testMCryptRNGProvidersReturnExpectedNumberOfBytes() { - $rng = new \RobThree\Auth\Providers\Rng\MCryptRNGProvider(); - foreach ($this->getRngTestLengths() as $l) - $this->assertEquals($l, strlen($rng->getRandomBytes($l))); - $this->assertEquals(true, $rng->isCryptographicallySecure()); - } - - /** - * @requires function openssl_random_pseudo_bytes - */ - public function testStrongOpenSSLRNGProvidersReturnExpectedNumberOfBytes() { - $rng = new \RobThree\Auth\Providers\Rng\OpenSSLRNGProvider(true); - foreach ($this->getRngTestLengths() as $l) - $this->assertEquals($l, strlen($rng->getRandomBytes($l))); - $this->assertEquals(true, $rng->isCryptographicallySecure()); - } - - /** - * @requires function openssl_random_pseudo_bytes - */ - public function testNonStrongOpenSSLRNGProvidersReturnExpectedNumberOfBytes() { - $rng = new \RobThree\Auth\Providers\Rng\OpenSSLRNGProvider(false); - foreach ($this->getRngTestLengths() as $l) - $this->assertEquals($l, strlen($rng->getRandomBytes($l))); - $this->assertEquals(false, $rng->isCryptographicallySecure()); - } - - - private function getRngTestLengths() { - return array(1, 16, 32, 256); - } - - private function DecodeDataUri($datauri) { - if (preg_match('/data:(?P