summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/libraries
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-05-25 09:54:36 +0200
committerAndrey Andreev <narf@devilix.net>2016-05-25 09:54:36 +0200
commit9e78be0d736ed0caab396f58109ce1db7169d727 (patch)
tree450459f8e77b3f2d651235d79a85001dce96cc1a /tests/codeigniter/libraries
parentad20f71b0395d8fadd417b3a2b580b6c53a80000 (diff)
Fix #4639
Really fix #4633
Diffstat (limited to 'tests/codeigniter/libraries')
-rw-r--r--tests/codeigniter/libraries/Form_validation_test.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php
index d11d616ad..b87ca65ff 100644
--- a/tests/codeigniter/libraries/Form_validation_test.php
+++ b/tests/codeigniter/libraries/Form_validation_test.php
@@ -40,11 +40,22 @@ class Form_validation_test extends CI_TestCase {
public function test_rule_required()
{
- $rules = array(array('field' => 'foo', 'label' => 'foo_label', 'rules' => 'required'));
- $this->assertTrue($this->run_rules($rules, array('foo' => 'bar')));
+ $rules = array(array('field' => 'foo', 'label' => 'Foo', 'rules' => 'is_numeric'));
+ // Empty, not required
+ $this->assertTrue($this->run_rules($rules, array('foo' => '')));
+
+
+ // Not required, but also not empty
+ $this->assertTrue($this->run_rules($rules, array('foo' => '123')));
+ $this->assertFalse($this->run_rules($rules, array('foo' => 'bar')));
+
+ // Required variations
+ $rules[0]['rules'] .= '|required';
+ $this->assertTrue($this->run_rules($rules, array('foo' => '123')));
$this->assertFalse($this->run_rules($rules, array('foo' => '')));
$this->assertFalse($this->run_rules($rules, array('foo' => ' ')));
+ $this->assertFalse($this->run_rules($rules, array('foo' => 'bar')));
}
public function test_rule_matches()