summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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()