diff --git a/tests/ChecksumBarcodeTest.php b/tests/ChecksumBarcodeTest.php index 2bbf0db..4298211 100644 --- a/tests/ChecksumBarcodeTest.php +++ b/tests/ChecksumBarcodeTest.php @@ -1,13 +1,14 @@ TypeEan13::class, 'barcodes' => [ '081231723897' => '0812317238973', '004900000463' => '0049000004632', @@ -17,14 +18,30 @@ class ChecksumBarcodeTest extends TestCase '0540014128876' => '05400141288766', ]], ]; + private const INVALID_BARCODES = [ + ['type' => TypeEan13::class, 'barcodes' => ['0812317238972', '0049000004633']], + ['type' => TypeITF14::class, 'barcodes' => ['00012345600016', '05400141288762']], + ]; + + public function testAllValidBarcodeTypes() + { + foreach (self::VALID_BARCODES as $barcodeTestSet) { + $barcodeType = $this->getBarcodeType($barcodeTestSet['type']); + + foreach ($barcodeTestSet['barcodes'] as $testBarcode => $validBarcode) { + $this->assertEquals($validBarcode, $barcodeType->getBarcodeData($testBarcode)->getBarcode()); + } + } + } - public function testAllSupportedBarcodeTypes() + public function testAllInvalidBarcodeTypes() { - foreach ($this::$supportedBarcodes as $barcodeTestSet) { + foreach (self::INVALID_BARCODES as $barcodeTestSet) { $barcodeType = $this->getBarcodeType($barcodeTestSet['type']); - foreach ($barcodeTestSet['barcodes'] as $testBarcode => $expectedBarcode) { - $this->assertEquals($expectedBarcode, $barcodeType->getBarcodeData($testBarcode)->getBarcode()); + foreach ($barcodeTestSet['barcodes'] as $invalidBarcode) { + $this->expectException(InvalidCheckDigitException::class); + $barcodeType->getBarcodeData($invalidBarcode)->getBarcode(); } } }