File tree 1 file changed +37
-0
lines changed 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use PHPUnit \Framework \TestCase ;
4
+ use Picqer \Barcode \Types \TypeEan13 ;
5
+ use Picqer \Barcode \Types \TypeInterface ;
6
+ use Picqer \Barcode \Types \TypeITF14 ;
7
+
8
+ class ChecksumBarcodeTest extends TestCase
9
+ {
10
+ public static $ supportedBarcodes = [
11
+ ['type ' => TypeEan13::class, 'barcodes ' => [
12
+ '081231723897 ' => '0812317238973 ' ,
13
+ '004900000463 ' => '0049000004632 ' ,
14
+ ]],
15
+ ['type ' => TypeITF14::class, 'barcodes ' => [
16
+ '0001234560001 ' => '00012345600012 ' ,
17
+ '0540014128876 ' => '05400141288766 ' ,
18
+ ]],
19
+ ];
20
+
21
+ public function testAllSupportedBarcodeTypes ()
22
+ {
23
+ foreach ($ this ::$ supportedBarcodes as $ barcodeTestSet ) {
24
+ $ barcodeType = $ this ->getBarcodeType ($ barcodeTestSet ['type ' ]);
25
+
26
+ foreach ($ barcodeTestSet ['barcodes ' ] as $ testBarcode => $ expectedBarcode ) {
27
+ $ this ->assertEquals ($ expectedBarcode , $ barcodeType ->getBarcodeData ($ testBarcode )->getBarcode ());
28
+ }
29
+ }
30
+ }
31
+
32
+
33
+ private function getBarcodeType (string $ typeClass ): TypeInterface
34
+ {
35
+ return new $ typeClass ;
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments