From cbc432b5ad0b570335bc6e5f2cf3260f295c4b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Kutn=C3=BD?= Date: Wed, 17 Jul 2024 20:27:49 +0200 Subject: [PATCH] Added failing test of ITF14 checksum --- tests/ChecksumBarcodeTest.php | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/ChecksumBarcodeTest.php diff --git a/tests/ChecksumBarcodeTest.php b/tests/ChecksumBarcodeTest.php new file mode 100644 index 0000000..9a83b9a --- /dev/null +++ b/tests/ChecksumBarcodeTest.php @@ -0,0 +1,37 @@ + 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($barcodeType->getBarcodeData($testBarcode)->getBarcode(), $expectedBarcode); + } + } + } + + + private function getBarcodeType(string $typeClass): TypeInterface + { + return new $typeClass; + } +}