| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Barcode
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: SvgTest.php 20096 2010-01-06 02:05:09Z bkarwin $
- */
- require_once dirname(__FILE__) . '/TestCommon.php';
- require_once 'Zend/Barcode/Renderer/Svg.php';
- require_once 'Zend/Barcode/Object/Code39.php';
- /**
- * @category Zend
- * @package Zend_Barcode
- * @subpackage UnitTests
- * @group Zend_Barcode
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
- class Zend_Barcode_Renderer_SvgTest extends Zend_Barcode_Renderer_TestCommon
- {
- protected function _getRendererObject($options = null)
- {
- return new Zend_Barcode_Renderer_Svg($options);
- }
- public function testType()
- {
- $this->assertSame('svg', $this->_renderer->getType());
- }
- public function testGoodHeight()
- {
- $this->assertSame(0, $this->_renderer->getHeight());
- $this->_renderer->setHeight(123);
- $this->assertSame(123, $this->_renderer->getHeight());
- $this->_renderer->setHeight(0);
- $this->assertSame(0, $this->_renderer->getHeight());
- }
- /**
- * @expectedException Zend_Barcode_Renderer_Exception
- */
- public function testBadHeight()
- {
- $this->_renderer->setHeight(-1);
- }
- public function testGoodWidth()
- {
- $this->assertSame(0, $this->_renderer->getWidth());
- $this->_renderer->setWidth(123);
- $this->assertSame(123, $this->_renderer->getWidth());
- $this->_renderer->setWidth(0);
- $this->assertSame(0, $this->_renderer->getWidth());
- }
- /**
- * @expectedException Zend_Barcode_Renderer_Exception
- */
- public function testBadWidth()
- {
- $this->_renderer->setWidth(-1);
- }
- public function testGoodSvgResource()
- {
- $svgResource = new DOMDocument();
- $this->_renderer->setResource($svgResource, 10);
- }
- /**
- * @expectedException Zend_Barcode_Renderer_Exception
- */
- public function testObjectSvgResource()
- {
- $svgResource = new StdClass();
- $this->_renderer->setResource($svgResource);
- }
- public function testDrawReturnResource()
- {
- Zend_Barcode::setBarcodeFont(dirname(__FILE__) . '/../Object/_fonts/Vera.ttf');
- $barcode = new Zend_Barcode_Object_Code39(array('text' => '0123456789'));
- $this->_renderer->setBarcode($barcode);
- $resource = $this->_renderer->draw();
- $this->assertTrue($resource instanceof DOMDocument);
- Zend_Barcode::setBarcodeFont('');
- }
- public function testDrawWithExistantResourceReturnResource()
- {
- Zend_Barcode::setBarcodeFont(dirname(__FILE__) . '/../Object/_fonts/Vera.ttf');
- $barcode = new Zend_Barcode_Object_Code39(array('text' => '0123456789'));
- $this->_renderer->setBarcode($barcode);
- $svgResource = new DOMDocument();
- $rootElement = $svgResource->createElement('svg');
- $rootElement->setAttribute('xmlns', "http://www.w3.org/2000/svg");
- $rootElement->setAttribute('version', '1.1');
- $rootElement->setAttribute('width', 500);
- $rootElement->setAttribute('height', 300);
- $svgResource->appendChild($rootElement);
- $this->_renderer->setResource($svgResource);
- $resource = $this->_renderer->draw();
- $this->assertTrue($resource instanceof DOMDocument);
- $this->assertSame($resource, $svgResource);
- Zend_Barcode::setBarcodeFont('');
- }
- protected function _getRendererWithWidth500AndHeight300()
- {
- $svg = new DOMDocument();
- $rootElement = $svg->createElement('svg');
- $rootElement->setAttribute('xmlns', "http://www.w3.org/2000/svg");
- $rootElement->setAttribute('version', '1.1');
- $rootElement->setAttribute('width', 500);
- $rootElement->setAttribute('height', 300);
- $svg->appendChild($rootElement);
- return $this->_renderer->setResource($svg);
- }
- }
|