Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* RO Localized Validation class test case | ||
* | ||
* PHP 5 | ||
* | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org | ||
* @package Localized.Test.Case.Validation | ||
* @since Localized Plugin v 0.1 | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
App::uses('RoValidation', 'Localized.Validation'); | ||
|
||
/** | ||
* RoValidationTest | ||
* | ||
* @package Localized.Test.Case.Validation | ||
*/ | ||
class RoValidationTest extends CakeTestCase { | ||
|
||
/** | ||
* test the postal method of RoValidation | ||
* | ||
* @return void | ||
*/ | ||
public function testPostal() { | ||
$this->assertTrue(RoValidation::postal('517006')); | ||
$this->assertFalse(RoValidation::postal('23708')); | ||
$this->assertFalse(RoValidation::postal('23 708')); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* RO Localized Validation class. Handles localized validation for Romania | ||
* | ||
* PHP 5 | ||
* | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org | ||
* @package Localized.Validation | ||
* @since Localized Plugin v 0.1 | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
|
||
/** | ||
* RoValidation | ||
* | ||
* @package Localized.Validation | ||
*/ | ||
class RoValidation { | ||
|
||
/** | ||
* Checks postal codes for Romania | ||
* | ||
* @param string $check The value to check. | ||
* @return boolean | ||
*/ | ||
public static function postal($check) { | ||
$pattern = '/^[0-9]{6}$/'; | ||
return (bool)preg_match($pattern, $check); | ||
} | ||
|
||
} |