Skip to content

Commit 8729b2f

Browse files
committed
Adding unit test.
Signed-off-by: tianhe1986 <[email protected]>
1 parent 65d3bff commit 8729b2f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/codeigniter/core/Input_test.php

+34
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,23 @@ public function test_post_get()
9090

9191
// --------------------------------------------------------------------
9292

93+
public function test_post_get_array_notation()
94+
{
95+
$_SERVER['REQUEST_METHOD'] = 'POST';
96+
$_POST['foo']['bar'] = 'baz';
97+
$barArray = array('bar' => 'baz');
98+
99+
$this->assertEquals('baz', $this->input->get_post('foo[bar]'));
100+
$this->assertEquals($barArray, $this->input->get_post('foo[]'));
101+
$this->assertNull($this->input->get_post('foo[baz]'));
102+
103+
$this->assertEquals('baz', $this->input->post_get('foo[bar]'));
104+
$this->assertEquals($barArray, $this->input->post_get('foo[]'));
105+
$this->assertNull($this->input->post_get('foo[baz]'));
106+
}
107+
108+
// --------------------------------------------------------------------
109+
93110
public function test_get_post()
94111
{
95112
$_SERVER['REQUEST_METHOD'] = 'GET';
@@ -100,6 +117,23 @@ public function test_get_post()
100117

101118
// --------------------------------------------------------------------
102119

120+
public function test_get_post_array_notation()
121+
{
122+
$_SERVER['REQUEST_METHOD'] = 'GET';
123+
$_GET['foo']['bar'] = 'baz';
124+
$barArray = array('bar' => 'baz');
125+
126+
$this->assertEquals('baz', $this->input->get_post('foo[bar]'));
127+
$this->assertEquals($barArray, $this->input->get_post('foo[]'));
128+
$this->assertNull($this->input->get_post('foo[baz]'));
129+
130+
$this->assertEquals('baz', $this->input->post_get('foo[bar]'));
131+
$this->assertEquals($barArray, $this->input->post_get('foo[]'));
132+
$this->assertNull($this->input->post_get('foo[baz]'));
133+
}
134+
135+
// --------------------------------------------------------------------
136+
103137
public function test_cookie()
104138
{
105139
$_COOKIE['foo'] = 'bar';

0 commit comments

Comments
 (0)