File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 99
1010use Picqer \Barcode \Barcode ;
1111use Picqer \Barcode \BarcodeBar ;
12+ use Picqer \Barcode \Exceptions \InvalidLengthException ;
1213
1314class TypePharmacodeTwoCode implements TypeInterface
1415{
1516 public function getBarcodeData (string $ code ): Barcode
1617 {
1718 $ code = intval ($ code );
1819
20+ if ($ code < 1 ) {
21+ throw new InvalidLengthException ('Pharmacode 2 needs a number of 1 or larger ' );
22+ }
23+
1924 $ seq = '' ;
2025
2126 do {
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use PHPUnit \Framework \TestCase ;
4+
5+ class PharmacodeTest extends TestCase
6+ {
7+ public function test_validation_triggerd_when_generating_zero_code ()
8+ {
9+ $ pharmacode = new Picqer \Barcode \Types \TypePharmacodeTwoCode ();
10+
11+ $ this ->expectException (Picqer \Barcode \Exceptions \InvalidLengthException::class);
12+
13+ $ pharmacode ->getBarcodeData ('0 ' );
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments