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

Commit

Permalink
Merge branch 'mikaelkael/barcode2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jul 26, 2010
7 parents 8d7f494 + 067f65f + f87e034 + bfb8488 + ab8ed6b + 0b17912 + ef4e0ee commit 553a883
Show file tree
Hide file tree
Showing 22 changed files with 68 additions and 208 deletions.
2 changes: 1 addition & 1 deletion src/Barcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Barcode
* @var array
*/
protected static $_loaders = array();

/**
* Set plugin loader to use for validator or filter chain
*
Expand Down
2 changes: 1 addition & 1 deletion src/Renderer/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected function _drawPolygon($points, $color, $filled = true)
$page->setFillColor($color);
$page->setLineWidth($this->_moduleSize);

$fillType = ($filled)
$fillType = ($filled)
? Page::SHAPE_DRAW_FILL_AND_STROKE
: Page::SHAPE_DRAW_STROKE;

Expand Down
2 changes: 0 additions & 2 deletions src/Renderer/Svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
* @namespace
*/
namespace Zend\Barcode\Renderer;
use Zend\Pdf\Color;
use Zend;

/**
* Class for rendering the barcode as svg
Expand Down
40 changes: 10 additions & 30 deletions test/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,16 @@ public function testFactoryWithAutomaticExceptionRendering()
$this->assertTrue($renderer->getBarcode() instanceof Object\Error);
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testFactoryWithoutAutomaticObjectExceptionRendering()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$options = array('barHeight' => - 1);
$renderer = Barcode\Barcode::factory('code39', 'image', $options, array(), false);
}

/**
* @expectedException \Zend\Barcode\Renderer\Exception
*/
public function testFactoryWithoutAutomaticRendererExceptionRendering()
{
$this->setExpectedException('\Zend\Barcode\Renderer\Exception');
$this->_checkGDRequirement();
$options = array('imageType' => 'my');
$renderer = Barcode\Barcode::factory('code39', 'image', array(), $options, false);
Expand Down Expand Up @@ -206,20 +202,16 @@ public function testBarcodeObjectFactoryWithBarcodeAsZendConfig()
$this->assertSame(123, $barcode->getBarHeight());
}

/**
* @expectedException \Zend\Barcode\Exception
*/
public function testBarcodeObjectFactoryWithBarcodeAsZendConfigButNoBarcodeParameter()
{
$this->setExpectedException('\Zend\Barcode\Exception');
$config = new Config(array('barcodeParams' => array('barHeight' => 123) ));
$barcode = Barcode\Barcode::makeBarcode($config);
}

/**
* @expectedException \Zend\Barcode\Exception
*/
public function testBarcodeObjectFactoryWithBarcodeAsZendConfigAndBadBarcodeParameters()
{
$this->setExpectedException('\Zend\Barcode\Exception');
$barcode = Barcode\Barcode::makeBarcode('code25', null);
}

Expand All @@ -240,21 +232,17 @@ public function testBarcodeObjectFactoryWithNamespaceExtendStandardLibray()
$this->assertTrue($barcode instanceof \ZendTest\Barcode\Object\TestAsset\Error);
}

/**
* @expectedException \Zend\Barcode\Exception
*/
public function testBarcodeObjectFactoryWithNamespaceButWithoutExtendingObjectAbstract()
{
$this->setExpectedException('\Zend\Barcode\Exception');
$loader = new PluginLoader(array('ZendTest\Barcode\Object\TestAsset' => __DIR__ . '/Object/TestAsset'));
Barcode\Barcode::setPluginLoader($loader, Barcode\Barcode::OBJECT);
$barcode = Barcode\Barcode::makeBarcode('barcodeNamespaceWithoutExtendingObjectAbstract');
}

/**
* @expectedException Zend\Loader\PluginLoaderException
*/
public function testBarcodeObjectFactoryWithUnexistantBarcode()
{
$this->setExpectedException('\Zend\Loader\PluginLoaderException');
$barcode = Barcode\Barcode::makeBarcode('zf123', array());
}

Expand Down Expand Up @@ -301,20 +289,16 @@ public function testBarcodeRendererFactoryWithBarcodeAsZendConfig()
$this->assertSame('gif', $renderer->getimageType());
}

/**
* @expectedException \Zend\Barcode\Exception
*/
public function testBarcodeRendererFactoryWithBarcodeAsZendConfigButNoBarcodeParameter()
{
$this->setExpectedException('\Zend\Barcode\Exception');
$config = new Config(array('rendererParams' => array('imageType' => 'gif') ));
$renderer = Barcode\Barcode::makeRenderer($config);
}

/**
* @expectedException \Zend\Barcode\Exception
*/
public function testBarcodeRendererFactoryWithBarcodeAsZendConfigAndBadBarcodeParameters()
{
$this->setExpectedException('\Zend\Barcode\Exception');
$renderer = Barcode\Barcode::makeRenderer('image', null);
}

Expand All @@ -327,21 +311,17 @@ public function testBarcodeRendererFactoryWithNamespace()
$this->assertTrue($renderer instanceof \Zend\Barcode\Renderer);
}

/**
* @expectedException \Zend\Barcode\Exception
*/
public function testBarcodeFactoryWithNamespaceButWithoutExtendingRendererAbstract()
{
$this->setExpectedException('\Zend\Barcode\Exception');
$loader = new PluginLoader(array('ZendTest\Barcode\Renderer\TestAsset' => __DIR__ . '/Renderer/TestAsset'));
Barcode\Barcode::setPluginLoader($loader, Barcode\Barcode::RENDERER);
$renderer = Barcode\Barcode::makeRenderer('rendererNamespaceWithoutExtendingRendererAbstract');
}

/**
* @expectedException Zend\Loader\PluginLoaderException
*/
public function testBarcodeRendererFactoryWithUnexistantRenderer()
{
$this->setExpectedException('\Zend\Loader\PluginLoaderException');
$renderer = Barcode\Barcode::makeRenderer('zend', array());
}

Expand Down
12 changes: 3 additions & 9 deletions test/Object/Code25Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,9 @@ public function testBadTextAlwaysAllowed()
$this->assertSame('a', $this->_object->getText());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testBadTextDetectedIfChecksumWished()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('a');
$this->_object->setWithChecksum(true);
$this->_object->getText();
Expand All @@ -117,22 +115,18 @@ public function testCheckGoodParams()
$this->assertTrue($this->_object->checkParams());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testCheckParamsWithLowRatio()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('0123456789');
$this->_object->setBarThinWidth(21);
$this->_object->setBarThickWidth(40);
$this->_object->checkParams();
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testCheckParamsWithHighRatio()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('0123456789');
$this->_object->setBarThinWidth(20);
$this->_object->setBarThickWidth(61);
Expand Down
12 changes: 3 additions & 9 deletions test/Object/Code25interleavedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@ public function testBadTextAlwaysAllowed()
$this->assertSame('0a', $this->_object->getText());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testBadTextDetectedIfChecksumWished()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('a');
$this->_object->setWithChecksum(true);
$this->_object->getText();
Expand All @@ -143,22 +141,18 @@ public function testCheckGoodParams()
$this->assertTrue($this->_object->checkParams());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testCheckParamsWithLowRatio()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('0123456789');
$this->_object->setBarThinWidth(21);
$this->_object->setBarThickWidth(40);
$this->_object->checkParams();
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testCheckParamsWithHighRatio()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('0123456789');
$this->_object->setBarThinWidth(20);
$this->_object->setBarThickWidth(61);
Expand Down
12 changes: 3 additions & 9 deletions test/Object/Code39Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ public function testBadTextAlwaysAllowed()
$this->assertSame('&', $this->_object->getRawText());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testBadTextDetectedIfChecksumWished()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('&');
$this->_object->setWithChecksum(true);
$this->_object->getText();
Expand All @@ -110,22 +108,18 @@ public function testCheckGoodParams()
$this->assertTrue($this->_object->checkParams());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testCheckParamsWithLowRatio()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('TEST');
$this->_object->setBarThinWidth(21);
$this->_object->setBarThickWidth(40);
$this->_object->checkParams();
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testCheckParamsWithHighRatio()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('TEST');
$this->_object->setBarThinWidth(20);
$this->_object->setBarThickWidth(61);
Expand Down
4 changes: 1 addition & 3 deletions test/Object/Ean13Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ public function testSetTextWithChecksumNotDisplayed()
$this->assertSame('0001234567895', $this->_object->getTextToDisplay());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testBadTextDetectedIfChecksumWished()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('a');
$this->_object->setWithChecksum(true);
$this->_object->getText();
Expand Down
5 changes: 1 addition & 4 deletions test/Object/Ean8Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ public function testSetTextWithChecksumNotDisplayed()
$this->assertSame('01234565', $this->_object->getTextToDisplay());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testBadTextDetectedIfChecksumWished()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('a');
$this->_object->setWithChecksum(true);
$this->_object->getText();
Expand All @@ -109,7 +107,6 @@ public function testCheckGoodParams()
$this->assertTrue($this->_object->checkParams());
}


public function testGetKnownWidthWithoutOrientation()
{
$this->_object->setText('123456');
Expand Down
4 changes: 1 addition & 3 deletions test/Object/IdentcodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ public function testSetTextWithChecksumNotDisplayed()
$this->assertSame('00.123 456.789 0', $this->_object->getTextToDisplay());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testBadTextDetectedIfChecksumWished()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('a');
$this->_object->setWithChecksum(true);
$this->_object->getText();
Expand Down
12 changes: 3 additions & 9 deletions test/Object/Itf14Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ public function testSetTextWithChecksumNotDisplayed()
$this->assertSame('00001234567895', $this->_object->getTextToDisplay());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testBadTextDetectedIfChecksumWished()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('a');
$this->_object->setWithChecksum(true);
$this->_object->getText();
Expand All @@ -109,22 +107,18 @@ public function testCheckGoodParams()
$this->assertTrue($this->_object->checkParams());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testCheckParamsWithLowRatio()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('0000123456789');
$this->_object->setBarThinWidth(21);
$this->_object->setBarThickWidth(40);
$this->_object->checkParams();
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testCheckParamsWithHighRatio()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('0000123456789');
$this->_object->setBarThinWidth(20);
$this->_object->setBarThickWidth(61);
Expand Down
4 changes: 1 addition & 3 deletions test/Object/LeitcodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ public function testSetTextWithChecksumNotDisplayed()
$this->assertSame('00001.234.567.89 0', $this->_object->getTextToDisplay());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testBadTextDetectedIfChecksumWished()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('a');
$this->_object->setWithChecksum(true);
$this->_object->getText();
Expand Down
8 changes: 2 additions & 6 deletions test/Object/PlanetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ public function testSetText()
$this->assertSame('000000123455', $this->_object->getTextToDisplay());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testSetTextWithoutGoodNumberOfCharacters()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('1234');
$this->_object->getText();
}
Expand Down Expand Up @@ -95,11 +93,9 @@ public function testSetTextWithChecksumNotDisplayed()
$this->assertSame('000000123455', $this->_object->getTextToDisplay());
}

/**
* @expectedException \Zend\Barcode\Object\Exception
*/
public function testBadTextDetectedIfChecksumWished()
{
$this->setExpectedException('\Zend\Barcode\Object\Exception');
$this->_object->setText('a');
$this->_object->setWithChecksum(true);
$this->_object->getText();
Expand Down
Loading

0 comments on commit 553a883

Please sign in to comment.