[ZF-10089] Zend_Log
[zend/radio.git] / tests / Zend / Validate / CcnumTest.php
blob9e577fc001eed523be6fd2085fb93f9db6920c33
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
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
20 * @version $Id$
24 /**
25 * Test helper
27 require_once dirname(__FILE__) . '/../../TestHelper.php';
29 /**
30 * @see Zend_Validate_Ccnum
32 require_once 'Zend/Validate/Ccnum.php';
35 /**
36 * @category Zend
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
45 /**
46 * Zend_Validate_Ccnum object
48 * @var Zend_Validate_Ccnum
50 protected $_validator;
52 /**
53 * Creates a new Zend_Validate_Ccnum object for each test method
55 * @return void
57 public function setUp()
59 set_error_handler(array($this, 'errorHandlerIgnore'));
60 $this->_validator = new Zend_Validate_Ccnum();
63 /**
64 * Ensures that the validator follows expected behavior
66 * @return void
68 public function testBasic()
70 $valuesExpected = array(
71 '4929000000006' => true,
72 '5404000000000001' => true,
73 '374200000000004' => true,
74 '4444555566667777' => false,
75 'ABCDEF' => false
77 foreach ($valuesExpected as $input => $result) {
78 $this->assertEquals($result, $this->_validator->isValid($input));
80 restore_error_handler();
83 /**
84 * Ensures that getMessages() returns expected default value
86 * @return void
88 public function testGetMessages()
90 $this->assertEquals(array(), $this->_validator->getMessages());
91 restore_error_handler();
94 /**
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
102 * @return void
104 public function errorHandlerIgnore($errno, $errstr, $errfile, $errline, array $errcontext)
106 $this->_errorOccured = true;