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

Fixes $options = null check when use Zend\Valdator\Barcode #52

Merged
merged 1 commit into from
Feb 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Barcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class Barcode extends AbstractValidator
*/
public function __construct($options = null)
{
if ($options === null) {
$options = [];
}

if (!is_array($options) && !($options instanceof Traversable)) {
$options = ['adapter' => $options];
}
Expand Down
16 changes: 16 additions & 0 deletions test/BarcodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
*/
class BarcodeTest extends \PHPUnit_Framework_TestCase
{
public function provideBarcodeConstructor()
{
return [
[null, Barcode\Ean13::class],
[[], Barcode\Ean13::class],
];
}
/**
* @dataProvider provideBarcodeConstructor
*/
public function testBarcodeConstructor($options, $expectedInstance)
{
$barcode = new Barcode($options);
$this->assertInstanceOf($expectedInstance, $barcode->getAdapter());
}

public function testNoneExisting()
{
$this->setExpectedException('Zend\Validator\Exception\InvalidArgumentException', 'not found');
Expand Down