PageRenderTime 27ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/DevApp/library/ServerLibraries/ZendFramework/trunk/tests/Zend/Barcode/Object/Ean2Test.php

http://firephp.googlecode.com/
PHP | 155 lines | 107 code | 19 blank | 29 comment | 0 complexity | 579eee8d1c4888314e2f9f17545ff318 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, MIT, Apache-2.0
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Barcode
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: Ean2Test.php 23772 2011-02-28 21:35:29Z ralph $
  21. */
  22. require_once dirname(__FILE__) . '/TestCommon.php';
  23. require_once 'Zend/Barcode/Object/Ean2.php';
  24. /**
  25. * @category Zend
  26. * @package Zend_Barcode
  27. * @subpackage UnitTests
  28. * @group Zend_Barcode
  29. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class Zend_Barcode_Object_Ean2Test extends Zend_Barcode_Object_TestCommon
  33. {
  34. protected function _getBarcodeObject($options = null)
  35. {
  36. return new Zend_Barcode_Object_Ean2($options);
  37. }
  38. public function testType()
  39. {
  40. $this->assertSame('ean2', $this->_object->getType());
  41. }
  42. public function testChecksum()
  43. {
  44. $this->assertSame(9, $this->_object->getChecksum('43'));
  45. }
  46. public function testSetText()
  47. {
  48. $this->_object->setText('43');
  49. $this->assertSame('43', $this->_object->getRawText());
  50. $this->assertSame('43', $this->_object->getText());
  51. $this->assertSame('43', $this->_object->getTextToDisplay());
  52. }
  53. public function testSetTextWithout2Characters()
  54. {
  55. $this->_object->setText('5');
  56. $this->assertSame('5', $this->_object->getRawText());
  57. $this->assertSame('05', $this->_object->getText());
  58. $this->assertSame('05', $this->_object->getTextToDisplay());
  59. }
  60. public function testSetTextWithoutChecksumHasNoEffect()
  61. {
  62. $this->_object->setText('43');
  63. $this->_object->setWithChecksum(false);
  64. $this->assertSame('43', $this->_object->getRawText());
  65. $this->assertSame('43', $this->_object->getText());
  66. $this->assertSame('43', $this->_object->getTextToDisplay());
  67. }
  68. public function testSetTextWithSpaces()
  69. {
  70. $this->_object->setText(' 43 ');
  71. $this->assertSame('43', $this->_object->getRawText());
  72. $this->assertSame('43', $this->_object->getText());
  73. $this->assertSame('43', $this->_object->getTextToDisplay());
  74. }
  75. public function testSetTextWithChecksumNotDisplayed()
  76. {
  77. $this->_object->setText('43');
  78. $this->_object->setWithChecksumInText(false);
  79. $this->assertSame('43', $this->_object->getRawText());
  80. $this->assertSame('43', $this->_object->getText());
  81. $this->assertSame('43', $this->_object->getTextToDisplay());
  82. }
  83. public function testCheckGoodParams()
  84. {
  85. $this->_object->setText('43');
  86. $this->assertTrue($this->_object->checkParams());
  87. }
  88. public function testGetKnownWidthWithoutOrientation()
  89. {
  90. $this->_object->setText('43');
  91. $this->assertEquals(41, $this->_object->getWidth());
  92. $this->_object->setWithQuietZones(false);
  93. $this->assertEquals(21, $this->_object->getWidth(true));
  94. }
  95. public function testCompleteGeneration()
  96. {
  97. $this->_object->setText('43');
  98. $this->_object->draw();
  99. $instructions = $this->loadInstructionsFile('Ean2_43_instructions');
  100. $this->assertEquals($instructions, $this->_object->getInstructions());
  101. }
  102. public function testCompleteGenerationWithBorder()
  103. {
  104. $this->_object->setText('43');
  105. $this->_object->setWithBorder(true);
  106. $this->_object->draw();
  107. $instructions = $this->loadInstructionsFile(
  108. 'Ean2_43_border_instructions');
  109. $this->assertEquals($instructions, $this->_object->getInstructions());
  110. }
  111. public function testCompleteGenerationWithOrientation()
  112. {
  113. $this->_object->setText('43');
  114. $this->_object->setOrientation(60);
  115. $this->_object->draw();
  116. $instructions = $this->loadInstructionsFile(
  117. 'Ean2_43_oriented_instructions');
  118. $this->assertEquals($instructions, $this->_object->getInstructions());
  119. }
  120. public function testCompleteGenerationWithBorderWithOrientation()
  121. {
  122. $this->_object->setText('43');
  123. $this->_object->setOrientation(60);
  124. $this->_object->setWithBorder(true);
  125. $this->_object->draw();
  126. $instructions = $this->loadInstructionsFile(
  127. 'Ean2_43_border_oriented_instructions');
  128. $this->assertEquals($instructions, $this->_object->getInstructions());
  129. }
  130. public function testGetDefaultHeight()
  131. {
  132. // Checksum activated => text needed
  133. $this->_object->setText('43');
  134. $this->assertEquals(62, $this->_object->getHeight(true));
  135. }
  136. }