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.
16 * @package Zend_Validate
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
27 require_once dirname(__FILE__
) . '/../../TestHelper.php';
30 * @see Zend_Validate_Ccnum
32 require_once 'Zend/Validate/Ccnum.php';
37 * @package Zend_Validate
38 * @subpackage UnitTests
39 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
40 * @license http://framework.zend.com/license/new-bsd New BSD License
41 * @group Zend_Validate
43 class Zend_Validate_CcnumTest
extends PHPUnit_Framework_TestCase
46 * Zend_Validate_Ccnum object
48 * @var Zend_Validate_Ccnum
50 protected $_validator;
53 * Creates a new Zend_Validate_Ccnum object for each test method
57 public function setUp()
59 set_error_handler(array($this, 'errorHandlerIgnore'));
60 $this->_validator
= new Zend_Validate_Ccnum();
64 * Ensures that the validator follows expected behavior
68 public function testBasic()
70 $valuesExpected = array(
71 '4929000000006' => true,
72 '5404000000000001' => true,
73 '374200000000004' => true,
74 '4444555566667777' => false,
77 foreach ($valuesExpected as $input => $result) {
78 $this->assertEquals($result, $this->_validator
->isValid($input));
80 restore_error_handler();
84 * Ensures that getMessages() returns expected default value
88 public function testGetMessages()
90 $this->assertEquals(array(), $this->_validator
->getMessages());
91 restore_error_handler();
95 * Ignores a raised PHP error when in effect, but throws a flag to indicate an error occurred
97 * @param integer $errno
98 * @param string $errstr
99 * @param string $errfile
100 * @param integer $errline
101 * @param array $errcontext
104 public function errorHandlerIgnore($errno, $errstr, $errfile, $errline, array $errcontext)
106 $this->_errorOccured
= true;