HexTest.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_Validate
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Test helper
  24. */
  25. require_once dirname(__FILE__) . '/../../TestHelper.php';
  26. /**
  27. * @see Zend_Validate_Hex
  28. */
  29. require_once 'Zend/Validate/Hex.php';
  30. /**
  31. * @category Zend
  32. * @package Zend_Validate
  33. * @subpackage UnitTests
  34. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. */
  37. class Zend_Validate_HexTest extends PHPUnit_Framework_TestCase
  38. {
  39. /**
  40. * Zend_Validate_Hex object
  41. *
  42. * @var Zend_Validate_Hex
  43. */
  44. protected $_validator;
  45. /**
  46. * Creates a new Zend_Validate_Hex object for each test method
  47. *
  48. * @return void
  49. */
  50. public function setUp()
  51. {
  52. $this->_validator = new Zend_Validate_Hex();
  53. }
  54. /**
  55. * Ensures that the validator follows expected behavior
  56. *
  57. * @return void
  58. */
  59. public function testBasic()
  60. {
  61. $valuesExpected = array(
  62. array(1, true),
  63. array(0x1, true),
  64. array(0x123, true),
  65. array('1', true),
  66. array('abc123', true),
  67. array('ABC123', true),
  68. array('1234567890abcdef', true),
  69. array('g', false),
  70. array('1.2', false)
  71. );
  72. foreach ($valuesExpected as $element) {
  73. $this->assertEquals($element[1], $this->_validator->isValid($element[0]), $element[0]);
  74. }
  75. }
  76. /**
  77. * Ensures that getMessages() returns expected default value
  78. *
  79. * @return void
  80. */
  81. public function testGetMessages()
  82. {
  83. $this->assertEquals(array(), $this->_validator->getMessages());
  84. }
  85. }