Adding passthrough to localized Validation class for Validation::ssn. Tests added. Fixes

This commit is contained in:
mark_story 2009-12-02 20:57:14 -05:00
parent 16f6d4d408
commit 0806545f35
2 changed files with 14 additions and 3 deletions
cake

View file

@ -782,11 +782,13 @@ class Validation extends Object {
$_this->regex = '/\\A\\b[0-9]{9}\\b\\z/i'; $_this->regex = '/\\A\\b[0-9]{9}\\b\\z/i';
break; break;
case 'us': case 'us':
default:
$_this->regex = '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i'; $_this->regex = '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i';
break; break;
} }
} }
if (empty($_this->regex)) {
return $_this->_pass('ssn', $check, $country);
}
return $_this->_check(); return $_this->_check();
} }

View file

@ -58,10 +58,18 @@ class TestNlValidation {
function postal($check) { function postal($check) {
return true; return true;
} }
/**
* ssn function for testing ssn pass through
*
* @return void
*/
function ssn($check) {
return true;
}
} }
/** /**
* TestNlValidation class * TestDeValidation class
* *
* Used to test pass through of Validation * Used to test pass through of Validation
* *
@ -2041,9 +2049,10 @@ class ValidationTest extends CakeTestCase {
* *
* @return void * @return void
*/ */
function testPhoneAndPostalPass() { function testPhonePostalSsnPass() {
$this->assertTrue(Validation::postal('text', null, 'testNl')); $this->assertTrue(Validation::postal('text', null, 'testNl'));
$this->assertTrue(Validation::phone('text', null, 'testDe')); $this->assertTrue(Validation::phone('text', null, 'testDe'));
$this->assertTrue(Validation::ssn('text', null, 'testNl'));
} }
/** /**