diff options
author | tianhe1986 <w1s2j3229@163.com> | 2018-06-22 10:51:11 +0200 |
---|---|---|
committer | tianhe1986 <w1s2j3229@163.com> | 2018-06-22 10:51:11 +0200 |
commit | 8729b2f1e54ed19f18cf31ba5c11a2953a7e4274 (patch) | |
tree | 331fd9676be3c2f2a2e7260164ebb2cca393117a /tests | |
parent | 65d3bff26a8e6342604f18caac70548f164a904d (diff) |
Adding unit test.
Signed-off-by: tianhe1986 <w1s2j3229@163.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/codeigniter/core/Input_test.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index 80cb9a740..07a99e136 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -90,6 +90,23 @@ class Input_test extends CI_TestCase { // -------------------------------------------------------------------- + public function test_post_get_array_notation() + { + $_SERVER['REQUEST_METHOD'] = 'POST'; + $_POST['foo']['bar'] = 'baz'; + $barArray = array('bar' => 'baz'); + + $this->assertEquals('baz', $this->input->get_post('foo[bar]')); + $this->assertEquals($barArray, $this->input->get_post('foo[]')); + $this->assertNull($this->input->get_post('foo[baz]')); + + $this->assertEquals('baz', $this->input->post_get('foo[bar]')); + $this->assertEquals($barArray, $this->input->post_get('foo[]')); + $this->assertNull($this->input->post_get('foo[baz]')); + } + + // -------------------------------------------------------------------- + public function test_get_post() { $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -100,6 +117,23 @@ class Input_test extends CI_TestCase { // -------------------------------------------------------------------- + public function test_get_post_array_notation() + { + $_SERVER['REQUEST_METHOD'] = 'GET'; + $_GET['foo']['bar'] = 'baz'; + $barArray = array('bar' => 'baz'); + + $this->assertEquals('baz', $this->input->get_post('foo[bar]')); + $this->assertEquals($barArray, $this->input->get_post('foo[]')); + $this->assertNull($this->input->get_post('foo[baz]')); + + $this->assertEquals('baz', $this->input->post_get('foo[bar]')); + $this->assertEquals($barArray, $this->input->post_get('foo[]')); + $this->assertNull($this->input->post_get('foo[baz]')); + } + + // -------------------------------------------------------------------- + public function test_cookie() { $_COOKIE['foo'] = 'bar'; |