Skip to content

Commit

Permalink
Added failing test of ITF14 checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
vitkutny committed Jul 17, 2024
1 parent 17f981c commit 0cc7fbd
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/ChecksumBarcodeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use PHPUnit\Framework\TestCase;
use Picqer\Barcode\Types\TypeEan13;
use Picqer\Barcode\Types\TypeInterface;
use Picqer\Barcode\Types\TypeITF14;

class ChecksumBarcodeTest extends TestCase
{
public static $supportedBarcodes = [
['type' => TypeEan13::class, 'barcodes' => [
'081231723897' => '0812317238973',
'004900000463' => '0049000004632',
]],
['type' => TypeITF14::class, 'barcodes' => [
'0001234560001' => '00012345600012',
'0540014128876' => '05400141288766',
]],
];

public function testAllSupportedBarcodeTypes()
{
foreach ($this::$supportedBarcodes as $barcodeTestSet) {
$barcodeType = $this->getBarcodeType($barcodeTestSet['type']);

foreach ($barcodeTestSet['barcodes'] as $testBarcode => $expectedBarcode) {
$this->assertEquals($expectedBarcode, $barcodeType->getBarcodeData($testBarcode)->getBarcode());
}
}
}


private function getBarcodeType(string $typeClass): TypeInterface
{
return new $typeClass;
}
}

0 comments on commit 0cc7fbd

Please sign in to comment.