From 2c30c3f3295e8cd426c2a826f0f97838dea882dd Mon Sep 17 00:00:00 2001 From: Sohel Rana Date: Thu, 27 Apr 2017 07:38:08 +0600 Subject: [PATCH] Write Some Assertions for Validation Library (#10582) Add additional test coverage for validation methods. --- tests/TestCase/Validation/ValidationTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/TestCase/Validation/ValidationTest.php b/tests/TestCase/Validation/ValidationTest.php index 2d6898da211..4ca4886a878 100644 --- a/tests/TestCase/Validation/ValidationTest.php +++ b/tests/TestCase/Validation/ValidationTest.php @@ -168,6 +168,7 @@ public function testLengthBetween() $this->assertFalse(Validation::lengthBetween('abcdefg', 1, 6)); $this->assertFalse(Validation::lengthBetween('ÆΔΩЖÇ', 1, 3)); + $this->assertFalse(Validation::lengthBetween(1, 1, 3)); } /** @@ -619,6 +620,8 @@ public function testCc() $this->assertTrue(Validation::cc('869958670174621', ['voyager'])); $this->assertTrue(Validation::cc('869921250068209', ['voyager'])); $this->assertTrue(Validation::cc('869972521242198', ['voyager'])); + //Credit card number should not pass as array + $this->assertFalse(Validation::cc(['869972521242198'], ['voyager'])); } /** @@ -1960,6 +1963,7 @@ public function testEmail() $this->assertFalse(Validation::email('abc@yahoo!.com')); $this->assertFalse(Validation::email('abc@example_underscored.com')); $this->assertFalse(Validation::email('raw@test.ra.ru....com')); + $this->assertFalse(Validation::email(1)); } /** @@ -2813,6 +2817,9 @@ public function testContainNonAlphaNumeric() $this->assertFalse(Validation::containsNonAlphaNumeric('abcdef##', 3)); $this->assertFalse(Validation::containsNonAlphaNumeric('abc##def', 3)); $this->assertFalse(Validation::containsNonAlphaNumeric('ab#cd#ef', 3)); + + //Non alpha numeric should not pass as array + $this->assertFalse(Validation::containsNonAlphaNumeric(['abc#'])); } /**