summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woods <d.woods92@gmail.com>2015-03-18 18:29:20 +0100
committerDavid Woods <d.woods92@gmail.com>2015-03-18 18:29:20 +0100
commit70e220ad2423f2f701b0db12686dad2e7e9a6458 (patch)
tree2dd97594e38b749f3c24c4f28ac26a286773ab6b
parent63c288cdd7dd66c653da1092ac07a035b01ef560 (diff)
Fixed bug of clearing POST array before every test.
Signed-off-by: David Woods <d.woods92@gmail.com>
-rw-r--r--tests/codeigniter/libraries/Form_validation_test.php26
1 files changed, 14 insertions, 12 deletions
diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php
index 9c21b9cfb..3dff2f374 100644
--- a/tests/codeigniter/libraries/Form_validation_test.php
+++ b/tests/codeigniter/libraries/Form_validation_test.php
@@ -49,28 +49,28 @@ class Form_validation_test extends CI_TestCase {
{
// Empty input should pass any rule unless required is also specified
$_POST['to_match'] = 'sample';
- $this->assertTrue($this->run_rule('matches[to_match]', ''));
+ $this->assertTrue($this->run_rule('matches[to_match]', '', FALSE));
$_POST['to_match'] = 'sample';
- $this->assertTrue($this->run_rule('matches[to_match]', 'sample'));
+ $this->assertTrue($this->run_rule('matches[to_match]', 'sample', FALSE));
$_POST['to_match'] = 'sample';
- $this->assertFalse($this->run_rule('matches[to_match]', 'Sample'));
+ $this->assertFalse($this->run_rule('matches[to_match]', 'Sample', FALSE));
$_POST['to_match'] = 'sample';
- $this->assertFalse($this->run_rule('matches[to_match]', ' sample'));
+ $this->assertFalse($this->run_rule('matches[to_match]', ' sample', FALSE));
}
public function test_rule_differs()
{
// Empty input should pass any rule unless required is also specified
$_POST['to_differ'] = 'sample';
- $this->assertTrue($this->run_rule('differs[to_differ]', ''));
+ $this->assertTrue($this->run_rule('differs[to_differ]', '', FALSE));
$_POST['to_differ'] = 'sample';
- $this->assertTrue($this->run_rule('differs[to_differ]', 'Sample'));
+ $this->assertTrue($this->run_rule('differs[to_differ]', 'Sample', FALSE));
$_POST['to_differ'] = 'sample';
- $this->assertTrue($this->run_rule('differs[to_differ]', ' sample'));
+ $this->assertTrue($this->run_rule('differs[to_differ]', ' sample', FALSE));
$_POST['to_differ'] = 'sample';
- $this->assertFalse($this->run_rule('differs[to_differ]', 'sample'));
+ $this->assertFalse($this->run_rule('differs[to_differ]', 'sample', FALSE));
}
public function test_rule_min_length()
@@ -302,13 +302,15 @@ class Form_validation_test extends CI_TestCase {
$this->assertFalse($this->run_rule('valid_base64', "FA08GG"));
}
- public function run_rule($rule, $test_value)
+ public function run_rule($rule, $test_value, $reset_post = TRUE)
{
// $this->markTestSkipped('Not designed to be a unit test');
- // Reset the _$POST array
- $_POST = array();
$this->form_validation->reset_validation();
-
+ if ($reset_post === TRUE)
+ {
+ $_POST = array();
+ }
+
$this->form_validation->set_rules('field', 'name', $rule);
$_POST['field'] = $test_value;
return $this->form_validation->run();