summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/libraries
diff options
context:
space:
mode:
authorZach Ploskey <zach@ploskey.com>2017-10-04 14:24:53 +0200
committerZach Ploskey <zach@ploskey.com>2017-10-06 12:44:52 +0200
commita088cc47a7104e11d78eac44851779d20bae9cbc (patch)
treeabc1e8e8ad34e376e8347b931a8f003c3210c235 /tests/codeigniter/libraries
parent4aecaf55f404c627db823f04dd8032c9fb59073c (diff)
Fix issue 5202
Fix attempting to access data_ref before it is defined when validating an array input with multiple explicitly specified keys. Adds a test for the issue. Signed-off-by: Zach Ploskey <zach@ploskey.com>
Diffstat (limited to 'tests/codeigniter/libraries')
-rw-r--r--tests/codeigniter/libraries/Form_validation_test.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php
index ebb14983e..b70f950a2 100644
--- a/tests/codeigniter/libraries/Form_validation_test.php
+++ b/tests/codeigniter/libraries/Form_validation_test.php
@@ -482,6 +482,20 @@ class Form_validation_test extends CI_TestCase {
$this->assertEquals('bar2', $this->form_validation->set_value('bar[]', $default));
}
+ public function test_issue_5202()
+ {
+ $data = array('person' => array('firstname' => 'Dick', 'lastname' => 'Tracy '));
+ $this->form_validation->reset_validation();
+ $this->form_validation->set_rules('person[firstname]', 'First Name', 'required|trim');
+ $this->form_validation->set_rules('person[lastname]', 'Last Name', 'required|trim');
+ $this->form_validation->set_data($data);
+ $valid = $this->form_validation->run('', $data);
+
+ $this->assertEquals(TRUE, $valid);
+ $this->assertEquals('Dick', $data['person']['firstname']);
+ $this->assertEquals('Tracy', $data['person']['lastname']);
+ }
+
public function test_set_select()
{
// Test 1: No options selected