From 2d0eaf517bcf92dba36631379d0f61fe7842f779 Mon Sep 17 00:00:00 2001 From: phpnut Date: Fri, 23 Mar 2007 18:01:36 +0000 Subject: [PATCH] Adding test for Validation::alphaNumeric() to check empty $check. Corrected Validation::alphaNumeric() to return false if $this->check; is empty git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4665 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/validation.php | 4 ++++ cake/tests/cases/libs/validation.test.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/cake/libs/validation.php b/cake/libs/validation.php index fce432afa..e42bf4d02 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -124,6 +124,10 @@ class Validation extends Object { $this->_extract($check); } + if(empty($this->check)) { + return false; + } + $this->regex = '/[^\\dA-Z]/i'; if($this->_check() === true){ return false; diff --git a/cake/tests/cases/libs/validation.test.php b/cake/tests/cases/libs/validation.test.php index 15a3ddcbc..0d98bb8b4 100644 --- a/cake/tests/cases/libs/validation.test.php +++ b/cake/tests/cases/libs/validation.test.php @@ -47,6 +47,7 @@ class ValidationTestCase extends UnitTestCase { $this->assertFalse($validation->alphaNumeric("\t")); $this->assertFalse($validation->alphaNumeric("\r")); $this->assertFalse($validation->alphaNumeric(' ')); + $this->assertFalse($validation->alphaNumeric('')); } function testAlphaNumericPassedAsArray(){ @@ -61,6 +62,7 @@ class ValidationTestCase extends UnitTestCase { $this->assertFalse($validation->alphaNumeric(array('check' => "\t"))); $this->assertFalse($validation->alphaNumeric(array('check' => "\r"))); $this->assertFalse($validation->alphaNumeric(array('check' => ' '))); + $this->assertFalse($validation->alphaNumeric(array('check' => ''))); } function testBetween(){