This repository was archived by the owner on Jan 8, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -91,15 +91,17 @@ public function setAdapter($adapter, $options = null)
9191 throw new Exception \InvalidArgumentException ('Barcode adapter matching " ' . $ adapter . '" not found ' );
9292 }
9393
94- $ this -> options [ ' adapter ' ] = new $ adapter ($ options );
94+ $ adapter = new $ adapter ($ options );
9595 }
96-
97- if (!$ this -> options [ ' adapter ' ] instanceof Barcode \AdapterInterface) {
96+
97+ if (!$ adapter instanceof Barcode \AdapterInterface) {
9898 throw new Exception \InvalidArgumentException (
99- "Adapter $ adapter does not implement Zend \\Validate \\Barcode \\AdapterInterface "
99+ sprintf ( "Adapter %s does not implement Zend \\Validate \\Barcode \\AdapterInterface " , get_class ( $ adapter ))
100100 );
101101 }
102102
103+ $ this ->options ['adapter ' ] = $ adapter ;
104+
103105 return $ this ;
104106 }
105107
Original file line number Diff line number Diff line change @@ -32,6 +32,15 @@ public function testSetAdapter()
3232 $ barcode ->setAdapter ('ean13 ' );
3333 $ this ->assertTrue ($ barcode ->isValid ('0075678164125 ' ));
3434 }
35+
36+ public function testSetCustomAdapter ()
37+ {
38+ $ barcode = new Barcode ([
39+ 'adapter ' => $ this ->getMock ('Zend\Validator\Barcode\AdapterInterface ' )
40+ ]);
41+
42+ $ this ->assertInstanceOf ('Zend\Validator\Barcode\AdapterInterface ' , $ barcode ->getAdapter ());
43+ }
3544
3645 /**
3746 * @ZF-4352
You can’t perform that action at this time.
0 commit comments