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 9
9
10
10
use Picqer \Barcode \Barcode ;
11
11
use Picqer \Barcode \BarcodeBar ;
12
+ use Picqer \Barcode \Exceptions \InvalidLengthException ;
12
13
13
14
class TypePharmacodeTwoCode implements TypeInterface
14
15
{
15
16
public function getBarcodeData (string $ code ): Barcode
16
17
{
17
18
$ code = intval ($ code );
18
19
20
+ if ($ code < 1 ) {
21
+ throw new InvalidLengthException ('Pharmacode 2 needs a number of 1 or larger ' );
22
+ }
23
+
19
24
$ seq = '' ;
20
25
21
26
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