Skip to content

Commit 2c30c3f

Browse files
sohelrana820markstory
authored andcommitted
Write Some Assertions for Validation Library (#10582)
Add additional test coverage for validation methods.
1 parent f720507 commit 2c30c3f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/TestCase/Validation/ValidationTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public function testLengthBetween()
168168

169169
$this->assertFalse(Validation::lengthBetween('abcdefg', 1, 6));
170170
$this->assertFalse(Validation::lengthBetween('ÆΔΩЖÇ', 1, 3));
171+
$this->assertFalse(Validation::lengthBetween(1, 1, 3));
171172
}
172173

173174
/**
@@ -619,6 +620,8 @@ public function testCc()
619620
$this->assertTrue(Validation::cc('869958670174621', ['voyager']));
620621
$this->assertTrue(Validation::cc('869921250068209', ['voyager']));
621622
$this->assertTrue(Validation::cc('869972521242198', ['voyager']));
623+
//Credit card number should not pass as array
624+
$this->assertFalse(Validation::cc(['869972521242198'], ['voyager']));
622625
}
623626

624627
/**
@@ -1960,6 +1963,7 @@ public function testEmail()
19601963
$this->assertFalse(Validation::email('abc@yahoo!.com'));
19611964
$this->assertFalse(Validation::email('abc@example_underscored.com'));
19621965
$this->assertFalse(Validation::email('raw@test.ra.ru....com'));
1966+
$this->assertFalse(Validation::email(1));
19631967
}
19641968

19651969
/**
@@ -2813,6 +2817,9 @@ public function testContainNonAlphaNumeric()
28132817
$this->assertFalse(Validation::containsNonAlphaNumeric('abcdef##', 3));
28142818
$this->assertFalse(Validation::containsNonAlphaNumeric('abc##def', 3));
28152819
$this->assertFalse(Validation::containsNonAlphaNumeric('ab#cd#ef', 3));
2820+
2821+
//Non alpha numeric should not pass as array
2822+
$this->assertFalse(Validation::containsNonAlphaNumeric(['abc#']));
28162823
}
28172824

28182825
/**

0 commit comments

Comments
 (0)