generated from jric11/baseProject
Initial commit
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AztecHintTest.php
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Com\Tecnick\Barcode\Type\Square\Aztec\AztecHint;
|
||||
|
||||
/**
|
||||
* AztecHint enum test
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class AztecHintTest extends TestUtil
|
||||
{
|
||||
public function testCaseBackingValues(): void
|
||||
{
|
||||
$this->assertSame('A', AztecHint::Automatic->value);
|
||||
$this->assertSame('B', AztecHint::Binary->value);
|
||||
}
|
||||
|
||||
public function testFromLooseCanonical(): void
|
||||
{
|
||||
$this->assertSame(AztecHint::Automatic, AztecHint::fromLoose('A'));
|
||||
$this->assertSame(AztecHint::Binary, AztecHint::fromLoose('B'));
|
||||
}
|
||||
|
||||
public function testFromLoosePassesThroughEnumInstance(): void
|
||||
{
|
||||
$this->assertSame(AztecHint::Binary, AztecHint::fromLoose(AztecHint::Binary));
|
||||
}
|
||||
|
||||
public function testFromLooseRoundTrip(): void
|
||||
{
|
||||
foreach (AztecHint::cases() as $case) {
|
||||
$this->assertSame($case, AztecHint::fromLoose($case->value));
|
||||
}
|
||||
}
|
||||
|
||||
public function testFromLooseUnknownFallsBackToAutomatic(): void
|
||||
{
|
||||
$this->assertSame(AztecHint::Automatic, AztecHint::fromLoose('C'));
|
||||
$this->assertSame(AztecHint::Automatic, AztecHint::fromLoose(''));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AztecRangeTest.php
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Com\Tecnick\Barcode\Type\Square\Aztec\AztecRange;
|
||||
|
||||
/**
|
||||
* AztecRange enum test
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class AztecRangeTest extends TestUtil
|
||||
{
|
||||
public function testCaseBackingValues(): void
|
||||
{
|
||||
$this->assertSame('A', AztecRange::Automatic->value);
|
||||
$this->assertSame('F', AztecRange::FullRange->value);
|
||||
}
|
||||
|
||||
public function testFromLooseCanonical(): void
|
||||
{
|
||||
$this->assertSame(AztecRange::Automatic, AztecRange::fromLoose('A'));
|
||||
$this->assertSame(AztecRange::FullRange, AztecRange::fromLoose('F'));
|
||||
}
|
||||
|
||||
public function testFromLoosePassesThroughEnumInstance(): void
|
||||
{
|
||||
$this->assertSame(AztecRange::FullRange, AztecRange::fromLoose(AztecRange::FullRange));
|
||||
}
|
||||
|
||||
public function testFromLooseRoundTrip(): void
|
||||
{
|
||||
foreach (AztecRange::cases() as $case) {
|
||||
$this->assertSame($case, AztecRange::fromLoose($case->value));
|
||||
}
|
||||
}
|
||||
|
||||
public function testFromLooseUnknownFallsBackToAutomatic(): void
|
||||
{
|
||||
$this->assertSame(AztecRange::Automatic, AztecRange::fromLoose('X'));
|
||||
$this->assertSame(AztecRange::Automatic, AztecRange::fromLoose(''));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,439 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* BarcodeTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class BarcodeTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetBarcodeObjException(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('ERROR', '01001100011100001111,10110011100011110000', -2, -2, 'purple');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testSetPaddingException(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
/** @var array{0: int, 1: int, 2: int, 3: int} $invalidPadding */
|
||||
$invalidPadding = [10];
|
||||
$barcode->getBarcodeObj(
|
||||
'LRAW,AB,12,E3F',
|
||||
'01001100011100001111,10110011100011110000',
|
||||
-2,
|
||||
-2,
|
||||
'purple',
|
||||
$invalidPadding,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testEmptyColumns(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('LRAW', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testEmptyInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('LRAW', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testSpotColor(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('LRAW', '01001100011100001111,10110011100011110000', -2, -2, 'all', [
|
||||
-2,
|
||||
3,
|
||||
0,
|
||||
1,
|
||||
]);
|
||||
$bobjarr = $type->getArray();
|
||||
$this->assertEquals('#000000ff', $bobjarr['color_obj']->getRgbaHexColor());
|
||||
$this->assertNUll($bobjarr['bg_color_obj']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testBackgroundColor(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('LRAW', '01001100011100001111,10110011100011110000', -2, -2, 'all', [
|
||||
-2,
|
||||
3,
|
||||
0,
|
||||
1,
|
||||
])->setBackgroundColor('mediumaquamarine');
|
||||
$bobjarr = $type->getArray();
|
||||
$this->assertNotNull($bobjarr['bg_color_obj']);
|
||||
$this->assertEquals('#66cdaaff', $bobjarr['bg_color_obj']->getRgbaHexColor());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testNoColorException(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('LRAW', '01001100011100001111,10110011100011110000', -2, -2, '', [-2, 3, 0, 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testExportMethods(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj(
|
||||
'LRAW,AB,12,E3F',
|
||||
'01001100011100001111,10110011100011110000',
|
||||
-2,
|
||||
-2,
|
||||
'purple',
|
||||
[-2, 3, 0, 1],
|
||||
);
|
||||
|
||||
$this->assertEquals('01001100011100001111,10110011100011110000', $type->getExtendedCode());
|
||||
|
||||
$barr = $type->getArray();
|
||||
$this->assertEquals('linear', $barr['type']);
|
||||
$this->assertEquals('LRAW', $barr['format']);
|
||||
$this->assertEquals(['AB', '12', 'E3F'], $barr['params']);
|
||||
$this->assertEquals('01001100011100001111,10110011100011110000', $barr['code']);
|
||||
$this->assertEquals('01001100011100001111,10110011100011110000', $barr['extcode']);
|
||||
$this->assertEquals(20, $barr['ncols']);
|
||||
$this->assertEquals(2, $barr['nrows']);
|
||||
$this->assertEquals(40, $barr['width']);
|
||||
$this->assertEquals(4, $barr['height']);
|
||||
$this->assertEquals(2, $barr['width_ratio']);
|
||||
$this->assertEquals(2, $barr['height_ratio']);
|
||||
$this->assertEquals(
|
||||
[
|
||||
'T' => 4,
|
||||
'R' => 3,
|
||||
'B' => 0,
|
||||
'L' => 1,
|
||||
],
|
||||
$barr['padding'],
|
||||
);
|
||||
$this->assertEquals(44, $barr['full_width']);
|
||||
$this->assertEquals(8, $barr['full_height']);
|
||||
|
||||
$expected = [
|
||||
[1, 0, 1, 1],
|
||||
[4, 0, 2, 1],
|
||||
[9, 0, 3, 1],
|
||||
[16, 0, 4, 1],
|
||||
[0, 1, 1, 1],
|
||||
[2, 1, 2, 1],
|
||||
[6, 1, 3, 1],
|
||||
[12, 1, 4, 1],
|
||||
];
|
||||
$this->assertEquals($expected, $barr['bars']);
|
||||
$this->assertEquals('#800080ff', $barr['color_obj']->getRgbaHexColor());
|
||||
|
||||
$grid = $type->getGrid('A', 'B');
|
||||
$expected = "ABAABBAAABBBAAAABBBB\nBABBAABBBAAABBBBAAAA\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$svg = $type->setBackgroundColor('yellow')->getSvgCode();
|
||||
$expected =
|
||||
'<?xml version="1.0" standalone="no" ?>
|
||||
<svg'
|
||||
. ' version="1.2"'
|
||||
. ' baseProfile="full"'
|
||||
. ' xmlns="http://www.w3.org/2000/svg"'
|
||||
. ' xmlns:xlink="http://www.w3.org/1999/xlink"'
|
||||
. ' xmlns:ev="http://www.w3.org/2001/xml-events"'
|
||||
. ' width="44.000000"'
|
||||
. ' height="8.000000"'
|
||||
. ' viewBox="0 0 44.000000 8.000000">
|
||||
<desc>01001100011100001111,10110011100011110000</desc>
|
||||
<rect x="0" y="0" width="44.000000" height="8.000000" fill="#ffff00"'
|
||||
. ' stroke="none" stroke-width="0" stroke-linecap="square" />
|
||||
<g id="bars" fill="#800080" stroke="none" stroke-width="0" stroke-linecap="square">
|
||||
<rect x="3.000000" y="4.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="9.000000" y="4.000000" width="4.000000" height="2.000000" />
|
||||
<rect x="19.000000" y="4.000000" width="6.000000" height="2.000000" />
|
||||
<rect x="33.000000" y="4.000000" width="8.000000" height="2.000000" />
|
||||
<rect x="1.000000" y="6.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="5.000000" y="6.000000" width="4.000000" height="2.000000" />
|
||||
<rect x="13.000000" y="6.000000" width="6.000000" height="2.000000" />
|
||||
<rect x="25.000000" y="6.000000" width="8.000000" height="2.000000" />
|
||||
<rect x="1.000000" y="6.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="3.000000" y="4.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="5.000000" y="6.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="7.000000" y="6.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="9.000000" y="4.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="11.000000" y="4.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="13.000000" y="6.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="15.000000" y="6.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="17.000000" y="6.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="19.000000" y="4.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="21.000000" y="4.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="23.000000" y="4.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="25.000000" y="6.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="27.000000" y="6.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="29.000000" y="6.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="31.000000" y="6.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="33.000000" y="4.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="35.000000" y="4.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="37.000000" y="4.000000" width="2.000000" height="2.000000" />
|
||||
<rect x="39.000000" y="4.000000" width="2.000000" height="2.000000" />
|
||||
</g>
|
||||
</svg>
|
||||
';
|
||||
$this->assertEquals($expected, $svg);
|
||||
|
||||
$hdiv = $type->setBackgroundColor('lightcoral')->getHtmlDiv();
|
||||
$expected =
|
||||
'<div style="width:44.000000px;height:8.000000px;position:relative;font-size:0;'
|
||||
. 'border:none;padding:0;margin:0;background-color:rgb(94%,50%,50%);">
|
||||
<div style="background-color:rgb(50%,0%,50%);left:3.000000px;top:4.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:9.000000px;top:4.000000px;'
|
||||
. 'width:4.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:19.000000px;top:4.000000px;'
|
||||
. 'width:6.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:33.000000px;top:4.000000px;'
|
||||
. 'width:8.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:1.000000px;top:6.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:5.000000px;top:6.000000px;'
|
||||
. 'width:4.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:13.000000px;top:6.000000px;'
|
||||
. 'width:6.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:25.000000px;top:6.000000px;'
|
||||
. 'width:8.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:1.000000px;top:6.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:3.000000px;top:4.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:5.000000px;top:6.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:7.000000px;top:6.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:9.000000px;top:4.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:11.000000px;top:4.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:13.000000px;top:6.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:15.000000px;top:6.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:17.000000px;top:6.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:19.000000px;top:4.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:21.000000px;top:4.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:23.000000px;top:4.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:25.000000px;top:6.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:27.000000px;top:6.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:29.000000px;top:6.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:31.000000px;top:6.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:33.000000px;top:4.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:35.000000px;top:4.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:37.000000px;top:4.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
<div style="background-color:rgb(50%,0%,50%);left:39.000000px;top:4.000000px;'
|
||||
. 'width:2.000000px;height:2.000000px;position:absolute;border:none;padding:0;margin:0;"> </div>
|
||||
</div>
|
||||
';
|
||||
$this->assertEquals($expected, $hdiv);
|
||||
|
||||
if (\extension_loaded('imagick')) {
|
||||
$pngik = $type->setBackgroundColor('white')->getPngData(true);
|
||||
$this->assertEquals('PNG', \substr($pngik, 1, 3));
|
||||
}
|
||||
|
||||
$pnggd = $type->setBackgroundColor('white')->getPngData(false);
|
||||
$this->assertEquals('PNG', \substr($pnggd, 1, 3));
|
||||
|
||||
$pnggd = $type->setBackgroundColor('')->getPngData(false);
|
||||
$this->assertEquals('PNG', \substr($pnggd, 1, 3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetSvg(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj(
|
||||
'LRAW,AB,12,E3F',
|
||||
'01001100011100001111,10110011100011110000',
|
||||
-2,
|
||||
-2,
|
||||
'purple',
|
||||
);
|
||||
|
||||
// empty filename
|
||||
\ob_start();
|
||||
$type->getSvg();
|
||||
$svg = \ob_get_clean();
|
||||
$this->assertNotFalse($svg);
|
||||
$this->assertEquals('114f33435c265345f7c6cdf673922292', \md5($svg));
|
||||
$headers = $this->getResponseHeaders();
|
||||
$this->assertEquals(
|
||||
'Content-Disposition: inline; filename="114f33435c265345f7c6cdf673922292.svg";',
|
||||
$headers[5] ?? '',
|
||||
);
|
||||
|
||||
// invalid filename
|
||||
\ob_start();
|
||||
$type->getSvg('#~');
|
||||
$svg = \ob_get_clean();
|
||||
$this->assertNotFalse($svg);
|
||||
$this->assertEquals('114f33435c265345f7c6cdf673922292', \md5($svg));
|
||||
$headers = $this->getResponseHeaders();
|
||||
$this->assertEquals(
|
||||
'Content-Disposition: inline; filename="114f33435c265345f7c6cdf673922292.svg";',
|
||||
$headers[5] ?? '',
|
||||
);
|
||||
|
||||
// valid filename
|
||||
\ob_start();
|
||||
$type->getSvg('test_SVG_filename-001');
|
||||
$svg = \ob_get_clean();
|
||||
$this->assertNotFalse($svg);
|
||||
$this->assertEquals('114f33435c265345f7c6cdf673922292', \md5($svg));
|
||||
$headers = $this->getResponseHeaders();
|
||||
$this->assertEquals('Content-Disposition: inline; filename="test_SVG_filename-001.svg";', $headers[5] ?? '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetPng(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj(
|
||||
'LRAW,AB,12,E3F',
|
||||
'01001100011100001111,10110011100011110000',
|
||||
-2,
|
||||
-2,
|
||||
'purple',
|
||||
);
|
||||
|
||||
// empty filename
|
||||
\ob_start();
|
||||
$type->getPng();
|
||||
$png = \ob_get_clean();
|
||||
$this->assertNotFalse($png);
|
||||
$this->assertEquals('PNG', \substr($png, 1, 3));
|
||||
$headers = $this->getResponseHeaders();
|
||||
$this->assertNotEmpty($headers[5] ?? '');
|
||||
|
||||
// invalid filename
|
||||
\ob_start();
|
||||
$type->getPng('#~');
|
||||
$png = \ob_get_clean();
|
||||
$this->assertNotFalse($png);
|
||||
$this->assertEquals('PNG', \substr($png, 1, 3));
|
||||
$headers = $this->getResponseHeaders();
|
||||
$this->assertNotEmpty($headers[5] ?? '');
|
||||
|
||||
// valid filename
|
||||
\ob_start();
|
||||
$type->getPng('test_PNG_filename-001');
|
||||
$png = \ob_get_clean();
|
||||
$this->assertNotFalse($png);
|
||||
$this->assertEquals('PNG', \substr($png, 1, 3));
|
||||
$headers = $this->getResponseHeaders();
|
||||
$this->assertEquals('Content-Disposition: inline; filename="test_PNG_filename-001.png";', $headers[5] ?? '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: an over-long payload must be rejected early.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testPayloadTooLong(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('QRCODE', \str_pad('', 30001, 'A'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: a pathological size multiplier must not trigger a huge image allocation.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testImageTooLarge(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('QRCODE', 'test', -100000, -100000);
|
||||
$type->getGd();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* BarcodeTypeTest.php
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Com\Tecnick\Barcode\Barcode;
|
||||
use Com\Tecnick\Barcode\BarcodeType;
|
||||
use Com\Tecnick\Barcode\Exception as BarcodeException;
|
||||
|
||||
/**
|
||||
* BarcodeType enum test
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class BarcodeTypeTest extends TestUtil
|
||||
{
|
||||
public function testCaseBackingValues(): void
|
||||
{
|
||||
$this->assertSame('C128', BarcodeType::C128->value);
|
||||
$this->assertSame('C39+', BarcodeType::C39Plus->value);
|
||||
$this->assertSame('QRCODE', BarcodeType::QRCODE->value);
|
||||
$this->assertSame('DATAMATRIX', BarcodeType::DATAMATRIX->value);
|
||||
$this->assertCount(37, BarcodeType::cases());
|
||||
}
|
||||
|
||||
/**
|
||||
* Every enum backing value must be a valid Barcode::BARCODETYPES key.
|
||||
*/
|
||||
public function testCasesMatchBarcodeTypesKeys(): void
|
||||
{
|
||||
$keys = \array_keys(Barcode::BARCODETYPES);
|
||||
foreach (BarcodeType::cases() as $case) {
|
||||
$this->assertContains($case->value, $keys);
|
||||
}
|
||||
$this->assertCount(\count($keys), BarcodeType::cases());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BarcodeException
|
||||
*/
|
||||
public function testFromLooseCanonical(): void
|
||||
{
|
||||
$this->assertSame(BarcodeType::QRCODE, BarcodeType::fromLoose('QRCODE'));
|
||||
$this->assertSame(BarcodeType::S25Plus, BarcodeType::fromLoose('S25+'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BarcodeException
|
||||
*/
|
||||
public function testFromLoosePassesThroughEnumInstance(): void
|
||||
{
|
||||
$this->assertSame(BarcodeType::AZTEC, BarcodeType::fromLoose(BarcodeType::AZTEC));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BarcodeException
|
||||
*/
|
||||
public function testFromLooseRoundTrip(): void
|
||||
{
|
||||
foreach (BarcodeType::cases() as $case) {
|
||||
$this->assertSame($case, BarcodeType::fromLoose($case->value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BarcodeException
|
||||
*/
|
||||
public function testFromLooseUnknownThrows(): void
|
||||
{
|
||||
$this->bcExpectException(BarcodeException::class);
|
||||
BarcodeType::fromLoose('NOPE');
|
||||
}
|
||||
|
||||
/**
|
||||
* The widened getBarcodeObj() accepts a BarcodeType enum and produces the
|
||||
* same barcode as the equivalent leading-token string.
|
||||
*
|
||||
* @throws BarcodeException
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetBarcodeObjAcceptsEnum(): void
|
||||
{
|
||||
$barcode = new Barcode();
|
||||
$fromEnum = $barcode->getBarcodeObj(BarcodeType::C39, 'TEST123');
|
||||
$fromString = $barcode->getBarcodeObj('C39', 'TEST123');
|
||||
$this->assertSame($fromString->getSvgCode(), $fromEnum->getSvgCode());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ConvertTest.php
|
||||
*
|
||||
* @since 2026-05-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Test\Fixture\InternalConvert;
|
||||
|
||||
class ConvertTest extends TestUtil
|
||||
{
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
*/
|
||||
public function testProcessBinarySequenceThrowsOnEmptyRows(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$helper = new InternalConvert();
|
||||
$helper->exposeProcessBinarySequence([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
*/
|
||||
public function testProcessBinarySequenceParsesStringRows(): void
|
||||
{
|
||||
$helper = new InternalConvert();
|
||||
$helper->exposeProcessBinarySequence(['1010', '0101']);
|
||||
|
||||
$this->assertSame(
|
||||
[
|
||||
[0, 0, 1, 1],
|
||||
[2, 0, 1, 1],
|
||||
[1, 1, 1, 1],
|
||||
[3, 1, 1, 1],
|
||||
],
|
||||
$helper->getBars(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
*/
|
||||
public function testRawRowsAndNumberConversionBranches(): void
|
||||
{
|
||||
$helper = new InternalConvert();
|
||||
|
||||
$this->assertSame(['1010', '0101'], $helper->exposeGetRawCodeRows(' ,[1010,0101], '));
|
||||
|
||||
$this->assertSame('00', $helper->exposeConvertDecToHex('abc'));
|
||||
$this->assertSame('00', $helper->exposeConvertDecToHex('0'));
|
||||
$this->assertSame('FF', $helper->exposeConvertDecToHex('255'));
|
||||
$this->assertSame('255', $helper->exposeConvertHexToDec('FF'));
|
||||
}
|
||||
|
||||
public function testGridArraySkipsInvalidBarsAndRotatedEarlyReturn(): void
|
||||
{
|
||||
$helper = new InternalConvert();
|
||||
$helper->setColsRows(5, 3);
|
||||
$helper->setBars([
|
||||
[0, 0, 0, 1],
|
||||
[1, 0, 2, 0],
|
||||
[1, 1, 2, 1],
|
||||
]);
|
||||
|
||||
$grid = $helper->getGridArray('.', '#');
|
||||
$this->assertSame(
|
||||
[
|
||||
['.', '.', '.', '.', '.'],
|
||||
['.', '#', '#', '.', '.'],
|
||||
['.', '.', '.', '.', '.'],
|
||||
],
|
||||
$grid,
|
||||
);
|
||||
|
||||
$helper->setColsRows(0, 0);
|
||||
$helper->setBars([]);
|
||||
$this->assertSame([], $helper->exposeGetRotatedBarArray());
|
||||
}
|
||||
|
||||
public function testRectHelpersAndRotatedBarsExtraction(): void
|
||||
{
|
||||
$helper = new InternalConvert();
|
||||
$helper->setColsRows(3, 2);
|
||||
$helper->setBars([
|
||||
[0, 0, 1, 2],
|
||||
[2, 0, 1, 2],
|
||||
]);
|
||||
$helper->setRatiosAndPadding(2.0, 3.0, ['T' => 4, 'R' => 0, 'B' => 0, 'L' => 5]);
|
||||
|
||||
$this->assertSame(
|
||||
[
|
||||
[0, 0, 1, 2],
|
||||
[2, 0, 1, 2],
|
||||
],
|
||||
$helper->exposeGetRotatedBarArray(),
|
||||
);
|
||||
|
||||
$this->assertSame([7.0, 7.0, 8.0, 9.0], $helper->exposeGetBarRectXYXY([1, 1, 1, 1]));
|
||||
$this->assertSame([7.0, 7.0, 2.0, 3.0], $helper->exposeGetBarRectXYWH([1, 1, 1, 1]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* DatamatrixEncodingTest.php
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Com\Tecnick\Barcode\Type\Square\Datamatrix\DatamatrixEncoding;
|
||||
|
||||
/**
|
||||
* DatamatrixEncoding enum test
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class DatamatrixEncodingTest extends TestUtil
|
||||
{
|
||||
public function testCaseBackingValues(): void
|
||||
{
|
||||
$this->assertSame('ASCII', DatamatrixEncoding::ASCII->value);
|
||||
$this->assertSame('C40', DatamatrixEncoding::C40->value);
|
||||
$this->assertSame('TXT', DatamatrixEncoding::TXT->value);
|
||||
$this->assertSame('X12', DatamatrixEncoding::X12->value);
|
||||
$this->assertSame('EDF', DatamatrixEncoding::EDF->value);
|
||||
$this->assertSame('BASE256', DatamatrixEncoding::BASE256->value);
|
||||
}
|
||||
|
||||
public function testFromLooseCanonical(): void
|
||||
{
|
||||
$this->assertSame(DatamatrixEncoding::C40, DatamatrixEncoding::fromLoose('C40'));
|
||||
$this->assertSame(DatamatrixEncoding::BASE256, DatamatrixEncoding::fromLoose('BASE256'));
|
||||
}
|
||||
|
||||
public function testFromLoosePassesThroughEnumInstance(): void
|
||||
{
|
||||
$this->assertSame(DatamatrixEncoding::X12, DatamatrixEncoding::fromLoose(DatamatrixEncoding::X12));
|
||||
}
|
||||
|
||||
public function testFromLooseRoundTrip(): void
|
||||
{
|
||||
foreach (DatamatrixEncoding::cases() as $case) {
|
||||
$this->assertSame($case, DatamatrixEncoding::fromLoose($case->value));
|
||||
}
|
||||
}
|
||||
|
||||
public function testFromLooseUnknownFallsBackToAscii(): void
|
||||
{
|
||||
$this->assertSame(DatamatrixEncoding::ASCII, DatamatrixEncoding::fromLoose('EDIFACT'));
|
||||
$this->assertSame(DatamatrixEncoding::ASCII, DatamatrixEncoding::fromLoose(''));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* DatamatrixShapeTest.php
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Com\Tecnick\Barcode\Type\Square\Datamatrix\DatamatrixShape;
|
||||
|
||||
/**
|
||||
* DatamatrixShape enum test
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class DatamatrixShapeTest extends TestUtil
|
||||
{
|
||||
public function testCaseBackingValues(): void
|
||||
{
|
||||
$this->assertSame('S', DatamatrixShape::Square->value);
|
||||
$this->assertSame('R', DatamatrixShape::Rectangular->value);
|
||||
}
|
||||
|
||||
public function testFromLooseCanonical(): void
|
||||
{
|
||||
$this->assertSame(DatamatrixShape::Square, DatamatrixShape::fromLoose('S'));
|
||||
$this->assertSame(DatamatrixShape::Rectangular, DatamatrixShape::fromLoose('R'));
|
||||
}
|
||||
|
||||
public function testFromLoosePassesThroughEnumInstance(): void
|
||||
{
|
||||
$this->assertSame(DatamatrixShape::Rectangular, DatamatrixShape::fromLoose(DatamatrixShape::Rectangular));
|
||||
}
|
||||
|
||||
public function testFromLooseRoundTrip(): void
|
||||
{
|
||||
foreach (DatamatrixShape::cases() as $case) {
|
||||
$this->assertSame($case, DatamatrixShape::fromLoose($case->value));
|
||||
}
|
||||
}
|
||||
|
||||
public function testFromLooseUnknownFallsBackToSquare(): void
|
||||
{
|
||||
$this->assertSame(DatamatrixShape::Square, DatamatrixShape::fromLoose('r'));
|
||||
$this->assertSame(DatamatrixShape::Square, DatamatrixShape::fromLoose(''));
|
||||
$this->assertSame(DatamatrixShape::Square, DatamatrixShape::fromLoose('X'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* FallbackMath.php
|
||||
*
|
||||
* @since 2026-08-06
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Fixture;
|
||||
|
||||
use Com\Tecnick\Barcode\Math;
|
||||
|
||||
/**
|
||||
* Forces the pure-PHP arithmetic used when the bcmath extension is not available.
|
||||
*/
|
||||
trait FallbackMath
|
||||
{
|
||||
/**
|
||||
* @param numeric-string $left
|
||||
* @param numeric-string $right
|
||||
*
|
||||
* @return numeric-string
|
||||
*/
|
||||
protected function addNumeric(string $left, string $right): string
|
||||
{
|
||||
return Math::fallbackAdd($left, $right);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param numeric-string $left
|
||||
* @param numeric-string $right
|
||||
*
|
||||
* @return numeric-string
|
||||
*/
|
||||
protected function mulNumeric(string $left, string $right): string
|
||||
{
|
||||
return Math::fallbackMul($left, $right);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param numeric-string $left
|
||||
* @param numeric-string $right
|
||||
*
|
||||
* @return numeric-string
|
||||
*/
|
||||
protected function divNumeric(string $left, string $right): string
|
||||
{
|
||||
return Math::fallbackDiv($left, $right);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param numeric-string $left
|
||||
* @param numeric-string $right
|
||||
*/
|
||||
protected function modNumeric(string $left, string $right): int
|
||||
{
|
||||
return (int) Math::fallbackMod($left, $right);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* FallbackMathImb.php
|
||||
*
|
||||
* @since 2026-08-06
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Fixture;
|
||||
|
||||
class FallbackMathImb extends \Com\Tecnick\Barcode\Type\Linear\Imb
|
||||
{
|
||||
use FallbackMath;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* FallbackMathPdfFourOneSeven.php
|
||||
*
|
||||
* @since 2026-08-06
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Fixture;
|
||||
|
||||
class FallbackMathPdfFourOneSeven extends \Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven
|
||||
{
|
||||
use FallbackMath;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* InternalBarcodeType.php
|
||||
*
|
||||
* @since 2026-04-19
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Fixture;
|
||||
|
||||
class InternalBarcodeType extends \Com\Tecnick\Barcode\Type
|
||||
{
|
||||
protected const TYPE = 'linear';
|
||||
|
||||
protected const FORMAT = 'INTERNAL';
|
||||
|
||||
/**
|
||||
* @var array<int, array{int, int, int, int}>|null
|
||||
*/
|
||||
private ?array $rotatedBarsOverride = null;
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function __construct(
|
||||
private bool $useParentHooks = false,
|
||||
) {
|
||||
$this->ncols = 2;
|
||||
$this->nrows = 1;
|
||||
|
||||
parent::__construct('12', -2, -3, 'black', [], [-2, -1, 0, 1]);
|
||||
}
|
||||
|
||||
protected function setParameters(): void
|
||||
{
|
||||
if ($this->useParentHooks) {
|
||||
parent::setParameters();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->params = ['ok'];
|
||||
}
|
||||
|
||||
protected function setBars(): void
|
||||
{
|
||||
if ($this->useParentHooks) {
|
||||
parent::setBars();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->bars = [[0, 0, 1, 1]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array{int, int, int, int}> $bars
|
||||
*/
|
||||
public function setBarsForTest(array $bars): void
|
||||
{
|
||||
$this->bars = $bars;
|
||||
}
|
||||
|
||||
public function setRowsColsForTest(int $nrows, int $ncols): void
|
||||
{
|
||||
$this->nrows = $nrows;
|
||||
$this->ncols = $ncols;
|
||||
}
|
||||
|
||||
public function setRatiosForTest(float $widthRatio, float $heightRatio): void
|
||||
{
|
||||
$this->width_ratio = $widthRatio;
|
||||
$this->height_ratio = $heightRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array{int, int, int, int}>|null $bars
|
||||
*/
|
||||
public function setRotatedBarsOverrideForTest(?array $bars): void
|
||||
{
|
||||
$this->rotatedBarsOverride = $bars;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{int, int, int, int}>
|
||||
*/
|
||||
protected function getRotatedBarArray(): array
|
||||
{
|
||||
if ($this->rotatedBarsOverride !== null) {
|
||||
return $this->rotatedBarsOverride;
|
||||
}
|
||||
|
||||
return parent::getRotatedBarArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* InternalConvert.php
|
||||
*
|
||||
* @since 2026-05-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Fixture;
|
||||
|
||||
class InternalConvert extends \Com\Tecnick\Barcode\Type\Convert
|
||||
{
|
||||
/**
|
||||
* @param array<int, string|array<int>> $rows
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
*/
|
||||
public function exposeProcessBinarySequence(array $rows): void
|
||||
{
|
||||
$this->processBinarySequence($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function exposeGetRawCodeRows(string $data): array
|
||||
{
|
||||
return $this->getRawCodeRows($data);
|
||||
}
|
||||
|
||||
public function exposeConvertDecToHex(string $number): string
|
||||
{
|
||||
return $this->convertDecToHex($number);
|
||||
}
|
||||
|
||||
public function exposeConvertHexToDec(string $hex): string
|
||||
{
|
||||
return $this->convertHexToDec($hex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{int, int, int, int}>
|
||||
*/
|
||||
public function exposeGetRotatedBarArray(): array
|
||||
{
|
||||
return $this->getRotatedBarArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array{int, int, int, int}> $bars
|
||||
*/
|
||||
public function setBars(array $bars): void
|
||||
{
|
||||
$this->bars = $bars;
|
||||
}
|
||||
|
||||
public function setColsRows(int $ncols, int $nrows): void
|
||||
{
|
||||
$this->ncols = $ncols;
|
||||
$this->nrows = $nrows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{'T': int, 'R': int, 'B': int, 'L': int} $padding
|
||||
*/
|
||||
public function setRatiosAndPadding(float $widthRatio, float $heightRatio, array $padding): void
|
||||
{
|
||||
$this->width_ratio = $widthRatio;
|
||||
$this->height_ratio = $heightRatio;
|
||||
$this->padding = $padding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{int, int, int, int} $bar
|
||||
*
|
||||
* @return array{float, float, float, float}
|
||||
*/
|
||||
public function exposeGetBarRectXYXY(array $bar): array
|
||||
{
|
||||
return $this->getBarRectXYXY($bar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{int, int, int, int} $bar
|
||||
*
|
||||
* @return array{float, float, float, float}
|
||||
*/
|
||||
public function exposeGetBarRectXYWH(array $bar): array
|
||||
{
|
||||
return $this->getBarRectXYWH($bar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{int, int, int, int}>
|
||||
*/
|
||||
public function getBars(): array
|
||||
{
|
||||
return \array_values($this->bars);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* InternalQrByteStream.php
|
||||
*
|
||||
* @since 2026-04-19
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Fixture;
|
||||
|
||||
/**
|
||||
* @phpstan-import-type Item from \Com\Tecnick\Barcode\Type\Square\QrCode\Estimate
|
||||
*/
|
||||
class InternalQrByteStream extends \Com\Tecnick\Barcode\Type\Square\QrCode\ByteStream
|
||||
{
|
||||
/**
|
||||
* @var array<int, array{0: array<int, Item>, 1: int}>
|
||||
*/
|
||||
public array $queuedCbs = [];
|
||||
|
||||
public ?int $forcedEstVer = null;
|
||||
|
||||
public ?int $forcedMinVer = null;
|
||||
|
||||
public function exposeLookAnTable(int $chr): int
|
||||
{
|
||||
return $this->lookAnTable($chr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, Item> $items
|
||||
* @param array<int, string> $data
|
||||
*
|
||||
* @return array<int, Item>
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
*/
|
||||
public function exposeAppendNewInputItem(array $items, int $mode, int $size, array $data): array
|
||||
{
|
||||
return $this->appendNewInputItem($items, $mode, $size, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $data
|
||||
* @param array<int, int> $bstream
|
||||
*
|
||||
* @return Item
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
*/
|
||||
public function exposeNewInputItem(int $mode, int $size, array $data, array $bstream = []): array
|
||||
{
|
||||
return $this->newInputItem($mode, $size, $data, $bstream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, int> $bstream
|
||||
*
|
||||
* @return array<int, int>
|
||||
*/
|
||||
public function exposeAppendPaddingBit(array $bstream): array
|
||||
{
|
||||
return $this->appendPaddingBit($bstream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, int> $bstream
|
||||
*
|
||||
* @return array<int, int>
|
||||
*/
|
||||
public function exposeBitstreamToByte(array $bstream): array
|
||||
{
|
||||
return $this->bitstreamToByte($bstream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, Item> $items
|
||||
*
|
||||
* @return array<int, Item>
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
*/
|
||||
public function exposeConvertData(array $items): array
|
||||
{
|
||||
return $this->convertData($items);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, Item> $items
|
||||
*
|
||||
* @return array{0: array<int, Item>, 1: int}
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
*/
|
||||
public function exposeCreateBitStream(array $items): array
|
||||
{
|
||||
return parent::createBitStream($items);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, Item> $items
|
||||
*/
|
||||
public function estimateVersion(array $items, int $level): int
|
||||
{
|
||||
return $this->forcedEstVer ?? parent::estimateVersion($items, $level);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, Item> $items
|
||||
*
|
||||
* @return array{0: array<int, Item>, 1: int}
|
||||
*/
|
||||
protected function createBitStream(array $items): array
|
||||
{
|
||||
if ($this->queuedCbs !== []) {
|
||||
return \array_shift($this->queuedCbs);
|
||||
}
|
||||
|
||||
return parent::createBitStream($items);
|
||||
}
|
||||
|
||||
protected function getMinimumVersion(int $size, int $level): int
|
||||
{
|
||||
return $this->forcedMinVer ?? parent::getMinimumVersion($size, $level);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* InternalHelpersTest.php
|
||||
*
|
||||
* @since 2026-04-19
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Test\Fixture\InternalBarcodeType;
|
||||
use Test\Fixture\InternalQrByteStream;
|
||||
|
||||
class InternalHelpersTest extends TestUtil
|
||||
{
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testBaseTypeDefaultHooksAreCovered(): void
|
||||
{
|
||||
$type = new InternalBarcodeType(true);
|
||||
$data = $type->getArray();
|
||||
|
||||
$this->assertSame([], $data['params']);
|
||||
$this->assertSame([], $data['bars']);
|
||||
$this->assertSame(4, $data['width']);
|
||||
$this->assertSame(3, $data['height']);
|
||||
$this->assertSame(['T' => 6, 'R' => 2, 'B' => 0, 'L' => 1], $data['padding']);
|
||||
|
||||
$type->setBackgroundColor('');
|
||||
$this->assertNull($type->getArray()['bg_color_obj']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testQrInputItemPaddingAndAppendBranches(): void
|
||||
{
|
||||
$helper = new InternalQrByteStream(\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_8B, 1, 0);
|
||||
|
||||
$item = $helper->exposeNewInputItem(\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_NM, 3, ['1']);
|
||||
|
||||
$this->assertSame(['1', '0', '0'], $item['data']);
|
||||
$this->assertSame(-1, $helper->exposeLookAnTable(128));
|
||||
|
||||
$items = $helper->exposeAppendNewInputItem(
|
||||
[],
|
||||
\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_AN,
|
||||
2,
|
||||
['A', 'Z'],
|
||||
);
|
||||
|
||||
$this->assertCount(1, $items);
|
||||
$firstItem = $items[0] ?? null;
|
||||
$this->assertNotNull($firstItem);
|
||||
$this->assertSame(['A', 'Z'], $firstItem['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $data
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
#[DataProvider('getInvalidQrInputItemProvider')]
|
||||
public function testQrInputItemInvalidBranches(int $mode, int $size, array $data): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
|
||||
$helper = new InternalQrByteStream(\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_8B, 1, 0);
|
||||
|
||||
$helper->exposeNewInputItem($mode, $size, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array{int, int, array<int, string>}>
|
||||
*/
|
||||
public static function getInvalidQrInputItemProvider(): array
|
||||
{
|
||||
return [
|
||||
[\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_AN, 1, ["\x80"]],
|
||||
[\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_KJ, 1, ["\x81"]],
|
||||
[999, 1, ['A']],
|
||||
[\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_NM, 0, ['1']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testQrByteStreamPaddingAndBitstreamBranches(): void
|
||||
{
|
||||
$helper = new InternalQrByteStream(\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_8B, 1, 0);
|
||||
$spec = new \Com\Tecnick\Barcode\Type\Square\QrCode\Spec();
|
||||
$maxWords = $spec->getDataLength(1, 0);
|
||||
$maxBits = $maxWords * 8;
|
||||
|
||||
$this->assertSame([], $helper->exposeAppendPaddingBit([]));
|
||||
|
||||
$exact = \array_fill(0, \max(0, $maxBits), 0);
|
||||
$this->assertSame($exact, $helper->exposeAppendPaddingBit($exact));
|
||||
|
||||
$shortBits = \max(0, $maxBits - 2);
|
||||
$short = \array_fill(0, $shortBits, 1);
|
||||
$this->assertCount($maxBits, $helper->exposeAppendPaddingBit($short));
|
||||
|
||||
$padded = $helper->exposeAppendPaddingBit([1, 0, 1, 0]);
|
||||
$this->assertCount($maxWords, $helper->exposeBitstreamToByte($padded));
|
||||
|
||||
$this->assertSame([], $helper->exposeBitstreamToByte([]));
|
||||
$this->assertSame([21], $helper->exposeBitstreamToByte([1, 0, 1, 0, 1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testQrByteStreamCreateAndConvertBranches(): void
|
||||
{
|
||||
$helper = new InternalQrByteStream(\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_8B, 1, 0);
|
||||
|
||||
$item = $helper->exposeNewInputItem(\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_NM, 3, ['1', '2', '3']);
|
||||
$stream = $helper->exposeCreateBitStream([$item]);
|
||||
$this->assertGreaterThan(0, $stream[1]);
|
||||
|
||||
$helper->forcedEstVer = 2;
|
||||
$helper->forcedMinVer = 2;
|
||||
$encoded = $helper->encodeBitStream($item, 2);
|
||||
$helper->queuedCbs = [
|
||||
[[$encoded], \count($encoded['bstream'])],
|
||||
];
|
||||
|
||||
$converted = $helper->exposeConvertData([$item]);
|
||||
$firstConverted = $converted[0] ?? null;
|
||||
$this->assertNotNull($firstConverted);
|
||||
$this->assertSame($encoded['bstream'], $firstConverted['bstream']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testQrByteStreamNegativeBitsThrowsException(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
|
||||
$helper = new InternalQrByteStream(\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_8B, 1, 0);
|
||||
$helper->forcedEstVer = 1;
|
||||
$helper->queuedCbs = [
|
||||
[[], -1],
|
||||
];
|
||||
|
||||
$helper->exposeConvertData([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testQrByteStreamEncodeBranches(): void
|
||||
{
|
||||
$helper = new InternalQrByteStream(\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_8B, 1, 0);
|
||||
|
||||
$spec = new \Com\Tecnick\Barcode\Type\Square\QrCode\Spec();
|
||||
$words = $spec->maximumWords(\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_8B, 1);
|
||||
$item = $helper->exposeNewInputItem(
|
||||
\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_8B,
|
||||
$words + 1,
|
||||
\array_fill(0, \max(0, $words + 1), 'A'),
|
||||
);
|
||||
|
||||
$encoded = $helper->encodeBitStream($item, 1);
|
||||
$this->assertNotEmpty($encoded['bstream']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testQrByteStreamEncodeInvalidModeThrowsException(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
|
||||
$helper = new InternalQrByteStream(\Com\Tecnick\Barcode\Type\Square\QrCode\Data::MODE_8B, 1, 0);
|
||||
|
||||
$helper->encodeBitStream([
|
||||
'mode' => 999,
|
||||
'size' => 1,
|
||||
'data' => ['A'],
|
||||
'bstream' => [],
|
||||
], 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testDatamatrixPaddingSizeHelper(): void
|
||||
{
|
||||
$params = \Com\Tecnick\Barcode\Type\Square\Datamatrix\Data::getPaddingSize('S', 1);
|
||||
$this->assertCount(16, $params);
|
||||
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
\Com\Tecnick\Barcode\Type\Square\Datamatrix\Data::getPaddingSize('S', PHP_INT_MAX);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CodabarTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class CodabarTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('CODABAR', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'10110010010101010011010101100101010010110110010101010110'
|
||||
. "10010110101001010010101101001011010100110101011010010101011001001\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('CODABAR', \chr(218));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CodeNineThreeTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class CodeNineThreeTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$bobj = $barcode->getBarcodeObj('C93', '0123456789');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'101011110100010100101001000101000100101000010100101000100'
|
||||
. "1001001001000101010100001000100101000010101001011001001100101010111101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C93', '012345678901234567890123456789');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'10101111010001010010100100010100010010100001010010100010010010010010001010101'
|
||||
. '000010001001010000101010001010010100100010100010010100001010010100010010010010010001'
|
||||
. '010101000010001001010000101010001010010100100010100010010100001010010100010010010010'
|
||||
. "01000101010100001000100101000010101001001001001010001010111101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('C93', \chr(255));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CodeOneOneTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class CodeOneOneTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$bobj = $barcode->getBarcodeObj('CODE11', '0123456789');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'10110010101011011010110100101101100101010110110110'
|
||||
. "11010100110101010011011010010110101010101101011001\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('CODE11', '123-456-789');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'10110010110101101001011011001010101101010110110110110'
|
||||
. "10100110101011010101001101101001011010101101101011010101011001\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('CODE11', '-');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "10110010101101010110101011001\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('CODE11', \chr(255));
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: a K check digit evaluating to 10 must be encoded as '-', not '10'.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testKCheckDigitDash(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$this->assertSame('S000000000077-S', $barcode->getBarcodeObj('CODE11', '00000000007')->getExtendedCode());
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ATest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear\CodeOneTwoEight;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class CodeOneTwoEightATest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$bobj = $barcode->getBarcodeObj('C128A', 'ABCDEFG');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'110100001001010001100010001011000100010001101011000100010001101000100011000101101'
|
||||
. "0001000100110010001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128A', '0123456789');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'110100001001001110110010011100110110011100101100101110011001001110110111001001100'
|
||||
. "1110100111011011101110100110011100101100111101110101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128A', \chr(241) . '01234567891');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'110100001001111010111010011101100100111001101100111001011001011100110010011101101'
|
||||
. "11001001100111010011101101110111010011001110010110010011100110100001101001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('C128A', \chr(246) . '01234567891');
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* BTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear\CodeOneTwoEight;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class CodeOneTwoEightBTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$bobj = $barcode->getBarcodeObj('C128B', '0123456789');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'11010010000100111011001001110011011001110010110010111001100100111011011100'
|
||||
. "10011001110100111011011101110100110011100101100110000101001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128B', \chr(241) . '01234567891');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'11010010000111101011101001110110010011100110110011100101100101110011001001'
|
||||
. "110110111001001100111010011101101110111010011001110010110010011100110100001100101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('C128B', \chr(246) . '01234567891');
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear\CodeOneTwoEight;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class CodeOneTwoEightCTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$bobj = $barcode->getBarcodeObj('C128C', '0123456789');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "110100111001100110110011101101110101110110001000010110011011011110100001101001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128C', \chr(241) . '0123456789');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'11010011100111101011101100110110011101101110101110110001000010110011011011110111101101101100'
|
||||
. "011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128C', \chr(241) . '00123456780000000001');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'11010011100111101011101101100110010110011100100010110001110001011011000010100110110011001101'
|
||||
. "1001100110110011001101100110011001101100100010011001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128C', \chr(241) . '42029651' . \chr(241) . '9405510200864168997758');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'11010011100111101011101011011100011001100110101111000101101110100011110101110100010111101000'
|
||||
. '100110011011101000110011001101101100110011110100100110001000101000010011010111011110111101110101110'
|
||||
. "1100010111100101001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidLength(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('C128C', '12345678901');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidChar(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('C128C', '1A2345678901');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CodeOneTwoEightTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class CodeOneTwoEightTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$bobj = $barcode->getBarcodeObj('C128', '0123456789');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "110100111001100110110011101101110101110110001000010110011011011110100001101001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', '1PBK500EI');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'110100100001001110011011101110110100010110001011000111011011100100100111011001001'
|
||||
. "11011001000110100011000100010111011001001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', 'SCB500J1C3Y');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'110100100001101110100010001000110100010110001101110010010011101100100111011001011'
|
||||
. "011100010011100110100010001101100101110011101101000110110111101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', '067023611120229212');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'110100111001001100100010110000100111011011101100100001011000100100110010011101100111010010101111'
|
||||
. "00010110011100110110111101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', 'Data:28102003');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'110100100001011000100010010110000100111101001001011000011100100110101110111101110011010011001000'
|
||||
. "1001100100111010010011000100010001101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', '12345678901');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'110100100001001110011010111011110111011011101011101100010000101100110110111101100110110011001100'
|
||||
. "1101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', '1234');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "110100111001011001110010001011000100100111101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', 'hello');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "110100100001001100001010110010000110010100001100101000010001111010100010011001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', 'HI345678');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'110100100001100010100011000100010101110111101000101100011100010110110000101001000010011011000'
|
||||
. "11101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', 'HI34567A');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'1101001000011000101000110001000101100101110010111011110101110110001000010110010111101110101000'
|
||||
. "11000100100011001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', 'Barcode 1');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'110100100001000101100010010110000100100111101000010110010001111010100001001101011001'
|
||||
. "00001101100110010011100110111011000101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', "C1\tC2\tC3");
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'11010000100100010001101001110011010000110100100010001101100111001010000110100100010001101100101'
|
||||
. "1100100110011101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', 'A1b2c3D4e5');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'1101001000010100011000100111001101001000011011001110010100001011001100101110010110001'
|
||||
. "000110010011101011001000011011100100100001101001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', \chr(241) . '0000801234999999999');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'1101001000011110101110100111011001011101111011011001100100011001001100110110011101101'
|
||||
. "1101101000111010111011110101110111101011101111010111011110110100010001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', \chr(241) . "000000\tABCDEF");
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'1101001110011110101110111101011101101100110011011001100110110011001110101111010000110100101000'
|
||||
. "110001000101100010001000110101100010001000110100010001100010100001100101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', "\tABCD\tEFGH");
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'1101000010010000110100101000110001000101100010001000110101100010001000011010010001101000100011'
|
||||
. "000101101000100011000101000100011101101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', "\tABCD\tabc\tABCdef");
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'1101000010010000110100101000110001000101100010001000110101100010001000011010010111101110100101'
|
||||
. '10000100100001101000010110011101011110100001101001010001100010001011000100010001101011110111010000100'
|
||||
. "1101011001000010110000100100001100101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', "\tABCD\tabc\tdef");
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'1101000010010000110100101000110001000101100010001000110101100010001000011010010111101110100101'
|
||||
. '10000100100001101000010110011110100010100001101001000010011010110010000101100001001111010100011000111'
|
||||
. "01011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', \chr(241) . "\tABCD");
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'1101000010011110101110111101011101000011010010100011000100010110001000100011010110001000110111'
|
||||
. "011101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', "\ta");
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "11010000100100001101001111010001010010110000110111000101100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', \chr(241) . '00123456780000000001');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'1101001110011110101110111101011101101100110010110011100100010110001110001011011000010100110110'
|
||||
. "0110011011001100110110011001101100110011001101100100101111001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('C128', \chr(241) . '42029651' . \chr(241) . '9405510200864168997758');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'11010011100111101011101111010111010110111000110011001101011110001011011101000101111011101111010'
|
||||
. '1110101110111101000101111010001001100110111010001100110011011011001100111101001001100010001010'
|
||||
. "000100110101110111101111011101011101100010100100110001100011101011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CodeThreeNineCheckTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class CodeThreeNineCheckTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('C39+', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'10001011101110101010001110111010111010001010111010111000101011101110111000101010101000'
|
||||
. '111010111011101000111010101011100011101010101000101110111011101000101110101011100010111010101'
|
||||
. "1100010101110100010111011101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CodeThreeNineExtCheckTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class CodeThreeNineExtCheckTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('C39E+', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'10001011101110101010001110111010111010001010111010111000101011101110111000101010101000'
|
||||
. '111010111011101000111010101011100011101010101000101110111011101000101110101011100010111010101'
|
||||
. "1100010101110100010111011101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('C39E+', \chr(218));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CodeThreeNineExtTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class CodeThreeNineExtTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('C39E', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'10001011101110101010001110111010111010001010111010111000101011101110111000101010101000'
|
||||
. '111010111011101000111010101011100011101010101000101110111011101000101110101011100010111010100'
|
||||
. "010111011101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CodeThreeNineTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class CodeThreeNineTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('C39', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'10001011101110101010001110111010111010001010111010111000101011101110'
|
||||
. '111000101010101000111010111011101000111010101011100011101010101000101110111'
|
||||
. "011101000101110101011100010111010100010111011101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('C39', \chr(218));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* EanEightTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class EanEightTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('EAN8', '1234567');
|
||||
$grid = $type->getGrid();
|
||||
$expected = "1010011001001001101111010100011010101001110101000010001001110010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: non-numeric input used to produce a malformed barcode instead of throwing.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testNonNumericInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('EAN8', 'abcdefg');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* EanFiveTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class EanFiveTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('EAN5', '12345');
|
||||
$grid = $type->getGrid();
|
||||
$expected = "10110110011010010011010100001010100011010110001\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* EanOneThreeTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class EanOneThreeTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('EAN13', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected = "10100011010001101001100100100110111101010001101010100111010100001000100100100011101001001110101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$this->assertEquals('0001234567895', $type->getExtendedCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('EAN13', '}{');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidLength(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('EAN13', '1111111111111');
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: a full code that already carries its (valid) check digit must not
|
||||
* gain a spurious extra digit in the extended code.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testFullCodeExtendedCode(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('EAN13', '8012345678907');
|
||||
$this->assertSame('8012345678907', $type->getExtendedCode());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* EanTwoTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class EanTwoTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('EAN2', '12');
|
||||
$grid = $type->getGrid();
|
||||
$expected = "10110011001010010011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ImbPreTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class ImbPreTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('IMBPRE', 'fatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdf');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'101000001010000010100000101000001010000010100000101000001010'
|
||||
. "000010100000101000001010000010100000101000001010000010100000101000001\n"
|
||||
. '1010101010101010101010101010101010101010101010101010101010101010101'
|
||||
. "01010101010101010101010101010101010101010101010101010101010101\n"
|
||||
. '1000001010000010100000101000001010000010100000101000001010000010100'
|
||||
. "00010100000101000001010000010100000101000001010000010100000101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('IMBPRE', 'fatd');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ImbTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class ImbTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$bobj = $barcode->getBarcodeObj('IMB', '00000-');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'100000101010001000101000101000000010000010100010001010100000'
|
||||
. "100010001000000010101000001010101000100000000000100010001000100000001\n"
|
||||
. '1010101010101010101010101010101010101010101010101010101010101010101'
|
||||
. "01010101010101010101010101010101010101010101010101010101010101\n"
|
||||
. '0000101000000010000010001000000000101010000010000000001000101010001'
|
||||
. "01010001010001010000010101000101000101000000000001000001000100\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('IMB', '0123456789');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'001010100010101000100010001010101010001000001000101010001010'
|
||||
. "101010100000000000000010101000000010001010100010001000101010001000001\n"
|
||||
. '1010101010101010101010101010101010101010101010101010101010101010101'
|
||||
. "01010101010101010101010101010101010101010101010101010101010101\n"
|
||||
. '1010101010101000001010000010101000000000000010100010001010000000000'
|
||||
. "00010100000100010001000001010101000001010000010101010100010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('IMB', '01234567094987654321-01234567891');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'10100000101000100000100000101000101000100000000010101000000000000000101010001'
|
||||
. "0000000001010100000000000100010101010001000001010001\n"
|
||||
. '101010101010101010101010101010101010101010101010101010101010101010101010101010101010'
|
||||
. "101010101010101010101010101010101010101010101\n"
|
||||
. '000010001010101000100010000000100000001010001010000000101000100000100010001000101010'
|
||||
. "001010101010000000001010000000101000100000100\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('IMB', '01234567094987654321-012345678');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'10001000001010000000000010100000100000101010001000100010000010101010000010001'
|
||||
. "0001000000000000000100000001000100010000000101000101\n"
|
||||
. '101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010'
|
||||
. "101010101010101010101010101010101\n"
|
||||
. '001010000000101000000000100000000010000000000010001000000010000000101010001000000000100010000010'
|
||||
. "101000100000001000100010101000100\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('IMB', '01234567094987654321-01234');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'00000010101000000000100000001000100000000010001000101010001010000000100010101'
|
||||
. "0100000001000101010100000100000001010000000000010100\n"
|
||||
. '101010101010101010101010101010101010101010101010101010101010101010101010101010101010'
|
||||
. "101010101010101010101010101010101010101010101\n"
|
||||
. '100000001000101000001000100010001010001010001000100010001010000010101000000000101000'
|
||||
. "000010100000000010101000101000101010001010100\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('IMB', '01234567094987654321-');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'10000010100000000000100000101000000000000010000000101000001010001000100010101'
|
||||
. "0101000100010101010100000101000001010001000100000000\n"
|
||||
. '101010101010101010101010101010101010101010101010101010101010101010101010101010101010'
|
||||
. "101010101010101010101010101010101010101010101\n"
|
||||
. '000000100000001000000010000000000010001000000000100010101010001010101000101010101000'
|
||||
. "000010000000000010101000100000101000101000100\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('IMB', '01234567094987654321-01234567891');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected =
|
||||
'10100000101000100000100000101000101000100000000010101000000000000000101010001'
|
||||
. "0000000001010100000000000100010101010001000001010001\n"
|
||||
. '101010101010101010101010101010101010101010101010101010101010101010101010101010101010'
|
||||
. "101010101010101010101010101010101010101010101\n"
|
||||
. '000010001010101000100010000000100000001010001010000000101000100000100010001000101010'
|
||||
. "001010101010000000001010000000101000100000100\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidRoutingCode(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('IMB', '01234567094987654321-1');
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* InterleavedTwoOfFiveCheckTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class InterleavedTwoOfFiveCheckTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('I25+', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected = "10101010110011001011010010101100110110100101001101001100101010010101100110100110100110101101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('I25+', 'GHI');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* InterleavedTwoOfFiveTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class InterleavedTwoOfFiveTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('I25', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected = "101010010110110100100110010101101001011001011010110110100100110100101100101101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* KlantIndexTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class KlantIndexTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('KIX', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
"00001010000010100000101000001010000010100000101000100010001000100010001000100010\n"
|
||||
. "10101010101010101010101010101010101010101010101010101010101010101010101010101010\n"
|
||||
. "00001010001000100010100010000010100010001010000000001010001000100010100010000010\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: invalid characters used to be silently mis-encoded.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidCharacter(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('KIX', 'INVALID!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: empty input used to raise an uncaught DivisionByZeroError.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testEmptyInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('KIX', '');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MsiCheckTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class MsiCheckTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('MSI+', '0123456789ABCDEF');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'110100100100100100100100110100100110100100100110110100110100100100110100110100110110100'
|
||||
. '1001101101101101001001001101001001101101001101001101001101101101101001001101101001101101101101'
|
||||
. "001101101101101001001001101001\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('MSI+', 'GHI');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MsiTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class MsiTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('MSI', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'110100100100100100100100110100100110100100100110110100110100'
|
||||
. "1001001101001101001101101001001101101101101001001001101001001101001\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PharmaTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class PharmaTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('PHARMA', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'111001110010011100100111001110010011100111001110011100100'
|
||||
. "1001110011100100111001001001001110010011100111001\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PharmaTwoTracksTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class PharmaTwoTracksTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('PHARMA2T', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected = "101000001010100010001010001000101\n000010101010001010101000100010001\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: '0' (and other non-positive inputs) used to cause an infinite loop.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('PHARMA2T', '0');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PlanetTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class PlanetTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('PLANET', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'100000101010101010000010100010001010000010100010100010'
|
||||
. "00100010100000101000101010000010100010001000101010001000101\n"
|
||||
. '1010101010101010101010101010101010101010101010101010101010101'
|
||||
. "0101010101010101010101010101010101010101010101010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PostnetTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class PostnetTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('POSTNET', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'101010000000000000101000001000100000101000001000001000'
|
||||
. "10001000001010000010000000101000001000100010000000100010001\n"
|
||||
. '1010101010101010101010101010101010101010101010101010101010101'
|
||||
. "0101010101010101010101010101010101010101010101010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('POSTNET', '}{');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* RawTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class RawTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$testObj = $this->getTestObject();
|
||||
$testObj = $this->getTestObject();
|
||||
|
||||
$type = $testObj->getBarcodeObj('LRAW', '01001100011100001111,10110011100011110000');
|
||||
$grid = $type->getGrid();
|
||||
$expected = "01001100011100001111\n10110011100011110000\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: bracket-separated rows used to be merged into a single row.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testBracketSeparatedRows(): void
|
||||
{
|
||||
$testObj = $this->getTestObject();
|
||||
$type = $testObj->getBarcodeObj('LRAW', '[101][010]');
|
||||
$this->assertSame("101\n010\n", $type->getGrid());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* RoyalMailFourCcTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class RoyalMailFourCcTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('RMS4CC', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
"1000001010000010100000101000001010000010100000101000100010001000100010001000100010001000101\n"
|
||||
. "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\n"
|
||||
. "0000001010001000100010100010000010100010001010000000001010001000100010100010000010000010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('RMS4CC', '}{');
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: a letter-valued check character used to be mangled to '0'.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testLetterCheckDigit(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$this->assertSame('1234J', $barcode->getBarcodeObj('RMS4CC', '1234')->getExtendedCode());
|
||||
$this->assertSame('CU9NH', $barcode->getBarcodeObj('RMS4CC', 'CU9N')->getExtendedCode());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* StandardTwoOfFiveCheckTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class StandardTwoOfFiveCheckTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('S25+', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'111011101010101110111010101011101110101110101010111010111010101110111011101010101010111010'
|
||||
. '1110111010111010101011101110101010101011101110111010101110101011101011101011101011101010111010111'
|
||||
. "\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('S25+', '}{');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* StandardTwoOfFiveTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class StandardTwoOfFiveTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('S25', '0123456789');
|
||||
$grid = $type->getGrid();
|
||||
$expected =
|
||||
'111011101010101110111010111010101011101011101010111011101110101010101011101011101110101110101010'
|
||||
. '111011101010101010111011101110101011101010111010111010111010111'
|
||||
. "\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* UpcATest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class UpcATest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$bobj = $barcode->getBarcodeObj('UPCA', '0123456789');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "10100011010001101001100100100110111101010001101010100111010100001000100100100011101001001110101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCA', '012345678912');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "10100011010011001001001101111010100011011000101010101000010001001001000111010011001101101100101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* UpcETest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Linear;
|
||||
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class UpcETest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '725270');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001000100100110110001001101101110110100111010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '725271');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001000100100110111001001001101110110110011010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '725272');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001000100100110111001001001100100010010011010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '725273');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001000100100110110001001101101110110100001010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '725274');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001000100100110110001001101100100010100011010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '725275');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001000100100110111001001101101110110110001010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '725276');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001000100110110110001001101101110110101111010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '725277');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001000100100110111001001001101110110010001010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '725278');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001000100100110110001001101100100010110111010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '725279');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001000100110110110001001001100100010001011010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '0123456789');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101010011100110010010011010000100111010001011010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '012345678912');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101011001100110110111101010001101110010011001010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '4210000526');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001110100100110111001001101101011110011001010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '4240000526');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001110100110110100011001101101011110111101010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
|
||||
$bobj = $barcode->getBarcodeObj('UPCE', '4241000526');
|
||||
$grid = $bobj->getGrid();
|
||||
$expected = "101001110100100110011101001100101011110011101010101\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: non-numeric input used to produce a malformed barcode instead of throwing.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testNonNumericInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('UPCE', 'abcdefg');
|
||||
}
|
||||
}
|
||||
+234
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MathTest.php
|
||||
*
|
||||
* @since 2026-08-06
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Com\Tecnick\Barcode\Barcode;
|
||||
use Com\Tecnick\Barcode\Math;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Test\Fixture\FallbackMathImb;
|
||||
use Test\Fixture\FallbackMathPdfFourOneSeven;
|
||||
|
||||
/**
|
||||
* Math class test
|
||||
*
|
||||
* @since 2026-08-06
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class MathTest extends TestUtil
|
||||
{
|
||||
/**
|
||||
* Operands with the expected sum, product, quotient and remainder.
|
||||
*
|
||||
* @return array<int, array{string, string, string, string, string, string}>
|
||||
*/
|
||||
public static function getOperationsProvider(): array
|
||||
{
|
||||
return [
|
||||
['7', '2', '9', '14', '3', '1'],
|
||||
['000123', '0045', '168', '5535', '2', '33'],
|
||||
['0', '12', '12', '0', '0', '0'],
|
||||
['99', '1', '100', '99', '99', '0'],
|
||||
['5', '5', '10', '25', '1', '0'],
|
||||
['1099511627776', '255', '1099511628031', '280375465082880', '4311810305', '1'],
|
||||
[
|
||||
'1000000000000000000000000000000',
|
||||
'999',
|
||||
'1000000000000000000000000000999',
|
||||
'999000000000000000000000000000000',
|
||||
'1001001001001001001001001001',
|
||||
'1',
|
||||
],
|
||||
[
|
||||
'123456789012345678901234567890',
|
||||
'987654321',
|
||||
'123456789012345678902222222211',
|
||||
'121932631124828532112482853211126352690',
|
||||
'124999998873437499901',
|
||||
'574845669',
|
||||
],
|
||||
[
|
||||
'987654321098765432109876543210',
|
||||
'123456789012345678901234567890',
|
||||
'1111111110111111111011111111100',
|
||||
'121932631137021795226185032733622923332237463801111263526900',
|
||||
'8',
|
||||
'9000000000900000000090',
|
||||
],
|
||||
[
|
||||
'100000000000000000000000000000000000000000000',
|
||||
'900',
|
||||
'100000000000000000000000000000000000000000900',
|
||||
'90000000000000000000000000000000000000000000000',
|
||||
'111111111111111111111111111111111111111111',
|
||||
'100',
|
||||
],
|
||||
[
|
||||
'19999999999999999999999999999999999999999999',
|
||||
'900',
|
||||
'20000000000000000000000000000000000000000899',
|
||||
'17999999999999999999999999999999999999999999100',
|
||||
'22222222222222222222222222222222222222222',
|
||||
'199',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
#[DataProvider('getOperationsProvider')]
|
||||
public function testOperations(
|
||||
string $left,
|
||||
string $right,
|
||||
string $sum,
|
||||
string $product,
|
||||
string $quotient,
|
||||
string $remainder,
|
||||
): void {
|
||||
$this->assertSame($sum, Math::add($left, $right));
|
||||
$this->assertSame($product, Math::mul($left, $right));
|
||||
$this->assertSame($quotient, Math::div($left, $right));
|
||||
$this->assertSame($remainder, Math::mod($left, $right));
|
||||
}
|
||||
|
||||
#[DataProvider('getOperationsProvider')]
|
||||
public function testFallbackOperations(
|
||||
string $left,
|
||||
string $right,
|
||||
string $sum,
|
||||
string $product,
|
||||
string $quotient,
|
||||
string $remainder,
|
||||
): void {
|
||||
$this->assertSame($sum, Math::fallbackAdd($left, $right));
|
||||
$this->assertSame($product, Math::fallbackMul($left, $right));
|
||||
$this->assertSame($quotient, Math::fallbackDiv($left, $right));
|
||||
$this->assertSame($remainder, Math::fallbackMod($left, $right));
|
||||
}
|
||||
|
||||
public function testHasBcmath(): void
|
||||
{
|
||||
$this->assertSame(\function_exists('bcadd'), Math::hasBcmath());
|
||||
}
|
||||
|
||||
public function testZeroOperands(): void
|
||||
{
|
||||
$this->assertSame('0', Math::add('0', '00'));
|
||||
$this->assertSame('0', Math::fallbackAdd('0', '00'));
|
||||
$this->assertSame('0', Math::mul('0', '123'));
|
||||
$this->assertSame('0', Math::fallbackMul('123', '0'));
|
||||
}
|
||||
|
||||
public function testDivisionByZero(): void
|
||||
{
|
||||
$this->bcExpectException(\DivisionByZeroError::class);
|
||||
Math::div('123', '0');
|
||||
}
|
||||
|
||||
public function testFallbackDivisionByZero(): void
|
||||
{
|
||||
$this->bcExpectException(\DivisionByZeroError::class);
|
||||
Math::fallbackDiv('123', '0');
|
||||
}
|
||||
|
||||
public function testFallbackModuloByZero(): void
|
||||
{
|
||||
$this->bcExpectException(\DivisionByZeroError::class);
|
||||
Math::fallbackMod('123', '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{string}>
|
||||
*/
|
||||
public static function getInvalidNumberProvider(): array
|
||||
{
|
||||
return [[''], ['abc'], ['-5'], ['1.5'], ['12 '], ['+1']];
|
||||
}
|
||||
|
||||
#[DataProvider('getInvalidNumberProvider')]
|
||||
public function testInvalidNumber(string $number): void
|
||||
{
|
||||
$this->bcExpectException(\ValueError::class);
|
||||
Math::add($number, '1');
|
||||
}
|
||||
|
||||
#[DataProvider('getInvalidNumberProvider')]
|
||||
public function testFallbackInvalidNumber(string $number): void
|
||||
{
|
||||
$this->bcExpectException(\ValueError::class);
|
||||
Math::fallbackMul('1', $number);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{string}>
|
||||
*/
|
||||
public static function getImbCodeProvider(): array
|
||||
{
|
||||
return [
|
||||
['00000-'],
|
||||
['0123456789'],
|
||||
['01234567094987654321-01234567891'],
|
||||
['01234567094987654321-012345678'],
|
||||
['01234567094987654321-01234'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The IMB grid must be the same with and without the bcmath extension.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
#[DataProvider('getImbCodeProvider')]
|
||||
public function testImbFallbackParity(string $code): void
|
||||
{
|
||||
$barcode = new Barcode();
|
||||
$expected = $barcode->getBarcodeObj('IMB', $code)->getGrid();
|
||||
$fallback = new FallbackMathImb($code);
|
||||
$this->assertSame($expected, $fallback->getGrid());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{string}>
|
||||
*/
|
||||
public static function getPdfFourOneSevenCodeProvider(): array
|
||||
{
|
||||
return [
|
||||
['0123456789'],
|
||||
['1234567890123456789012345678901234567890123456789012345678901234567890'],
|
||||
['Tecnick.com PDF417 test 1234567890'],
|
||||
["\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c"],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The PDF417 grid must be the same with and without the bcmath extension.
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
#[DataProvider('getPdfFourOneSevenCodeProvider')]
|
||||
public function testPdfFourOneSevenFallbackParity(string $code): void
|
||||
{
|
||||
$barcode = new Barcode();
|
||||
$expected = $barcode->getBarcodeObj('PDF417', $code)->getGrid();
|
||||
$fallback = new FallbackMathPdfFourOneSeven($code);
|
||||
$this->assertSame($expected, $fallback->getGrid());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* QrEccLevelTest.php
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Com\Tecnick\Barcode\Type\Square\QrCode\QrEccLevel;
|
||||
|
||||
/**
|
||||
* QrEccLevel enum test
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class QrEccLevelTest extends TestUtil
|
||||
{
|
||||
public function testCaseBackingValues(): void
|
||||
{
|
||||
$this->assertSame('L', QrEccLevel::L->value);
|
||||
$this->assertSame('M', QrEccLevel::M->value);
|
||||
$this->assertSame('Q', QrEccLevel::Q->value);
|
||||
$this->assertSame('H', QrEccLevel::H->value);
|
||||
}
|
||||
|
||||
public function testFromLooseCanonical(): void
|
||||
{
|
||||
$this->assertSame(QrEccLevel::H, QrEccLevel::fromLoose('H'));
|
||||
$this->assertSame(QrEccLevel::Q, QrEccLevel::fromLoose('Q'));
|
||||
}
|
||||
|
||||
public function testFromLoosePassesThroughEnumInstance(): void
|
||||
{
|
||||
$this->assertSame(QrEccLevel::M, QrEccLevel::fromLoose(QrEccLevel::M));
|
||||
}
|
||||
|
||||
public function testFromLooseRoundTrip(): void
|
||||
{
|
||||
foreach (QrEccLevel::cases() as $case) {
|
||||
$this->assertSame($case, QrEccLevel::fromLoose($case->value));
|
||||
}
|
||||
}
|
||||
|
||||
public function testFromLooseUnknownFallsBackToL(): void
|
||||
{
|
||||
$this->assertSame(QrEccLevel::L, QrEccLevel::fromLoose('X'));
|
||||
$this->assertSame(QrEccLevel::L, QrEccLevel::fromLoose(''));
|
||||
$this->assertSame(QrEccLevel::L, QrEccLevel::fromLoose('h'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* QrEncodingModeTest.php
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Com\Tecnick\Barcode\Type\Square\QrCode\QrEncodingMode;
|
||||
|
||||
/**
|
||||
* QrEncodingMode enum test
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2010-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class QrEncodingModeTest extends TestUtil
|
||||
{
|
||||
public function testCaseBackingValues(): void
|
||||
{
|
||||
$this->assertSame('NL', QrEncodingMode::NL->value);
|
||||
$this->assertSame('NM', QrEncodingMode::NM->value);
|
||||
$this->assertSame('AN', QrEncodingMode::AN->value);
|
||||
$this->assertSame('8B', QrEncodingMode::Byte->value);
|
||||
$this->assertSame('KJ', QrEncodingMode::KJ->value);
|
||||
$this->assertSame('ST', QrEncodingMode::ST->value);
|
||||
}
|
||||
|
||||
public function testFromLooseCanonical(): void
|
||||
{
|
||||
$this->assertSame(QrEncodingMode::Byte, QrEncodingMode::fromLoose('8B'));
|
||||
$this->assertSame(QrEncodingMode::AN, QrEncodingMode::fromLoose('AN'));
|
||||
}
|
||||
|
||||
public function testFromLoosePassesThroughEnumInstance(): void
|
||||
{
|
||||
$this->assertSame(QrEncodingMode::KJ, QrEncodingMode::fromLoose(QrEncodingMode::KJ));
|
||||
}
|
||||
|
||||
public function testFromLooseRoundTrip(): void
|
||||
{
|
||||
foreach (QrEncodingMode::cases() as $case) {
|
||||
$this->assertSame($case, QrEncodingMode::fromLoose($case->value));
|
||||
}
|
||||
}
|
||||
|
||||
public function testFromLooseUnknownFallsBackToByte(): void
|
||||
{
|
||||
$this->assertSame(QrEncodingMode::Byte, QrEncodingMode::fromLoose('ZZ'));
|
||||
$this->assertSame(QrEncodingMode::Byte, QrEncodingMode::fromLoose(''));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AztecTest.php
|
||||
*
|
||||
* @since 2023-10-20
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2023-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Square;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* AZTEC Barcode class test
|
||||
*
|
||||
* @since 2023-10-20
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2023-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class AztecTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('AZTEC', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testCapacityException(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$code = \str_pad('', 2000, '0123456789');
|
||||
$barcode->getBarcodeObj('AZTEC,100,B,F,3', $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: the ECC percentage parameter used to be silently ignored (always 33%).
|
||||
*
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testEccParameterRespected(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$low = $barcode->getBarcodeObj('AZTEC,10', 'TEST DATA 123')->getGrid();
|
||||
$high = $barcode->getBarcodeObj('AZTEC,90', 'TEST DATA 123')->getGrid();
|
||||
$this->assertNotSame($low, $high);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
#[DataProvider('getGridDataProvider')]
|
||||
public function testGetGrid(string $options, string $code, mixed $expected): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('AZTEC' . $options, $code);
|
||||
$grid = $type->getGrid();
|
||||
$this->assertEquals($expected, \md5($grid));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array{string, string, string}>
|
||||
*/
|
||||
public static function getGridDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
',100,A,A,0',
|
||||
'A',
|
||||
'c48da49052f674edc66fa02e52334b17',
|
||||
],
|
||||
[
|
||||
'',
|
||||
' ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||
'74f1e68830f0c635cd01167245743098',
|
||||
],
|
||||
[
|
||||
'',
|
||||
' abcdefghijklmnopqrstuvwxyz',
|
||||
'100ebf910c88922b0ccee88256ba0c81',
|
||||
],
|
||||
[
|
||||
'',
|
||||
' ,.0123456789',
|
||||
'ee2a70b7c88a9e0956b1896983e93f91',
|
||||
],
|
||||
[
|
||||
'',
|
||||
"\r" . '!"#$%&\'()*+,-./:;<=>?[]{}',
|
||||
'6965459e50f7c3029de42ef5dc5c1fdf',
|
||||
],
|
||||
[
|
||||
'',
|
||||
"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A"
|
||||
. "\x0B\x0C\x0D\x1B\x1C\x1D\x1E\x1F\x40\x5C"
|
||||
. "\x5E\x5F\x60\x7C\x7E\x7F",
|
||||
'b8961abf38519b529f7dc6a20e8f3e59',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'AaB0C#D' . "\x7E",
|
||||
'9b1f2af28b8d9d222de93dfe6a09a047',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'aAb0c#d' . "\x7E",
|
||||
'f4c58cabbdb5d94fa0cc1c31d510936a',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'#A$a%0&' . "\x7E",
|
||||
'a17634a1db6372efbf8ea25a303c38f8',
|
||||
],
|
||||
[
|
||||
'',
|
||||
"\x01A\x01a\x010\x01#",
|
||||
'c1a585888c7a1eb424ff98bbf7b32d46',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'PUNCT pairs , . : ' . "\r\n",
|
||||
'35281793cc5247b291abb8e3fe5ed853',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'ABCDEabcdeABCDE012345ABCDE?[]{}ABCDE' . "\x01\x02\x03\x04\x05",
|
||||
'4ae19b80469a1afff8e490f5afaa8b73',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'abcdeABCDEabcde012345abcde?[]{}abcde' . "\x01\x02\x03\x04\x05",
|
||||
'b0158bfe19c6fe20042128d59e40ca3b',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'?[]{}ABCDE?[]{}abcde?[]{}012345?[]{}' . "\x01\x02\x03\x04\x05",
|
||||
'71ba0ed8c308c93af6af7cd23a76355a',
|
||||
],
|
||||
[
|
||||
'',
|
||||
"\x01\x02\x03\x04\x05"
|
||||
. 'ABCDE'
|
||||
. "\x01\x02\x03\x04\x05"
|
||||
. 'abcde'
|
||||
. "\x01\x02\x03\x04\x05"
|
||||
. '012345'
|
||||
. "\x01\x02\x03\x04\x05"
|
||||
. '?[]{}',
|
||||
'f31e14be0b2c1f903e77af11e6c901b0',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit,'
|
||||
. ' sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
|
||||
. ' Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris'
|
||||
. ' nisi ut aliquip ex ea commodo consequat.'
|
||||
. ' Duis aute irure dolor in reprehenderit in voluptate velit esse'
|
||||
. ' cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat'
|
||||
. ' cupidatat non proident,'
|
||||
. ' sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
||||
'bb2b103d59e035a581fed0619090f89c',
|
||||
],
|
||||
[
|
||||
'',
|
||||
"\x80\x81\x82\x83\x84",
|
||||
'da92b009c1f4430e2f62c76c5f708121',
|
||||
],
|
||||
[
|
||||
'',
|
||||
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89"
|
||||
. "\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93"
|
||||
. "\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D"
|
||||
. "\x9E\x9F\xA0",
|
||||
'f3dfdda6d6fdbd747c86f042fc649193',
|
||||
],
|
||||
[
|
||||
'',
|
||||
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89"
|
||||
. "\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93"
|
||||
. "\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D"
|
||||
. "\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7"
|
||||
. "\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1"
|
||||
. "\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB"
|
||||
. "\xBC\xBD\xBE",
|
||||
'ee473dc76e160671f3d1991777894323',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'012345: : : : : : : : ',
|
||||
'b7ae80e65d754dc17fe116aaddd33c24',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'012345. , ',
|
||||
'92b442e5f1b33be91c576eddc12bcca7',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'012345. , . , . , . , ',
|
||||
'598fd97d8a28b1514cd0bf88369c68e9',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'~~~~~~. , ',
|
||||
'c40fc61717a7e802d7458897197227b1',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'******. , ',
|
||||
'abbe0bdfdc10ad059ad2c415e79dab31',
|
||||
],
|
||||
[
|
||||
'',
|
||||
"\xBC\xBD\xBE" . '. , ',
|
||||
'c9ae209e0c6d03014753363affffee8b',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
#[DataProvider('getStringDataProvider')]
|
||||
public function testStrings(string $code): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('AZTEC,50,B,F', $code);
|
||||
$this->assertNotNull($type); // @phpstan-ignore method.alreadyNarrowedType
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array{string}>
|
||||
*/
|
||||
public static function getStringDataProvider(): array
|
||||
{
|
||||
return \Test\TestStrings::$data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,497 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* DatamatrixTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Square;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* Datamatrix Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class DatamatrixTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('DATAMATRIX', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testCapacityException(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$code = \str_pad('', 3000, 'X');
|
||||
$barcode->getBarcodeObj('DATAMATRIX', $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testEncodeTXTC40shiftException(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$encode = new \Com\Tecnick\Barcode\Type\Square\Datamatrix\Encode();
|
||||
$chr = -1;
|
||||
$enc = -1;
|
||||
$temp_cw = [];
|
||||
$ptr = 0;
|
||||
$encode->encodeTXTC40shift($chr, $enc, $temp_cw, $ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testEncodeTXTC40Exception(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$encode = new \Com\Tecnick\Barcode\Type\Square\Datamatrix\Encode();
|
||||
$data = "\x80";
|
||||
$enc = \Com\Tecnick\Barcode\Type\Square\Datamatrix\Data::ENC_X12;
|
||||
$temp_cw = [];
|
||||
$ptr = 0;
|
||||
$epos = 0;
|
||||
$charset = [];
|
||||
$encode->encodeTXTC40($data, $enc, $temp_cw, $ptr, $epos, $charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
#[DataProvider('getGridDataProvider')]
|
||||
public function testGetGrid(string $mode, string $code, mixed $expected): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj($mode, $code);
|
||||
$grid = $type->getGrid();
|
||||
$this->assertEquals($expected, \md5($grid));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array{string, string, string}>
|
||||
*/
|
||||
public static function getGridDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'0&0&0&0&0&0&_',
|
||||
'fffdfdaec33af0788d24cdfa8cba5ac6',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'0&0&0&0&0&0&0',
|
||||
'10d0faf5a6e7b71829f268218df7e6af',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'-=-1-=-2-=-3',
|
||||
'75c6038d90476cec641ad07690989b36',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'-=-1-=-2-=-3x',
|
||||
'f020e44d0926d17af7eb21febdb38d53',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'-=-1-=-2-=-3xyz',
|
||||
'17420fbffefddb5f1b8abd0d05de724d',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'-=-1-=-2-=-3-',
|
||||
'a63372ce839b51294964f0da0ae0f9f9',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'-=-1-=-2-=-3-xy',
|
||||
'f65ab07c374c53e2a93016776041de42',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'-=-1-=-2-=-3-=x',
|
||||
'7a30efdf7616397a1ea2fd5fd95fed2c',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'(400)BS2WZ64PA(00)0',
|
||||
'9cb7f1c2aa5989909229ef8e4252d61d',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'(400)BS2WZ64QA(00)0',
|
||||
'0494f709138a1feef5a1c9f14852dbe5',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'LD2B 1 CLNGP',
|
||||
'f806889d1dbe0908dcfb530f86098041',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'XXXXXXXXXNGP',
|
||||
'c6f2b7b293a2943bae74f2a191ec4aea',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'XXXXXXXXXXXXNGP',
|
||||
'f7679d5a7ab4a8edf12571a6866d92bc',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'ABCDABCDAB' . "\x80" . 'DABCD',
|
||||
'39aca5ed58b922bee369e5ab8e3add8c',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'123aabcdefghijklmnopqrstuvwxyzc',
|
||||
'b2d1e957af10655d7a8c3bae86696314',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopq',
|
||||
'c45bd372694ad7a20fca7d45f3d459ab',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'abcdefghijklmnop',
|
||||
'4fc7940fe3d19fca12454340c38e3421',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'abcdefghijklmnopq',
|
||||
'a452e658e3096d8187969cbdc930909c',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'abcdefghij',
|
||||
'8ec27153e5d173aa2cb907845334e68c',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'30Q324343430794<OQQ',
|
||||
'e67808f91114fb021851098c4cc65b88',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'0123456789',
|
||||
'cc1fd942bc919b2d09b3c7cf508c6ae4',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
|
||||
'c61d8ced313e2a2e79ab56eded67f11a',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'10f27ce-acb7-4e4e-a7ae-a0b98da6ed4a',
|
||||
'1a56c44e3977f1ac68057230181e49a8',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'Hello World',
|
||||
'e72650689027fe75d1f9377ec759c710',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'https://github.com/tecnickcom/tc-lib-barcode',
|
||||
'efed64acfa2ca29024446fa9816be696',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdab'
|
||||
. 'cdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd'
|
||||
. 'abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdab'
|
||||
. 'cdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd',
|
||||
'4dc0efb6248b3802c2ab7cf123b884d0',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\',
|
||||
'1d41ee32691ff75637224e4fbe68a626',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\'
|
||||
. 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\'
|
||||
. 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\',
|
||||
'0b2921466e097ff9cc1ad63719430540',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
"\x80\x8A\x94\x9E",
|
||||
'9300000cee5a5f7b3b48145d44aa7fff',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'!"£$%^&*()-+_={}[]\'#@~;:/?,.<>|',
|
||||
'4993e149fd20569c8a4f0d758b6dfa76',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'!"£$',
|
||||
'792181edb48c6722217dc7e2e4cd4095',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\1234567890',
|
||||
'7360a5a6c25476711139ae1244f56c29',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
"\xFE\xFD"
|
||||
. 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\'
|
||||
. "\xFC\xFB",
|
||||
'0f078e5e5735396312245740484fa6d1',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'aABCDEFG',
|
||||
'f074dee3f0f386d9b2f30b1ce4ad08a8',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'123 45678',
|
||||
'6c2e6503625e408fe9a4e392743f31a8',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'DATA MATRIX',
|
||||
'3ba4f4ef8449d795813b353ddcce4d23',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'123ABCD89',
|
||||
'7ce2f8433b82c16e80f4a4c59cad5d10',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'AB/C123-X',
|
||||
'703318e1964c63d5d500d14a821827cd',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
\str_pad('', 300, "\xFE\xFD\xFC\xFB"),
|
||||
'e524bb17821d0461f3db6f313d35018f',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'ec:b47'
|
||||
. "\x7F"
|
||||
. '4#P d*b}gI2#DB|hl{!~[EYH*=cmR{lf'
|
||||
. "\x7F"
|
||||
. '=gcGIa.st286. #*"!eG[.Ryr?Kn,1mIyQqC3 6\'3N>',
|
||||
'57fbb9bfb7d542e2e5eadb615e6be549',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX',
|
||||
'eA211101A2raJTGL/r9o93CVk4gtpEvWd2A2Qz8jvPc7l8ybD3m'
|
||||
. 'Wel91ih727kldinPeHJCjhr7fIBX1KQQfsN7BFMX00nlS8FlZG+',
|
||||
'b2f0d45920c7da5b298bbab5cff5d402',
|
||||
],
|
||||
// Square
|
||||
[
|
||||
'DATAMATRIX,S',
|
||||
"\xFF\xFE\xFD\xFC\xFB\xFA\xF9\xF8\xF7\xF6"
|
||||
. "\xF5\xF4\xF3\xF2\xF1\xF0\xEF\xEE\xED\xEC"
|
||||
. "\xEB\xEA\xE9\xE8\xE7\xE6\xE5\xE4\xE3\xE2"
|
||||
. "\xE1\xE0\xDF\xDE\xDD\xDC\xDB\xDA\xD9\xD8"
|
||||
. "\xD7\xD6\xD5\xD4\xD3\xD2\xD1\xD0\xCF\xCE"
|
||||
. "\xCD\xCC\xCB\xCA\xC9\xC8\xC7\xC6\xC5\xC4"
|
||||
. "\xC3\xC2\xC1\xC0\xBF\xBE\xBD\xBC\xBB\xBA"
|
||||
. "\xB9\xB8\xB7\xB6\xB5\xB4\xB3\xB2\xB1\xB0"
|
||||
. "\xAF\xAE\xAD\xAC\xAB\xAA\xA9\xA8\xA7\xA6"
|
||||
. "\xA5\xA4\xA3\xA2\xA1\xA0\x9F\x9E\x9D\x9C"
|
||||
. "\x9B\x9A\x99\x98\x97\x96\x95\x94\x93\x92"
|
||||
. "\x91\x90\x8F\x8E\x8D\x8C\x8B\x8A\x89\x88"
|
||||
. "\x87\x86\x85\x84\x83\x82\x81\x80\x7F\x7E"
|
||||
. "\x7D\x7C\x7B\x7A\x79\x78\x77\x76\x75\x74"
|
||||
. "\x73\x72\x71\x70\x6F\x6E\x6D\x6C\x6B\x6A"
|
||||
. "\x69\x68\x67\x66\x65\x64\x63\x62\x61\x60"
|
||||
. "\x5F\x5E\x5D\x5C\x5B\x5A\x59\x58\x57\x56"
|
||||
. "\x55\x54\x53\x52\x51\x50\x4F\x4E\x4D\x4C"
|
||||
. "\x4B\x4A\x49\x48\x47\x46\x45\x44\x43\x42"
|
||||
. "\x41\x40\x3F\x3E\x3D\x3C\x3B\x3A\x39\x38"
|
||||
. "\x37\x36\x35\x34\x33\x32\x31\x30\x2F\x2E"
|
||||
. "\x2D\x2C\x2B\x2A\x29\x28\x27\x26\x25\x24"
|
||||
. "\x23\x22\x21\x20\x1F\x1E\x1D\x1C\x1B\x1A"
|
||||
. "\x19\x18\x17\x16\x15\x14\x13\x12\x11\x10"
|
||||
. "\x0F\x0E\x0D\x0C\x0B\x0A\x09\x08\x07\x06"
|
||||
. "\x05\x04\x03\x02\x01",
|
||||
'514963c4fde0cee7ff91f76dd56015cc',
|
||||
],
|
||||
// Rectangular shape
|
||||
[
|
||||
'DATAMATRIX,R',
|
||||
'01234567890',
|
||||
'd3811e018f960beed6d3fa5e675e290e',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,R',
|
||||
'01234567890123456789',
|
||||
'fe3ecb042dabc4b40c5017e204df105b',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,R',
|
||||
'012345678901234567890123456789',
|
||||
'3f8e9aa4413b90f7e1c2e85b4471fd20',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,R',
|
||||
'0123456789012345678901234567890123456789',
|
||||
'b748b02c1c4cae621a84c8dbba97c710',
|
||||
],
|
||||
// Rectangular GS1
|
||||
[
|
||||
'DATAMATRIX,R,GS1',
|
||||
"\xE8" . '01034531200000111719112510ABCD1234',
|
||||
'f55524d239fc95072d99eafe5363cfeb',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,R,GS1',
|
||||
"\xE8" . '01095011010209171719050810ABCD1234' . "\xE8" . '2110',
|
||||
'e17f2a052271a18cdc00b161908eccb9',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,R,GS1',
|
||||
"\xE8" . '01034531200000111712050810ABCD1234' . "\xE8" . '4109501101020917',
|
||||
'31759950f3253805b100fedf3e536575',
|
||||
],
|
||||
// Square GS1
|
||||
[
|
||||
'DATAMATRIX,S,GS1',
|
||||
"\xE8" . '01034531200000111719112510ABCD1234',
|
||||
'c9efb69a62114fb6a3d2b52f139a372a',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,S,GS1',
|
||||
"\xE8" . '01095011010209171719050810ABCD1234' . "\xE8" . '2110',
|
||||
'9630bdba9fc79b4a4911fc465aa08951',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,S,GS1',
|
||||
"\xE8" . '01034531200000111712050810ABCD1234' . "\xE8" . '4109501101020917',
|
||||
'a29a330a01cce34a346cf7049e2259ee',
|
||||
],
|
||||
// Different encoding datamatrix
|
||||
[
|
||||
'DATAMATRIX,S,N,ASCII',
|
||||
'01234567890',
|
||||
'ac7dd9e1ebdb42d07fe928fb33cd307b',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,S,N,C40',
|
||||
'01234567890',
|
||||
'958a7a3bcd036d7135489eb703a25633',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,S,N,TXT',
|
||||
'01234567890',
|
||||
'057981dfbf527b029ae59d65fb55f61d',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,S,N,X12',
|
||||
'01234567890',
|
||||
'8d75b0fcfb2d0977abd95004a6ba98dd',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,S,N,EDF',
|
||||
'01234567890',
|
||||
'989eab3ca16c97e05dd2307bef32f64b',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,S,N,BASE256',
|
||||
'01234567890',
|
||||
'8b4f688a774130bc654e39dfcfadb482',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,S,GS1',
|
||||
// \xE8 is the control character FNC1 (ASCII 232)
|
||||
// Expected read:
|
||||
// (01)03453120000011
|
||||
// (17)191125
|
||||
// (10)ABCD1234
|
||||
// (21)10
|
||||
"\xE8" . '01034531200000111719112510ABCD1234' . "\xE8" . '2110',
|
||||
'3c66c6c7355e7dea071501216e894eac',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,S,GS1',
|
||||
// \xE8 is the control character FNC1 (ASCII 232)
|
||||
// \x1D is the control character <GS> (ASCII 29)
|
||||
// Expected read:
|
||||
// (01)03453120000011
|
||||
// (17)191125
|
||||
// (10)ABCD1234
|
||||
// (21)10
|
||||
"\xE8" . '01034531200000111719112510ABCD1234' . "\x1D" . '2110',
|
||||
'3c66c6c7355e7dea071501216e894eac',
|
||||
],
|
||||
[
|
||||
'DATAMATRIX,S,GS1,C40',
|
||||
// \xE8 is the control character FNC1 (ASCII 232)
|
||||
"\xE8" . '01095011010209171719050810ABCD1234' . "\xE8" . '2110',
|
||||
'ba117111dfa40a40e1bb968c719d2eef',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
#[DataProvider('getStringDataProvider')]
|
||||
public function testStrings(string $code): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('DATAMATRIX', $code);
|
||||
$this->assertNotNull($type); // @phpstan-ignore method.alreadyNarrowedType
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array{string}>
|
||||
*/
|
||||
public static function getStringDataProvider(): array
|
||||
{
|
||||
return \Test\TestStrings::$data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PdfFourOneSevenTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Square;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* PDF417 Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class PdfFourOneSevenTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('PDF417', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testCapacityException(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$code = \str_pad('', 1000, 'X1');
|
||||
$barcode->getBarcodeObj('PDF417', $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
#[DataProvider('getGridDataProvider')]
|
||||
public function testGetGrid(string $options, string $code, mixed $expected): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('PDF417' . $options, $code);
|
||||
$grid = $type->getGrid();
|
||||
$this->assertEquals($expected, \md5($grid));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array{string, string, string}>
|
||||
*/
|
||||
public static function getGridDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'',
|
||||
\str_pad('', 1850, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
|
||||
'38e205c911b94a62c72b7d20fa4361f8',
|
||||
],
|
||||
// max text
|
||||
[
|
||||
'',
|
||||
\str_pad('', 2710, '123456789'),
|
||||
'c512b5d3ca975a16c21b47e938d2aecb',
|
||||
],
|
||||
// max digits
|
||||
[
|
||||
'',
|
||||
'abc/abc',
|
||||
'831874fe7d1b3d865c222858eba3507c',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'0123456789',
|
||||
'4f9cdac81d62f0020beb93fc3ecdd8ad',
|
||||
],
|
||||
[
|
||||
',2,8,1,0,0,0,1,2',
|
||||
\str_pad('', 1750, 'X'),
|
||||
'f0874a35e15f11f9aa8bc070a4be24bf',
|
||||
],
|
||||
[
|
||||
',15,8,1,0,0,0,1,2',
|
||||
\str_pad('', 1750, 'X'),
|
||||
'0288f0a87cc069fc34d6168d7a9f7846',
|
||||
],
|
||||
[
|
||||
'',
|
||||
\str_pad('', 350, '0123456789'),
|
||||
'9a8e73c7a098fd10ce37605be1c87435',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'abcdefghijklmnopqrstuvwxyz01234567890123456789',
|
||||
'bd4f4215aca0bbc3452a35b81fcf7bdb',
|
||||
],
|
||||
[
|
||||
'',
|
||||
"\x9E\x13\xC0\x08\x47\x71\x6B\xFC\xAB\xA9"
|
||||
. "\x72\x72\xCC\x97\xB7\x14\xB4\x1A\x49\x4C"
|
||||
. "\xC1\x10\x45\xD4\xE8\x5A\xF8\x73\x09\x68"
|
||||
. "\x95\xA7\x7B\x56\xAF\xC1\xC7\x1B\xBE\x73"
|
||||
. "\xC4\x32\xE4\x92\xC9\x9C\xA5\x7E\xB6\xED"
|
||||
. "\xC9\x79\xFD\x0F\x4E\xE7\x69\x48\x5C\x72"
|
||||
. "\xAF\xF0\x1A\x2B\x47\xC8\xEC\x0F\xE3\xAC"
|
||||
. "\x81\xA9\xDD\x67\x3C\xA7\x05\xE1\x27\xBA"
|
||||
. "\xD0\xF0\x34\xCE\xFE\x82\xB7\x69\xC9\x14"
|
||||
. "\xDA\x7A\x05\xF4\xA5\x4C\xBD\x92\x5B\xA2"
|
||||
. "\x3F\xDC\x4C\x1E\x44\x87\xC4\x49\x6A\xEB"
|
||||
. "\x05\x3B\xDC\x38\x0B\xDC\xBA\xC2\x46\x84"
|
||||
. "\xD5\x22\xFE\xDA\x17\xA4\x28\xD4\x38\x82"
|
||||
. "\x77\x76\x5F\xC2\x94\xA3\x4B\x5A\xEC\xB4"
|
||||
. "\x46\xF0\xEF\x23\x2A\xFA\xFE\xE3\xBD\x46"
|
||||
. "\x69\x94\x67\x68\x70\x7E\x0D\x97\x53\x44"
|
||||
. "\x1B\xC9\xBA\x79\x8D\x50\x1E\xD7\xA9\x0C"
|
||||
. "\x8D\xEE\xFB\x7E\x12\x27\x79\x12\x0C\x38"
|
||||
. "\x58\x74\xCB\xBE\xDC\x3C\x3D\xE9\xD3\x90"
|
||||
. "\x2F\xED\x5A\xE8\x68\xE6\x39\x86\xBF\xE2"
|
||||
. "\x91\x4D\xD1\x8E\xCA\xE3\xB4\x45\xF5\xBF"
|
||||
. "\x7C\x4E\x35\x49\x0D\x12\x85\x4A\xFA\x59"
|
||||
. "\xD9\x2A\x47\x35\x14\xAF\x1D\x4D\x36\xDB"
|
||||
. "\x30\xC6\x29\x03\x55\xF3\xE5\x0B\x39\xDB"
|
||||
. "\xC9\xB4\x2B\xFD\xFC\x38\x11\x83\x81\x0C"
|
||||
. "\xDB\x5C\x36\x24\x91\x4A\xD2\xAD\x97\x09"
|
||||
. "\x89\xC6\xCF\xB2\xC9\x26\xA6\xAF\x30\xDF"
|
||||
. "\x8C\xF9\x95\xB6\xF8\x93\xED\x0A\x17\x70"
|
||||
. "\x16\xF1\xCC\x4C\x17\x5E\x96\xE8\x0D\x2E"
|
||||
. "\xF1\x95\xF3\xC1\x49\xBE\xE6\xEF\x6E\x18",
|
||||
'1cae7ca47cde6ca52522ce31771a5c54',
|
||||
],
|
||||
[
|
||||
'',
|
||||
"\x9E\xC6\x2D\x5E\xE7\x53\x3C\x2D\x68\x3E"
|
||||
. "\x7A\x58\xF5\x08\x15\x4C\xAA\xFA\x57\x06"
|
||||
. "\xA2\x20\x2B\xD0\x11\x60\x8B\x2B\xC0\x0F"
|
||||
. "\x39\x5F\xD4\x66\xBD\xBC\xB8\xF9\xE9\x22"
|
||||
. "\x38\x65\x7A\x2F\x6C\x8E\x7A\x18\x89\xD1"
|
||||
. "\x1E\x2D\xF0\x48\xFD\x02\xA7\x8A\x2C\x69"
|
||||
. "\x98\x65\xC8\x6D\xCA\x87\x2B\x84\x81\x15"
|
||||
. "\xA5\xB9\x79\x20\xE7\xE5\xAE\x63\xFC\x39"
|
||||
. "\x35\x1B\x65\x26\x63\x64\x27\x0C\xED\x53"
|
||||
. "\x74\x86\xB7\x3E\xF3\x83\xC4\x1F\x08\x46"
|
||||
. "\x34\xAC\xFE\xAD\xCC\xE7\x93\x7C\x4B\x91"
|
||||
. "\xB4\x80\xAC\x1B\xA5\x10\x7E\xCC\x1B\x6D"
|
||||
. "\x21\x8F\xF2\xD8\xCC\xE7\x5C\x91\x07\x63"
|
||||
. "\xD6\x3B\x11\xD6\xE7\xDD\xBE\x7C\x5A\x0B"
|
||||
. "\x0E\x10\x8A\xBA\x2B\x31\xC9\xA8\xFC\xE3"
|
||||
. "\x16\x1F\x74\x0A\xF6\x41\xF0\x53\xD1\xF7"
|
||||
. "\xB6\xA9\x34\xC7\x81\x1D\xA5\x41\x98\x01"
|
||||
. "\x4B\xA6\x11\xD4\x61\x3B\x07\x2C\xE3\x04"
|
||||
. "\x11\xF9\x23\x84\x05\x1A\xC4\xF4\x6C\x97"
|
||||
. "\xED\x24\x42\x22\xEA\xC2\x3F\x91\x04\xD6"
|
||||
. "\x92\x4F\x7E\xA2\x24\xDE\xDC\x2A\x0C\xC1"
|
||||
. "\x2E\x1C\xBB\x50\x9F\xBF\x6A\x64\xB5\xD5"
|
||||
. "\xFB\xA4\xF9\x3E\xC6\xE4\x02\x06\x77\x05"
|
||||
. "\xDC\x0A\x53\x5B\xAB\x77\x3B\x89\xA1\x46"
|
||||
. "\x4B\xCF\x61\x08\x21\x01\xC6\x8A\x65\x7D"
|
||||
. "\x61\x61\x22\x5B\x9F\xE7\x41\xA0\xED\xB7"
|
||||
. "\xA5\xCA\xC0\xF8\x26\x6C\x70\x60\xF5\x13"
|
||||
. "\xA6\x41\xE1\x08\x48\x04\x09\x10\x8D\x6D"
|
||||
. "\x8D\xED\xCE\xAE\x49\x6F\x97\x8A\x10\x85"
|
||||
. "\x42\xB4\x51\x03\xAD\x76\x6F\x1F\xD6\x65"
|
||||
. "\x31\x7D\xA6\x14\x85\xEE\x17\x8D\xFE\xA3"
|
||||
. "\xFA\x8C\x92\xCA\x3C\xDB\x3A\xD3\x66\x49"
|
||||
. "\x5A\xA7\xFD\xAA\xAA\xAC\x22\x1B\xCA\xF7"
|
||||
. "\x80\xFB\x75\x27\x11\xF9\x17\x27\x88\x16"
|
||||
. "\xCA\x83\xA2\x5E\x4E\xDE\x3A\x88\xB2\x9F"
|
||||
. "\xD1\x0E\x48\xCF\xB7\xF2\x7C\xD9\x0E\x48"
|
||||
. "\xD1\x8D\x45\x48\xB4\x55\x43\xCA\x7C\xCA"
|
||||
. "\xE0\x48\x4F\x83\xA5\x9D\x63\xDF\x26\x17"
|
||||
. "\x80\xF6\x24\xC7\xC7\xDB\xBB\x45\xB5\xC8"
|
||||
. "\x8C\x88\x56\xD0\xCF\x0B\x27\x13\xD5\xA2"
|
||||
. "\xDD\xB6\xE9\x2E\x3B\x90\xCA\x9D\x70\xF0"
|
||||
. "\xB3\xF0\xE7\xD7\xB9\xB0\xB4\x75\xF4\x6A"
|
||||
. "\x3E\x81\xF2\x94\x53\xC2\x9F\x79\xD5\x75"
|
||||
. "\x1D\xB3\x2C\x08\xE0\x67\x97\xAC\x05\x09"
|
||||
. "\x9D\xB8\xF8\x86\x91\xB3\x37\x46\x29\x2C"
|
||||
. "\xB0\x66\xAD\xA3\xFA\x02\x67\x9A\x7B\x3D"
|
||||
. "\x10\x97\xF0\x3C\x9F\xD2\xA2\x37\x7F\xA7"
|
||||
. "\x40\x1E\x61\x3A\xA3\xF1\xEC\xDA\x39\x16"
|
||||
. "\x08\xE9\x7C\xB4\x8D\x77\xB6\xF3\x12\x33"
|
||||
. "\x32\x22\xC9\x23\x5D\x6A\xF4\x01\xA1\x74"
|
||||
. "\xA7\xE0\x92\x09\x1C\x36\xFA\x0A\x11\x35"
|
||||
. "\x20\x18\x1F\x9B\xCC\xAC\x14\x84\xA0\x26"
|
||||
. "\xB6\xD1\x48\x81\xF3\xA4\xEA\xE9\xA4\x8C"
|
||||
. "\x5F\x4D\x6E\xF0\x56\x89\x27\x51\x92\x38"
|
||||
. "\x86\xB1\x50\xA4\x4E\x1E\x51\x62\xA1\xF1"
|
||||
. "\x87\x58\xC4\xCE\xD8\xB9\x74\xC3\xA3\x1A"
|
||||
. "\x51\x03\x66\xBE\xF3\xBB\x48\x1C\x0E\xDA"
|
||||
. "\x53\x93\x8D\xA3\x39\xDA\xC0\x89\x3D\x62"
|
||||
. "\x7C\xC4\xBA\x41\x94\x93\xF9\x09\x58\x9D"
|
||||
. "\x22\xA8\xA0\x87\x67\x94\x44\xAF\xB0\x51"
|
||||
. "\x8A\x04\xE4\x19\xA7\x1E\xF2\x68\xA7\x31"
|
||||
. "\xCA\x24\xF4\x85\x64\x8A\x1A\x5E\x92\x71"
|
||||
. "\xFB\xB4\x1B\x9D\x3D\x81\x33\x80\x32\xE2"
|
||||
. "\xD1\xBC\xE6\xB6\xD4\x8E\xD4\xC8\xF6\x7C"
|
||||
. "\xF8\xC1\x9F\xEE\x47\x04\x79\x60\x62\x0D"
|
||||
. "\xD1\x5F\xC1\xEB\xFB\xFD\x6E\x2F\x7F\x9F"
|
||||
. "\x12\x51\x5D\xF7\x09\x32\x87\xDC\xF9\x7E"
|
||||
. "\x5A\xF3\x40\xF8\xE3\x87\xFC\x5E\xE7\x60"
|
||||
. "\x6A\xBA\xBE\x2C\xA6\xBB\x2B\x15\xE9\xA9"
|
||||
. "\xB4\xFB\xFA\x12\xF4\x05\x44\x7C\xE1\x3F"
|
||||
. "\xFA\x3C\x34\x3B\x35\x18\xC2\x33\x75\xAB"
|
||||
. "\x92\xDF\x66\x52\x0C\x0D\x0E\x36\x22\xF6"
|
||||
. "\xDF\xD6\xF3\xDA\xE8\xE8\xDE\x2D\x66\xC0"
|
||||
. "\x6C\x61\xFC\x9F\x9C\x32\xB7\x60\x65\x2D"
|
||||
. "\x0C\xF6\x0D\x71\x49\x19\x7E\x57\x4F\xA0"
|
||||
. "\x4E\x2F\x77\x43\x0B\x60\x2D\xE9\x8D\x92"
|
||||
. "\xAB\xF9\xF2\xA8\x99\x8F\xDA\x51\xEE\x40"
|
||||
. "\x7E\xFA\x37\x8B\x6D\x80\xA3\xEA\xD6\xF2"
|
||||
. "\x8B\x26\x22\x04\x68\x2D\x64\x94\x17\xF1"
|
||||
. "\x28\xC2\xEB\x1B\x6B\x85\xAA\x46\xD6\x9A"
|
||||
. "\x85\x56\x95\xBC\xE0\x03\x3D\x85\xED\x15"
|
||||
. "\x79\x7A\x3B\x9A\x7D\xA3\xC7\xE1\x38\xDE"
|
||||
. "\xD3\x60\xA1\xBF\x7A\x0D\x46\x26\x52\x1E"
|
||||
. "\xBF\xD7\x73\x56\x94\x55\x59\xD1\xDA\x47"
|
||||
. "\xE6\x54\xC1\x22\xEE\x3F\xC4\xB6\x22\xFC"
|
||||
. "\x95\xF4\x5D\x37\xB4\xD7\x44\xF9\xFC\x96"
|
||||
. "\x18\xBD\x6E\x8B\x15\x04\xDF\x6D\xD5\xBA"
|
||||
. "\xB4\xBC\x10\x76\xDD\xFD\xB5\xA3\xB4\xD6"
|
||||
. "\xA0\x4B\xCB\xFC\x82\x81\xD5\xC5\x7C\xD2"
|
||||
. "\x5C\x94\x91\xCA\x20\xA6\xCD\x01\x15\xA4"
|
||||
. "\xBB\xC8\x61\xCA\x40\x40\xC8\xF5\xE2\x7E"
|
||||
. "\xCD\x84\xC9\x9A\x82\x4C\x1C\x58\x12\x98"
|
||||
. "\x2C\x6E\x2D\xBC\x39\x4C\x64\x08\x4C\x78"
|
||||
. "\xAC\x09\x41\x0E\xD2\x81\x4E\x9C\x78\x32"
|
||||
. "\x1C\x46\xB5\xE4\xDF\x38\x31\xFB\x8F\x43"
|
||||
. "\x94\xBB\xB0\xC0\x78\xE9\x0E\xDB\xF1\x5A"
|
||||
. "\x55\x9E\x62\x96\xAC\x36\x18\xF9\xD1\x8F"
|
||||
. "\x2D\xEC\xD5\xE1\xD2\xB6\x1B\x04\xB3\xA9"
|
||||
. "\x46\x48\x65\xF6\x0A\xDD\xE1\x18\xBA\xD4"
|
||||
. "\x71\x10\x73\xD3\xA5\x21\x0A\xBD\x1C\xDB",
|
||||
'6c1033648fc11250ad22006398cd1bdc',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
#[DataProvider('getStringDataProvider')]
|
||||
public function testStrings(string $code): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('PDF417', $code);
|
||||
$this->assertNotNull($type); // @phpstan-ignore method.alreadyNarrowedType
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array{string}>
|
||||
*/
|
||||
public static function getStringDataProvider(): array
|
||||
{
|
||||
return \Test\TestStrings::$data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* QrCodeTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Square;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Test\TestUtil;
|
||||
|
||||
/**
|
||||
* QR-Code Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class QrCodeTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$barcode->getBarcodeObj('QRCODE', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testCapacityException(): void
|
||||
{
|
||||
$this->bcExpectException(\Com\Tecnick\Barcode\Exception::class);
|
||||
$barcode = $this->getTestObject();
|
||||
$code = \str_pad('', 4000, 'iVoo{[O17n~>(FXC9{*t1P532}l7E{7/R\' ObO`y?`9G(qjBmu7 GM3ZK!qp|)!P1" sRanqC(:Ky');
|
||||
$barcode->getBarcodeObj('QRCODE', $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
#[DataProvider('getGridDataProvider')]
|
||||
public function testGetGrid(string $options, string $code, mixed $expected): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('QRCODE' . $options, $code);
|
||||
$grid = $type->getGrid();
|
||||
$this->assertEquals($expected, \md5($grid));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array{string, string, string}>
|
||||
*/
|
||||
public static function getGridDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'',
|
||||
'0123456789',
|
||||
'89e599523008751db7eef3b5befc37ed',
|
||||
],
|
||||
[
|
||||
',L',
|
||||
'0123456789',
|
||||
'89e599523008751db7eef3b5befc37ed',
|
||||
],
|
||||
[
|
||||
',H,NM',
|
||||
'0123456789',
|
||||
'07c7cc526ed4efdc303ff133f3912619',
|
||||
],
|
||||
[
|
||||
',L,8B,0,0',
|
||||
'123aeiouàèìòù',
|
||||
'1622068066c77d3e6ea0a3ad420d105c',
|
||||
],
|
||||
[
|
||||
',H,KJ,0,0',
|
||||
'ぎポ亊',
|
||||
'00cb1bd983bfe7b3d942c3f89f7643f5',
|
||||
],
|
||||
[
|
||||
',H,ST,0,0',
|
||||
'ABCdef0123',
|
||||
'a09df8f57bfd39faaf08acaa23eca45c',
|
||||
],
|
||||
[
|
||||
'',
|
||||
\str_pad('', 350, '0123456789'),
|
||||
'1a4753c428f644794b9ee1515138ecb3',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'abcdefghijklmnopqrstuvwxyz01234567890123456789',
|
||||
'b41c13e6bba528cc0390d1797bbac38e',
|
||||
],
|
||||
[
|
||||
',H,AN,40,1,0,1,2',
|
||||
'abcdefghijklmnopqrstuvwxyz01234567890123456789',
|
||||
'5ba221be81b269ab1f105b07bf49b372',
|
||||
],
|
||||
[
|
||||
'',
|
||||
"\x9E\x13\xC0\x08\x47\x71\x6B\xFC\xAB\xA9"
|
||||
. "\x72\x72\xCC\x97\xB7\x14\xB4\x1A\x49\x4C"
|
||||
. "\xC1\x10\x45\xD4\xE8\x5A\xF8\x73\x09\x68"
|
||||
. "\x95\xA7\x7B\x56\xAF\xC1\xC7\x1B\xBE\x73"
|
||||
. "\xC4\x32\xE4\x92\xC9\x9C\xA5\x7E\xB6\xED"
|
||||
. "\xC9\x79\xFD\x0F\x4E\xE7\x69\x48\x5C\x72"
|
||||
. "\xAF\xF0\x1A\x2B\x47\xC8\xEC\x0F\xE3\xAC"
|
||||
. "\x81\xA9\xDD\x67\x3C\xA7\x05\xE1\x27\xBA"
|
||||
. "\xD0\xF0\x34\xCE\xFE\x82\xB7\x69\xC9\x14"
|
||||
. "\xDA\x7A\x05\xF4\xA5\x4C\xBD\x92\x5B\xA2"
|
||||
. "\x3F\xDC\x4C\x1E\x44\x87\xC4\x49\x6A\xEB"
|
||||
. "\x05\x3B\xDC\x38\x0B\xDC\xBA\xC2\x46\x84"
|
||||
. "\xD5\x22\xFE\xDA\x17\xA4\x28\xD4\x38\x82"
|
||||
. "\x77\x76\x5F\xC2\x94\xA3\x4B\x5A\xEC\xB4"
|
||||
. "\x46\xF0\xEF\x23\x2A\xFA\xFE\xE3\xBD\x46"
|
||||
. "\x69\x94\x67\x68\x70\x7E\x0D\x97\x53\x44"
|
||||
. "\x1B\xC9\xBA\x79\x8D\x50\x1E\xD7\xA9\x0C"
|
||||
. "\x8D\xEE\xFB\x7E\x12\x27\x79\x12\x0C\x38"
|
||||
. "\x58\x74\xCB\xBE\xDC\x3C\x3D\xE9\xD3\x90"
|
||||
. "\x2F\xED\x5A\xE8\x68\xE6\x39\x86\xBF\xE2"
|
||||
. "\x91\x4D\xD1\x8E\xCA\xE3\xB4\x45\xF5\xBF"
|
||||
. "\x7C\x4E\x35\x49\x0D\x12\x85\x4A\xFA\x59"
|
||||
. "\xD9\x2A\x47\x35\x14\xAF\x1D\x4D\x36\xDB"
|
||||
. "\x30\xC6\x29\x03\x55\xF3\xE5\x0B\x39\xDB"
|
||||
. "\xC9\xB4\x2B\xFD\xFC\x38\x11\x83\x81\x0C"
|
||||
. "\xDB\x5C\x36\x24\x91\x4A\xD2\xAD\x97\x09"
|
||||
. "\x89\xC6\xCF\xB2\xC9\x26\xA6\xAF\x30\xDF"
|
||||
. "\x8C\xF9\x95\xB6\xF8\x93\xED\x0A\x17\x70"
|
||||
. "\x16\xF1\xCC\x4C\x17\x5E\x96\xE8\x0D\x2E"
|
||||
. "\xF1\x95\xF3\xC1\x49\xBE\xE6\xEF\x6E\x18",
|
||||
'6a418df382be3ad883e29c92ff7c4a6b',
|
||||
],
|
||||
[
|
||||
'',
|
||||
"\x9E\xC6\x2D\x5E\xE7\x53\x3C\x2D\x68\x3E"
|
||||
. "\x7A\x58\xF5\x08\x15\x4C\xAA\xFA\x57\x06"
|
||||
. "\xA2\x20\x2B\xD0\x11\x60\x8B\x2B\xC0\x0F"
|
||||
. "\x39\x5F\xD4\x66\xBD\xBC\xB8\xF9\xE9\x22"
|
||||
. "\x38\x65\x7A\x2F\x6C\x8E\x7A\x18\x89\xD1"
|
||||
. "\x1E\x2D\xF0\x48\xFD\x02\xA7\x8A\x2C\x69"
|
||||
. "\x98\x65\xC8\x6D\xCA\x87\x2B\x84\x81\x15"
|
||||
. "\xA5\xB9\x79\x20\xE7\xE5\xAE\x63\xFC\x39"
|
||||
. "\x35\x1B\x65\x26\x63\x64\x27\x0C\xED\x53"
|
||||
. "\x74\x86\xB7\x3E\xF3\x83\xC4\x1F\x08\x46"
|
||||
. "\x34\xAC\xFE\xAD\xCC\xE7\x93\x7C\x4B\x91"
|
||||
. "\xB4\x80\xAC\x1B\xA5\x10\x7E\xCC\x1B\x6D"
|
||||
. "\x21\x8F\xF2\xD8\xCC\xE7\x5C\x91\x07\x63"
|
||||
. "\xD6\x3B\x11\xD6\xE7\xDD\xBE\x7C\x5A\x0B"
|
||||
. "\x0E\x10\x8A\xBA\x2B\x31\xC9\xA8\xFC\xE3"
|
||||
. "\x16\x1F\x74\x0A\xF6\x41\xF0\x53\xD1\xF7"
|
||||
. "\xB6\xA9\x34\xC7\x81\x1D\xA5\x41\x98\x01"
|
||||
. "\x4B\xA6\x11\xD4\x61\x3B\x07\x2C\xE3\x04"
|
||||
. "\x11\xF9\x23\x84\x05\x1A\xC4\xF4\x6C\x97"
|
||||
. "\xED\x24\x42\x22\xEA\xC2\x3F\x91\x04\xD6"
|
||||
. "\x92\x4F\x7E\xA2\x24\xDE\xDC\x2A\x0C\xC1"
|
||||
. "\x2E\x1C\xBB\x50\x9F\xBF\x6A\x64\xB5\xD5"
|
||||
. "\xFB\xA4\xF9\x3E\xC6\xE4\x02\x06\x77\x05"
|
||||
. "\xDC\x0A\x53\x5B\xAB\x77\x3B\x89\xA1\x46"
|
||||
. "\x4B\xCF\x61\x08\x21\x01\xC6\x8A\x65\x7D"
|
||||
. "\x61\x61\x22\x5B\x9F\xE7\x41\xA0\xED\xB7"
|
||||
. "\xA5\xCA\xC0\xF8\x26\x6C\x70\x60\xF5\x13"
|
||||
. "\xA6\x41\xE1\x08\x48\x04\x09\x10\x8D\x6D"
|
||||
. "\x8D\xED\xCE\xAE\x49\x6F\x97\x8A\x10\x85"
|
||||
. "\x42\xB4\x51\x03\xAD\x76\x6F\x1F\xD6\x65"
|
||||
. "\x31\x7D\xA6\x14\x85\xEE\x17\x8D\xFE\xA3"
|
||||
. "\xFA\x8C\x92\xCA\x3C\xDB\x3A\xD3\x66\x49"
|
||||
. "\x5A\xA7\xFD\xAA\xAA\xAC\x22\x1B\xCA\xF7"
|
||||
. "\x80\xFB\x75\x27\x11\xF9\x17\x27\x88\x16"
|
||||
. "\xCA\x83\xA2\x5E\x4E\xDE\x3A\x88\xB2\x9F"
|
||||
. "\xD1\x0E\x48\xCF\xB7\xF2\x7C\xD9\x0E\x48"
|
||||
. "\xD1\x8D\x45\x48\xB4\x55\x43\xCA\x7C\xCA"
|
||||
. "\xE0\x48\x4F\x83\xA5\x9D\x63\xDF\x26\x17"
|
||||
. "\x80\xF6\x24\xC7\xC7\xDB\xBB\x45\xB5\xC8"
|
||||
. "\x8C\x88\x56\xD0\xCF\x0B\x27\x13\xD5\xA2"
|
||||
. "\xDD\xB6\xE9\x2E\x3B\x90\xCA\x9D\x70\xF0"
|
||||
. "\xB3\xF0\xE7\xD7\xB9\xB0\xB4\x75\xF4\x6A"
|
||||
. "\x3E\x81\xF2\x94\x53\xC2\x9F\x79\xD5\x75"
|
||||
. "\x1D\xB3\x2C\x08\xE0\x67\x97\xAC\x05\x09"
|
||||
. "\x9D\xB8\xF8\x86\x91\xB3\x37\x46\x29\x2C"
|
||||
. "\xB0\x66\xAD\xA3\xFA\x02\x67\x9A\x7B\x3D"
|
||||
. "\x10\x97\xF0\x3C\x9F\xD2\xA2\x37\x7F\xA7"
|
||||
. "\x40\x1E\x61\x3A\xA3\xF1\xEC\xDA\x39\x16"
|
||||
. "\x08\xE9\x7C\xB4\x8D\x77\xB6\xF3\x12\x33"
|
||||
. "\x32\x22\xC9\x23\x5D\x6A\xF4\x01\xA1\x74"
|
||||
. "\xA7\xE0\x92\x09\x1C\x36\xFA\x0A\x11\x35"
|
||||
. "\x20\x18\x1F\x9B\xCC\xAC\x14\x84\xA0\x26"
|
||||
. "\xB6\xD1\x48\x81\xF3\xA4\xEA\xE9\xA4\x8C"
|
||||
. "\x5F\x4D\x6E\xF0\x56\x89\x27\x51\x92\x38"
|
||||
. "\x86\xB1\x50\xA4\x4E\x1E\x51\x62\xA1\xF1"
|
||||
. "\x87\x58\xC4\xCE\xD8\xB9\x74\xC3\xA3\x1A"
|
||||
. "\x51\x03\x66\xBE\xF3\xBB\x48\x1C\x0E\xDA"
|
||||
. "\x53\x93\x8D\xA3\x39\xDA\xC0\x89\x3D\x62"
|
||||
. "\x7C\xC4\xBA\x41\x94\x93\xF9\x09\x58\x9D"
|
||||
. "\x22\xA8\xA0\x87\x67\x94\x44\xAF\xB0\x51"
|
||||
. "\x8A\x04\xE4\x19\xA7\x1E\xF2\x68\xA7\x31"
|
||||
. "\xCA\x24\xF4\x85\x64\x8A\x1A\x5E\x92\x71"
|
||||
. "\xFB\xB4\x1B\x9D\x3D\x81\x33\x80\x32\xE2"
|
||||
. "\xD1\xBC\xE6\xB6\xD4\x8E\xD4\xC8\xF6\x7C"
|
||||
. "\xF8\xC1\x9F\xEE\x47\x04\x79\x60\x62\x0D"
|
||||
. "\xD1\x5F\xC1\xEB\xFB\xFD\x6E\x2F\x7F\x9F"
|
||||
. "\x12\x51\x5D\xF7\x09\x32\x87\xDC\xF9\x7E"
|
||||
. "\x5A\xF3\x40\xF8\xE3\x87\xFC\x5E\xE7\x60"
|
||||
. "\x6A\xBA\xBE\x2C\xA6\xBB\x2B\x15\xE9\xA9"
|
||||
. "\xB4\xFB\xFA\x12\xF4\x05\x44\x7C\xE1\x3F"
|
||||
. "\xFA\x3C\x34\x3B\x35\x18\xC2\x33\x75\xAB"
|
||||
. "\x92\xDF\x66\x52\x0C\x0D\x0E\x36\x22\xF6"
|
||||
. "\xDF\xD6\xF3\xDA\xE8\xE8\xDE\x2D\x66\xC0"
|
||||
. "\x6C\x61\xFC\x9F\x9C\x32\xB7\x60\x65\x2D"
|
||||
. "\x0C\xF6\x0D\x71\x49\x19\x7E\x57\x4F\xA0"
|
||||
. "\x4E\x2F\x77\x43\x0B\x60\x2D\xE9\x8D\x92"
|
||||
. "\xAB\xF9\xF2\xA8\x99\x8F\xDA\x51\xEE\x40"
|
||||
. "\x7E\xFA\x37\x8B\x6D\x80\xA3\xEA\xD6\xF2"
|
||||
. "\x8B\x26\x22\x04\x68\x2D\x64\x94\x17\xF1"
|
||||
. "\x28\xC2\xEB\x1B\x6B\x85\xAA\x46\xD6\x9A"
|
||||
. "\x85\x56\x95\xBC\xE0\x03\x3D\x85\xED\x15"
|
||||
. "\x79\x7A\x3B\x9A\x7D\xA3\xC7\xE1\x38\xDE"
|
||||
. "\xD3\x60\xA1\xBF\x7A\x0D\x46\x26\x52\x1E"
|
||||
. "\xBF\xD7\x73\x56\x94\x55\x59\xD1\xDA\x47"
|
||||
. "\xE6\x54\xC1\x22\xEE\x3F\xC4\xB6\x22\xFC"
|
||||
. "\x95\xF4\x5D\x37\xB4\xD7\x44\xF9\xFC\x96"
|
||||
. "\x18\xBD\x6E\x8B\x15\x04\xDF\x6D\xD5\xBA"
|
||||
. "\xB4\xBC\x10\x76\xDD\xFD\xB5\xA3\xB4\xD6"
|
||||
. "\xA0\x4B\xCB\xFC\x82\x81\xD5\xC5\x7C\xD2"
|
||||
. "\x5C\x94\x91\xCA\x20\xA6\xCD\x01\x15\xA4"
|
||||
. "\xBB\xC8\x61\xCA\x40\x40\xC8\xF5\xE2\x7E"
|
||||
. "\xCD\x84\xC9\x9A\x82\x4C\x1C\x58\x12\x98"
|
||||
. "\x2C\x6E\x2D\xBC\x39\x4C\x64\x08\x4C\x78"
|
||||
. "\xAC\x09\x41\x0E\xD2\x81\x4E\x9C\x78\x32"
|
||||
. "\x1C\x46\xB5\xE4\xDF\x38\x31\xFB\x8F\x43"
|
||||
. "\x94\xBB\xB0\xC0\x78\xE9\x0E\xDB\xF1\x5A"
|
||||
. "\x55\x9E\x62\x96\xAC\x36\x18\xF9\xD1\x8F"
|
||||
. "\x2D\xEC\xD5\xE1\xD2\xB6\x1B\x04\xB3\xA9"
|
||||
. "\x46\x48\x65\xF6\x0A\xDD\xE1\x18\xBA\xD4"
|
||||
. "\x71\x10\x73\xD3\xA5\x21\x0A\xBD\x1C\xDB",
|
||||
'ffed7d96ae53a9c63c88d426680833dd',
|
||||
],
|
||||
[
|
||||
',H,NM',
|
||||
|
||||
"\x1A\x97\xE0\xC1\x47\x20\xA2\xBF\x1E\x62"
|
||||
. "\x52\x0D\x99\x91\x45\x03\x7B\xE3\x32\xC8"
|
||||
. "\x18\xEA\x80\x51\xE8\x70\x93\x2D\x19\x08"
|
||||
. "\x26\x33\x9E\x07\xF3\xE5\x27\x96\xA5\x45"
|
||||
. "\xF7\xF6\x51\x92\x89\x95\x94\x06\x7A\xC5",
|
||||
|
||||
'4f6fd3799489b48fa07e1a7aef0561fc',
|
||||
],
|
||||
[
|
||||
',H,AN',
|
||||
|
||||
"\xCD\x92\xB0\x4F\xE2\x9A\xBF\x76\xC6\xD7"
|
||||
. "\x7E\xEC\x0C\x1D\xF3\xFE\x04\x1B\x96\xA8"
|
||||
. "\x60\x8E\xA0\xB0\x22\x2A\x47\xB6\x30\xC0"
|
||||
. "\x7D\xFC\x54\x2E\x4D\x37\xC8\x0D\xAD\x90"
|
||||
. "\xE3\x2C\x7D\xEE\x49\x71\xEE\x4C\x8C\x85",
|
||||
|
||||
'55cd590ed76d12591c6df3b673904530',
|
||||
],
|
||||
[
|
||||
',H,KJ',
|
||||
"\xF4\xEB\x15\x95\x9D\x36\xBF\xE3\xEB\xEE"
|
||||
. "\xA5\x69\xEC\xF8\x97\x3A\x31\x61\x46\xDD"
|
||||
. "\xF0\x2B\x0B\x6F\x1B\x53\xDF\x0A\x9F\x6D"
|
||||
. "\x8E\x94\x59\xA3\x2A\xF6\xD8\xE9\xDA\xC5"
|
||||
. "\xD8\x81\x30\xC5\x7A\xC7\x01\xAA\x29\x46",
|
||||
|
||||
'92e82c296965d97d35ab7168ece11dd0',
|
||||
],
|
||||
[
|
||||
',H,8B',
|
||||
"\x89\x1B\x70\x93\x89\x8A\xE6\x6A\x94\x86"
|
||||
. "\xD6\x24\x1B\x31\xC6\x45\x28\xA0\x2F\x04"
|
||||
. "\x67\x09\x85\x96\xCE\xFE\x5F\xCE\xAA\x88"
|
||||
. "\x16\x35\xA2\x86\xC7\x2D\x12\xAE\x96\xA5"
|
||||
. "\x36\x6D\xC9\x51\x9E\x90\x96\xC6\x32\xC4",
|
||||
'68799fdb9685b5e2f258245833006425',
|
||||
],
|
||||
[
|
||||
',H,ST',
|
||||
"\xC9\x98\xCD\x4F\x2F\x9D\x4F\x8E\x6C\xF9"
|
||||
. "\x17\x82\x2F\xB9\x09\xF6\xE5\x1A\xA6\x7C"
|
||||
. "\xBF\xDB\xE9\x89\x2D\x89\x1B\xC2\x50\x4C"
|
||||
. "\x88\x1B\xE3\x57\x6A\x14\xF3\xB8\xA1\x61"
|
||||
. "\xB3\xB8\xE2\xE2\x72\xEB\xD9\x58\x06\x81",
|
||||
'6fb328c418ea40c6c94277f420ba9357',
|
||||
],
|
||||
[
|
||||
'',
|
||||
'w(fa`nC]e=}OY(K^ 3xN1Vz1g<F=P%!H-h*nWNL>kKnFS;&TN '
|
||||
. '$`W~r?;9\\l?]5MF@<~oh>\\4-#hH*=w*AYaAL!]f^J&<`Tc!'
|
||||
. 'pcpZ"Nn0RWY\\uQf8+HZXJ8?*bFGDz+Eln7Gqe6"8n[te.\\}'
|
||||
. ':&YrQq3[UY#yU.@B}Xio>!rWoNMV]*Uw0/kb!~>WYAR0PrROK'
|
||||
. '=?j>3B/boe@z;8,K$nM$-%]OWm KAOv^oa}#%-ets&p/?|[Dk'
|
||||
. ')Hy.\'IfuI27y*viktmq#Tfv[X\'zUb?Bkh=zofbe1t|+~tuk'
|
||||
. 'id]l9Edt}kpTO0w<x57h|yO.oM:oB1[-u:z/`_%_Lu4{\',9 '
|
||||
. 'BPi?K:M;gh,+yh8p#3!ds&D@|X=$eV%((oGS*uor^{}Ye6JhJ'
|
||||
. 'LM>Sr^PK|T2SZ:[Jb0UX!I8}Grc^>L)jzG>n\'n:%DMX g5KK'
|
||||
. 'F!$GJ=Er0*QOVZ:R#YA+H\\0m*inr :>G;Cof`5Yq@,Avg\\J'
|
||||
. 'j6lv_J(MUq<IrWg:s,*Zl@5_`B"X*^$utqlT<t#rg@<[w%uk1'
|
||||
. '!G~A]^# `\\*?` 5RmiocmcL. (&&~r7 :6BwuFwW##wc#-7q'
|
||||
. 'w(Uek#sl+zr*m*+)AN!8tyow|h\\!vssn|IUiMJVXEJc4To>v'
|
||||
. '>?03:!+8ig9`\\-PZW\'D%Qz^wEC,z3JrQj#d&$p>nYXP6f!p'
|
||||
. '?)5EZ1$RWH_S[+F-vIr|Nc<==tmT\\oF{x\\ASnF\'FnfyKr@'
|
||||
. 'YijLg91$VOyD%V4KS-(tav;h>+P8VCY0.D]u^nz6?tZDLoo }'
|
||||
. 'xt_p1I0=zIs?#%MHbD(R?>q4y7ai(ah"WIrir$\'nM{.P![yd'
|
||||
. ' "7@@*T:A7%IxmKP7?:+CAyp>)B?e<$e><\'_F\\yhs~2ll^>'
|
||||
. '%~X1Bz+494VYys^`2zhrBEl+9l>&Y}D_|}p@y|T32,m- Ln3H'
|
||||
. 'W&j|sv6`6=;5bz2alS[i(o{5]*6*xIRPP>NE6d&L#Abe=tG+H'
|
||||
. '$tQsqgQ{}\\tH0FyNt?eZE2]gtD&jl14p\'fdxO7uMskv$2pS'
|
||||
. '(19bWLA@BeF-RXBD_*)YY@O\'5;~9NolV!\':YS[yuA@$tyF9'
|
||||
. 'YPC3*cc2y~13N"!%$(@][{WR>xV4r|MMNp`YUDkPD|cr~ex#m'
|
||||
. '9`J69}T2Th&R7S")4[_YG0~EtqDZkHI&*t<CrpVHZ\\zr0|{E'
|
||||
. 'X[ !l~Faqk<]4fd?[!bNr:vMvr@(p=MJyMKfMrH?^e}sLb3)c'
|
||||
. 'uWV0O%(CF04c]_],,EY~ny^TwR"[e+@[cwl3|uWD&l(dLfqY,'
|
||||
. 'LXzF7P?iRzO^<,B4yV2o.Vvz^[HFM"Ry[NAr~`]R\\.1x;S.5'
|
||||
. '*@%9v|4VX]|\'_P";~C/~%mQa{c[77iMB+R["PpY)NV1/(3K('
|
||||
. 'W[\'\\IY?E={]Uf+wq^Ts/EM9t%J$-]P65,=rUw2{6.Zktedg'
|
||||
. 'E:\\U`+nU09Z>w+T.8r!mk4j"CEn9+S!Qn]\'Ohu%y0`9)lm7'
|
||||
. '%a9sMN^Oq$?,0r.ablh2U_8PoxixeX1k;K_hy>9lBXxRL\'5/'
|
||||
. 's~BJ^Z{OSfI:?[&[\'eD!$^mG8gzen1uc08/or+@Fria2FgnM'
|
||||
. 'N3NRr=z+%uqt\'gY8 h(rtI:g4{zZdi(3}Wfpta|zXoo`WIxX'
|
||||
. '3"L)Kgp_cl:IVB\\UyCGo&Ej^5[?m&8F::rCfZ4F?"`hX$F/~'
|
||||
. 'iVoo{[O17n~>(FXC9{*t1P532}l7E{7/R\' ObO`y?`9G(qjB'
|
||||
. 'mu7 GM3ZK!qp|)!P1" sRanqC(:Ky&mh{&hDS|~ }qqzzrL,u'
|
||||
. 'L!H/o:RwU}r[l\\XrE|FB{FAm9=i-iv#7wKFgfx`<wTxd1QWV'
|
||||
. 'N~yKF<9_Y$lDzo[r<#[${=Atq:Y#k2Z;1UfXq!8K%&p vMs3P'
|
||||
. 'O7MlYB^s{b`/=|@rcxde21j9#k0P`C!0[N}5p]*m@k|^h>RM8'
|
||||
. '83KI~dMkt}L9 ]uN[,@:6/[",:jKl8c%L/OKs}7i{c#{BxK}%'
|
||||
. 'k9<zt>(0*S}C7#oGS;<QS&N8)KZ"vY(crD_hchxm<v1Tz!{N='
|
||||
. '9!p?P*H{dKs>TW2x8z]!sK=k]rf',
|
||||
'83747986cf0df320b915587609232076',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
#[DataProvider('getStringDataProvider')]
|
||||
public function testStrings(string $code): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('QRCODE,H,NL,0,1,3,1', $code);
|
||||
$this->assertNotNull($type); // @phpstan-ignore method.alreadyNarrowedType
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array{string}>
|
||||
*/
|
||||
public static function getStringDataProvider(): array
|
||||
{
|
||||
return \Test\TestStrings::$data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* RawTest.php
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test\Square;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Raw Barcode class test
|
||||
*
|
||||
* @since 2015-02-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class RawTest extends TestCase
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Barcode\Barcode
|
||||
{
|
||||
return new \Com\Tecnick\Barcode\Barcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testGetGrid(): void
|
||||
{
|
||||
$barcode = $this->getTestObject();
|
||||
$type = $barcode->getBarcodeObj('SRAW', '0101,1010,1100,0011');
|
||||
$grid = $type->getGrid();
|
||||
$expected = "0101\n1010\n1100\n0011\n";
|
||||
$this->assertEquals($expected, $grid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
// @codingStandardsIgnoreFile
|
||||
/**
|
||||
* TestStrings.php
|
||||
*
|
||||
* @since 2016-08-31
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
/**
|
||||
* Barcode class test
|
||||
*
|
||||
* @since 2016-08-31
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*/
|
||||
class TestStrings
|
||||
{
|
||||
/**
|
||||
* Array containing testing strings.
|
||||
*
|
||||
* @var array<array{string}>
|
||||
*
|
||||
* @phpcs:disable Generic.Files.LineLength.TooLong
|
||||
*/
|
||||
public static array $data = [
|
||||
// Reserved keywords
|
||||
[
|
||||
'__halt_compiler abstract and array as break callable case catch class clone const continue declare default die do echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval exit extends final for foreach function global goto if implements include include_once instanceof insteadof interface isset list namespace new or print private protected public require require_once return static switch throw trait try unset use var while xor',
|
||||
],
|
||||
[
|
||||
'__CLASS__ __DIR__ __FILE__ __FUNCTION__ __LINE__ __METHOD__ __NAMESPACE__ __TRAIT__ boolean bool integer float double string array object resource undefined undef null NULL (null) nil NIL true false True False TRUE FALSE None hasOwnProperty',
|
||||
],
|
||||
// Numeric Strings
|
||||
[
|
||||
'0 1 2 3 5 7 97 397 997 7919 99991 104729 01 012 0123 01234 012345 0123456 01234567 012345678 0123456789 1234567890 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 012345678900112233445566778899 012345678900112233445566778899000111222333444555666777888999 123456789012345678901234567890123456789 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999',
|
||||
],
|
||||
[
|
||||
'1.00 $1.00 1/2 1E2 1E02 1E+02 -1 -1.00 -$1.00 -1/2 -1E2 -1E02 -1E+02 1/0 0/0 -2147483648/-1 -9223372036854775808/-1 0.00 0..0 . 0.0.0 0,00 0,,0 , 0,0,0 0.0/0 1.0/0.0 0.0/0.0 1,0/0,0 0,0/0,0 --1 - -. -, NaN Infinity -Infinity INF 1#INF -1#IND 1#QNAN 1#SNAN 1#IND 0x0 0xffffffff 0xffffffffffffffff 0xabad1dea 1,000.00 1 000.00 1\'000.00 1,000,000.00 1 000 000.00 1\'000\'000.00 1.000,00 1 000,00 1\'000,00 1.000.000,00 1 000 000,00 1\'000\'000,00 01000 08 09 2.2250738585072011e-308 012-345-678-901-234-567-890-123-456-789',
|
||||
],
|
||||
// Special Characters
|
||||
[
|
||||
' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~',
|
||||
],
|
||||
[
|
||||
'Roses are [0;31mred[0m, violets are [0;34mblue. Hope you enjoy terminal hue But now...[20Cfor my greatest trick...[8m The quick brown fox...',
|
||||
],
|
||||
[
|
||||
'<<< ((( [[[ {{{ """ \'\'\' ``` ### ~~~ @@@ £££ $$$ %%% ^^^ &&& *** --- +++ === ___ ::: ;;; ,,, ... ??? ¬¬¬ ||| /// \\\\\\ !!! }}} ]]] ))) >>> ./;\'[]\-= <>?:"{}|_+ !@#$%^&*()`~ "\'"\'"\'\'\'\'"',
|
||||
],
|
||||
// Unicode Symbols
|
||||
[
|
||||
'Ω≈ç√∫˜µ≤≥÷ åß∂ƒ©˙∆˚¬…æ œ∑´®†¥¨ˆøπ“‘ ¡™£¢∞§¶•ªº–≠ ¸˛Ç◊ı˜Â¯˘¿ ÅÍÎÏ˝ÓÔÒÚÆ☃ Œ„´‰ˇÁ¨ˆØ∏”’ `⁄€‹›fifl‡°·‚—± ⅛⅜⅝⅞ ЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя ٠١٢٣٤٥٦٧٨٩ ␣ ␢ ␡ ⁰⁴⁵ ₀₁₂ ⁰⁴⁵₀₁₂',
|
||||
],
|
||||
// Two-Byte Characters
|
||||
[
|
||||
'田中さんにあげて下さい パーティーへ行かないか 和製漢語 部落格 사회과학원 어학연구소 찦차를 타고 온 펲시맨과 쑛다리 똠방각하 社會科學院語學研究所 울란바토르 𠜎𠜱𠝹𠱓𠱸𠲖𠳏',
|
||||
],
|
||||
// Japanese Emoticons
|
||||
[
|
||||
'ヽ༼ຈل͜ຈ༽ノ ヽ༼ຈل͜ຈ༽ノ (。◕ ∀ ◕。) `ィ(´∀`∩ __ロ(,_,*) ・( ̄∀ ̄)・:*: ゚・✿ヾ╲(。◕‿◕。)╱✿・゚ ,。・:*:・゜’( ☻ ω ☻ )。・:*:・゜’ (╯°□°)╯︵ ┻━┻) (ノಥ益ಥ)ノ ┻━┻ ( ͡° ͜ʖ ͡°)',
|
||||
],
|
||||
// Emoji
|
||||
[
|
||||
'😍 👩🏽 👾 🙇 💁 🙅 🙆 🙋 🙎 🙍 🐵 🙈 🙉 🙊 ❤️ 💔 💌 💕 💞 💓 💗 💖 💘 💝 💟 💜 💛 💚 💙 ✋🏿 💪🏿 👐🏿 🙌🏿 👏🏿 🙏🏿 🚾 🆒 🆓 🆕 🆖 🆗 🆙 🏧 0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟',
|
||||
],
|
||||
// Regional Indicator Symbols
|
||||
['🇺🇸🇷🇺🇸 🇦🇫🇦🇲🇸 🇺🇸🇷🇺🇸🇦🇫🇦🇲 🇺🇸🇷🇺🇸🇦'],
|
||||
// Unicode Numbers
|
||||
['123 ١٢٣'],
|
||||
// Right-To-Left Strings
|
||||
[
|
||||
'ثم نفس سقطت وبالتحديد،, جزيرتي باستخدام أن دنو. إذ هنا؟ الستار وتنصيب كان. أهّل ايطاليا، بريطانيا-فرنسا قد أخذ. سليمان، إتفاقية بين ما, يذكر الحدود أي بعد, معاملة بولندا، الإطلاق عل إيو. בְּרֵאשִׁית, בָּרָא אֱלֹהִים, אֵת הַשָּׁמַיִם, וְאֵת הָאָרֶץ הָיְתָהtestالصفحات التّحول ﷽ ﷺ مُنَاقَشَةُ سُبُلِ اِسْتِخْدَامِ اللُّغَةِ فِي النُّظُمِ الْقَائِمَةِ وَفِيم يَخُصَّ التَّطْبِيقَاتُ الْحاسُوبِيَّةُ، ',
|
||||
],
|
||||
// Trick Unicode
|
||||
['test test
test
testtest test'],
|
||||
// Strings which contain "corrupted" text
|
||||
['Ṱ̺̺̕o͞ ̷i̲̬͇̪͙n̝̗͕v̟̜̘̦͟o̶̙̰̠kè͚̮̺̪̹̱̤ ̖t̝͕̳̣̻̪͞h̼͓̲̦̳̘̲e͇̣̰̦̬͎ ̢̼̻̱̘h͚͎͙̜̣̲ͅi̦̲̣̰̤v̻͍e̺̭̳̪̰-m̢iͅn̖̺̞̲̯̰d̵̼̟͙̩̼̘̳ ̞̥̱̳̭r̛̗̘e͙p͠r̼̞̻̭̗e̺̠̣͟s̘͇̳͍̝͉e͉̥̯̞̲͚̬͜ǹ̬͎͎̟̖͇̤t͍̬̤͓̼̭͘ͅi̪̱n͠g̴͉ ͏͉ͅc̬̟h͡a̫̻̯͘o̫̟̖͍̙̝͉s̗̦̲.̨̹͈̣ ̡͓̞ͅI̗̘̦͝n͇͇͙v̮̫ok̲̫̙͈i̖͙̭̹̠̞n̡̻̮̣̺g̲͈͙̭͙̬͎ ̰t͔̦h̞̲e̢̤ ͍̬̲͖f̴̘͕̣è͖ẹ̥̩l͖͔͚i͓͚̦͠n͖͍̗͓̳̮g͍ ̨o͚̪͡f̘̣̬ ̖̘͖̟͙̮c҉͔̫͖͓͇͖ͅh̵̤̣͚͔á̗̼͕ͅo̼̣̥s̱͈̺̖̦̻͢.̛̖̞̠̫̰ ̗̺͖̹̯͓'],
|
||||
['Ṯ̤͍̥͇͈h̲́e͏͓̼̗̙̼̣͔ ͇̜̱̠͓͍ͅN͕͠e̗̱z̘̝̜̺͙p̤̺̹͍̯͚e̠̻̠͜r̨̤͍̺̖͔̖̖d̠̟̭̬̝͟i̦͖̩͓͔̤a̠̗̬͉̙n͚͜ ̻̞̰͚ͅh̵͉i̳̞v̢͇ḙ͎͟-҉̭̩̼͔m̤̭̫i͕͇̝̦n̗͙ḍ̟ ̯̲͕͞ǫ̟̯̰̲͙̻̝f ̪̰̰̗̖̭̘͘c̦͍̲̞͍̩̙ḥ͚a̮͎̟̙͜ơ̩̹͎s̤.̝̝ ҉Z̡̖̜͖̰̣͉̜a͖̰͙̬͡l̲̫̳͍̩g̡̟̼̱͚̞̬ͅo̗͜.̟ ̦H̬̤̗̤͝e͜ ̜̥̝̻͍̟́w̕h̖̯͓o̝͙̖͎̱̮ ҉̺̙̞̟͈W̷̼̭a̺̪͍į͈͕̭͙̯̜t̶̼̮s̘͙͖̕ ̠̫̠B̻͍͙͉̳ͅe̵h̵̬͇̫͙i̹͓̳̳̮͎̫̕n͟d̴̪̜̖ ̰͉̩͇͙̲͞ͅT͖̼͓̪͢h͏͓̮̻e̬̝̟ͅ ̤̹̝W͙̞̝͔͇͝ͅa͏͓͔̹̼̣l̴͔̰̤̟͔ḽ̫.͕'],
|
||||
// Unicode Upsidedown
|
||||
[
|
||||
'˙ɐnbᴉlɐ ɐuƃɐɯ ǝɹolop ʇǝ ǝɹoqɐl ʇn ʇunpᴉpᴉɔuᴉ ɹodɯǝʇ poɯsnᴉǝ op pǝs \'ʇᴉlǝ ƃuᴉɔsᴉdᴉpɐ ɹnʇǝʇɔǝsuoɔ \'ʇǝɯɐ ʇᴉs ɹolop ɯnsdᴉ ɯǝɹo˥ 00˙Ɩ$-',
|
||||
],
|
||||
// Unicode font
|
||||
[
|
||||
'The quick brown fox jumps over the lazy dog 𝐓𝐡𝐞 𝐪𝐮𝐢𝐜𝐤 𝐛𝐫𝐨𝐰𝐧 𝐟𝐨𝐱 𝐣𝐮𝐦𝐩𝐬 𝐨𝐯𝐞𝐫 𝐭𝐡𝐞 𝐥𝐚𝐳𝐲 𝐝𝐨𝐠 𝕿𝖍𝖊 𝖖𝖚𝖎𝖈𝖐 𝖇𝖗𝖔𝖜𝖓 𝖋𝖔𝖝 𝖏𝖚𝖒𝖕𝖘 𝖔𝖛𝖊𝖗 𝖙𝖍𝖊 𝖑𝖆𝖟𝖞 𝖉𝖔𝖌 𝑻𝒉𝒆 𝒒𝒖𝒊𝒄𝒌 𝒃𝒓𝒐𝒘𝒏 𝒇𝒐𝒙 𝒋𝒖𝒎𝒑𝒔 𝒐𝒗𝒆𝒓 𝒕𝒉𝒆 𝒍𝒂𝒛𝒚 𝒅𝒐𝒈 𝓣𝓱𝓮 𝓺𝓾𝓲𝓬𝓴 𝓫𝓻𝓸𝔀𝓷 𝓯𝓸𝔁 𝓳𝓾𝓶𝓹𝓼 𝓸𝓿𝓮𝓻 𝓽𝓱𝓮 𝓵𝓪𝔃𝔂 𝓭𝓸𝓰 ',
|
||||
],
|
||||
[
|
||||
'𝕋𝕙𝕖 𝕢𝕦𝕚𝕔𝕜 𝕓𝕣𝕠𝕨𝕟 𝕗𝕠𝕩 𝕛𝕦𝕞𝕡𝕤 𝕠𝕧𝕖𝕣 𝕥𝕙𝕖 𝕝𝕒𝕫𝕪 𝕕𝕠𝕘 𝚃𝚑𝚎 𝚚𝚞𝚒𝚌𝚔 𝚋𝚛𝚘𝚠𝚗 𝚏𝚘𝚡 𝚓𝚞𝚖𝚙𝚜 𝚘𝚟𝚎𝚛 𝚝𝚑𝚎 𝚕𝚊𝚣𝚢 𝚍𝚘𝚐 ⒯⒣⒠ ⒬⒰⒤⒞⒦ ⒝⒭⒪⒲⒩ ⒡⒪⒳ ⒥⒰⒨⒫⒮ ⒪⒱⒠⒭ ⒯⒣⒠ ⒧⒜⒵⒴ ⒟⒪⒢',
|
||||
],
|
||||
// Unwanted Interpolation
|
||||
['$HOME $ENV{\'HOME\'} %d %s {0} %*.*s'],
|
||||
// PHP code
|
||||
['echo \'hello world\'; exit(); for($i=32;$i<120;++$i){echo \chr($i);}'],
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TestUtil.php
|
||||
*
|
||||
* @since 2020-12-19
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-color software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Web Color class test
|
||||
*
|
||||
* @since 2020-12-19
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* @SuppressWarnings("PHPMD.NumberOfChildren")
|
||||
*/
|
||||
class TestUtil extends TestCase
|
||||
{
|
||||
public function bcAssertEqualsWithDelta(
|
||||
mixed $expected,
|
||||
mixed $actual,
|
||||
float $delta = 0.01,
|
||||
string $message = '',
|
||||
): void {
|
||||
parent::assertEqualsWithDelta($expected, $actual, $delta, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<\Throwable> $exception
|
||||
*/
|
||||
public function bcExpectException(string $exception): void
|
||||
{
|
||||
if (!\is_a($exception, \Throwable::class, true)) {
|
||||
self::fail('Expected a throwable class name.');
|
||||
}
|
||||
|
||||
parent::expectException($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
protected function getResponseHeaders(): array
|
||||
{
|
||||
if (\function_exists('xdebug_get_headers')) {
|
||||
/** @var list<string> $rawHeaders */
|
||||
$rawHeaders = xdebug_get_headers();
|
||||
$headers = [];
|
||||
foreach ($rawHeaders as $header) {
|
||||
$headers[] = $header;
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
return \headers_list();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TypeCoverageTest.php
|
||||
*
|
||||
* @since 2026-05-21
|
||||
* @category Library
|
||||
* @package Barcode
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-barcode
|
||||
*
|
||||
* This file is part of tc-lib-barcode software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Test\Fixture\InternalBarcodeType;
|
||||
|
||||
class TypeCoverageTest extends TestUtil
|
||||
{
|
||||
/**
|
||||
* @throws \Com\Tecnick\Barcode\Exception
|
||||
* @throws \Com\Tecnick\Color\Exception
|
||||
*/
|
||||
public function testBarsArrayFiltersInvalidBarsInBothPasses(): void
|
||||
{
|
||||
$type = new InternalBarcodeType();
|
||||
$type->setRowsColsForTest(3, 3);
|
||||
$type->setRatiosForTest(1.0, 1.0);
|
||||
$type->setBarsForTest([
|
||||
[0, 0, 0, 1],
|
||||
[0, 0, 1, 0],
|
||||
[1, 1, 1, 1],
|
||||
]);
|
||||
$type->setRotatedBarsOverrideForTest([
|
||||
[0, 0, 0, 1],
|
||||
[0, 0, 1, 0],
|
||||
[2, 2, 1, 1],
|
||||
]);
|
||||
|
||||
$this->assertSame(
|
||||
[
|
||||
[2.0, 7.0, 2.0, 7.0],
|
||||
[3.0, 8.0, 3.0, 8.0],
|
||||
],
|
||||
$type->getBarsArrayXYXY(),
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
[
|
||||
[2.0, 7.0, 1.0, 1.0],
|
||||
[3.0, 8.0, 1.0, 1.0],
|
||||
],
|
||||
$type->getBarsArrayXYWH(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user