Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.

Commit dbabcd6

Browse files
committed
Merge 67c9190 into b1e3326
2 parents b1e3326 + 67c9190 commit dbabcd6

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

library/Zend/Validator/Barcode.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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

tests/ZendTest/Validator/BarcodeTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)