diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index dcb7ab750d..8705082f24 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -82,7 +82,7 @@ if ( ! function_exists('form_open')) $form = '
\n"; // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites - $before = (new \Config\Filters())->globals['before']; + $before = Services::filters()->getFilters()['before']; if ((in_array('csrf', $before) || array_key_exists('csrf', $before)) && strpos($action, base_url()) !== false && ! stripos($form, 'method="get"') ) diff --git a/tests/system/Helpers/FormHelperTest.php b/tests/system/Helpers/FormHelperTest.php index 955ee82850..560b1d8e3b 100644 --- a/tests/system/Helpers/FormHelperTest.php +++ b/tests/system/Helpers/FormHelperTest.php @@ -1,4 +1,6 @@ -baseURL = ''; - $config->indexPage = 'index.php'; - $request = Services::request($config); - $request->uri = new URI('http://example.com/'); + public function setUp() + { + parent::setUp(); - Services::injectMock('request', $request); + helper('form'); + } + + // ------------------------------------------------------------------------ + public function testFormOpenBasic() + { + $config = new App(); + $config->baseURL = ''; + $config->indexPage = 'index.php'; + $request = Services::request($config); + $request->uri = new URI('http://example.com/'); + + Services::injectMock('request', $request); $before = (new Filters())->globals['before']; - if (in_array('csrf', $before) || array_key_exists('csrf', $before )) + if (in_array('csrf', $before) || array_key_exists('csrf', $before)) { $Value = csrf_hash(); $Name = csrf_token(); @@ -43,26 +47,27 @@ EOH; EOH; } - $attributes = [ - 'name' => 'form', - 'id' => 'form', - 'method' => 'POST' - ]; - $this->assertEquals($expected, form_open('foo/bar', $attributes)); - } - // ------------------------------------------------------------------------ - public function testFormOpenWithoutAction() - { - $config = new App(); - $config->baseURL = ''; - $config->indexPage = 'index.php'; - $request = Services::request($config); - $request->uri = new URI('http://example.com/'); + $attributes = [ + 'name' => 'form', + 'id' => 'form', + 'method' => 'POST' + ]; + $this->assertEquals($expected, form_open('foo/bar', $attributes)); + } - Services::injectMock('request', $request); + // ------------------------------------------------------------------------ + public function testFormOpenWithoutAction() + { + $config = new App(); + $config->baseURL = ''; + $config->indexPage = 'index.php'; + $request = Services::request($config); + $request->uri = new URI('http://example.com/'); + + Services::injectMock('request', $request); $before = (new Filters())->globals['before']; - if (in_array('csrf', $before) || array_key_exists('csrf', $before )) + if (in_array('csrf', $before) || array_key_exists('csrf', $before)) { $Value = csrf_hash(); $Name = csrf_token(); @@ -79,26 +84,27 @@ EOH; EOH; } - $attributes = [ - 'name' => 'form', - 'id' => 'form', - 'method' => 'POST' - ]; - $this->assertEquals($expected, form_open('', $attributes)); - } - // ------------------------------------------------------------------------ - public function testFormOpenWithoutMethod() - { - $config = new App(); - $config->baseURL = ''; - $config->indexPage = 'index.php'; - $request = Services::request($config); - $request->uri = new URI('http://example.com/'); + $attributes = [ + 'name' => 'form', + 'id' => 'form', + 'method' => 'POST' + ]; + $this->assertEquals($expected, form_open('', $attributes)); + } - Services::injectMock('request', $request); + // ------------------------------------------------------------------------ + public function testFormOpenWithoutMethod() + { + $config = new App(); + $config->baseURL = ''; + $config->indexPage = 'index.php'; + $request = Services::request($config); + $request->uri = new URI('http://example.com/'); + + Services::injectMock('request', $request); $before = (new Filters())->globals['before']; - if (in_array('csrf', $before) || array_key_exists('csrf', $before )) + if (in_array('csrf', $before) || array_key_exists('csrf', $before)) { $Value = csrf_hash(); $Name = csrf_token(); @@ -116,25 +122,26 @@ EOH; EOH; } - $attributes = [ - 'name' => 'form', - 'id' => 'form' - ]; - $this->assertEquals($expected, form_open('foo/bar', $attributes)); - } - // ------------------------------------------------------------------------ - public function testFormOpenWithHidden() - { - $config = new App(); - $config->baseURL = ''; - $config->indexPage = 'index.php'; - $request = Services::request($config); - $request->uri = new URI('http://example.com/'); + $attributes = [ + 'name' => 'form', + 'id' => 'form' + ]; + $this->assertEquals($expected, form_open('foo/bar', $attributes)); + } - Services::injectMock('request', $request); + // ------------------------------------------------------------------------ + public function testFormOpenWithHidden() + { + $config = new App(); + $config->baseURL = ''; + $config->indexPage = 'index.php'; + $request = Services::request($config); + $request->uri = new URI('http://example.com/'); + + Services::injectMock('request', $request); $before = (new Filters())->globals['before']; - if (in_array('csrf', $before) || array_key_exists('csrf', $before )) + if (in_array('csrf', $before) || array_key_exists('csrf', $before)) { $Value = csrf_hash(); $Name = csrf_token(); @@ -154,29 +161,65 @@ EOH; EOH; } - $attributes = [ - 'name' => 'form', - 'id' => 'form', - 'method' => 'POST' - ]; - $hidden = [ - 'foo' => 'bar' - ]; - $this->assertEquals($expected, form_open('foo/bar', $attributes, $hidden)); - } - // ------------------------------------------------------------------------ - public function testFormOpenMultipart() - { - $config = new App(); - $config->baseURL = ''; - $config->indexPage = 'index.php'; - $request = Services::request($config); - $request->uri = new URI('http://example.com/'); + $attributes = [ + 'name' => 'form', + 'id' => 'form', + 'method' => 'POST' + ]; + $hidden = [ + 'foo' => 'bar' + ]; + $this->assertEquals($expected, form_open('foo/bar', $attributes, $hidden)); + } - Services::injectMock('request', $request); +// ------------------------------------------------------------------------ + public function testFormOpenWithCSRF() + { + $config = new App(); + $config->baseURL = ''; + $config->indexPage = 'index.php'; + $request = Services::request($config); + $request->uri = new URI('http://example.com/'); + + Services::injectMock('request', $request); + + $filters = Services::filters(); + $filters->globals['before'][] = 'csrf'; // force CSRF + $before = $filters->globals['before']; + + $Value = csrf_hash(); + $Name = csrf_token(); + $expected = << + + + +EOH; + + $attributes = [ + 'name' => 'form', + 'id' => 'form', + 'method' => 'POST' + ]; + $hidden = [ + 'foo' => 'bar' + ]; + $this->assertEquals($expected, form_open('foo/bar', $attributes, $hidden)); + } + + // ------------------------------------------------------------------------ + public function testFormOpenMultipart() + { + $config = new App(); + $config->baseURL = ''; + $config->indexPage = 'index.php'; + $request = Services::request($config); + $request->uri = new URI('http://example.com/'); + + Services::injectMock('request', $request); $before = (new Filters())->globals['before']; - if (in_array('csrf', $before) || array_key_exists('csrf', $before )) + if (in_array('csrf', $before) || array_key_exists('csrf', $before)) { $Value = csrf_hash(); $Name = csrf_token(); @@ -193,105 +236,114 @@ EOH; EOH; } - $attributes = [ - 'name' => 'form', - 'id' => 'form', - 'method' => 'POST' - ]; - $this->assertEquals($expected, form_open_multipart('foo/bar', $attributes)); - } - // ------------------------------------------------------------------------ - public function testFormHidden() - { - $expected = << 'form', + 'id' => 'form', + 'method' => 'POST' + ]; + $this->assertEquals($expected, form_open_multipart('foo/bar', $attributes)); + } + + // ------------------------------------------------------------------------ + public function testFormHidden() + { + $expected = <<\n EOH; - $this->assertEquals($expected, form_hidden('username', 'johndoe')); - } - // ------------------------------------------------------------------------ - public function testFormHiddenArrayInput() - { - $data = [ - 'foo' => 'bar' - ]; - $expected = <<assertEquals($expected, form_hidden('username', 'johndoe')); + } + + // ------------------------------------------------------------------------ + public function testFormHiddenArrayInput() + { + $data = [ + 'foo' => 'bar' + ]; + $expected = << EOH; - $this->assertEquals($expected, form_hidden($data, null)); - } - // ------------------------------------------------------------------------ - public function testFormHiddenArrayValues() - { - $data = [ - 'foo' => 'bar' - ]; - $expected = <<assertEquals($expected, form_hidden($data, null)); + } + + // ------------------------------------------------------------------------ + public function testFormHiddenArrayValues() + { + $data = [ + 'foo' => 'bar' + ]; + $expected = << EOH; - $this->assertEquals($expected, form_hidden('name', $data)); - } - // ------------------------------------------------------------------------ - public function testFormInput() - { - $expected = <<assertEquals($expected, form_hidden('name', $data)); + } + + // ------------------------------------------------------------------------ + public function testFormInput() + { + $expected = <<\n EOH; - $data = [ - 'name' => 'username', - 'id' => 'username', - 'value' => 'johndoe', - 'maxlength' => '100', - 'size' => '50', - 'style' => 'width:50%', - ]; - $this->assertEquals($expected, form_input($data)); - } - // ------------------------------------------------------------------------ - public function test_form_password() - { - $expected = << 'username', + 'id' => 'username', + 'value' => 'johndoe', + 'maxlength' => '100', + 'size' => '50', + 'style' => 'width:50%', + ]; + $this->assertEquals($expected, form_input($data)); + } + + // ------------------------------------------------------------------------ + public function test_form_password() + { + $expected = <<\n EOH; - $this->assertEquals($expected, form_password('password')); - } - // ------------------------------------------------------------------------ - public function test_form_upload() - { - $expected = <<assertEquals($expected, form_password('password')); + } + + // ------------------------------------------------------------------------ + public function test_form_upload() + { + $expected = <<\n EOH; - $this->assertEquals($expected, form_upload('attachment')); - } - // ------------------------------------------------------------------------ - public function test_form_textarea() - { - $expected = <<assertEquals($expected, form_upload('attachment')); + } + + // ------------------------------------------------------------------------ + public function test_form_textarea() + { + $expected = <<Notes\n EOH; - $this->assertEquals($expected, form_textarea('notes', 'Notes')); - } - // ------------------------------------------------------------------------ - public function testFormTextareaWithValueAttribute() - { - $data = [ - 'name' => 'foo', - 'value' => 'bar' - ]; - $expected = <<assertEquals($expected, form_textarea('notes', 'Notes')); + } + + // ------------------------------------------------------------------------ + public function testFormTextareaWithValueAttribute() + { + $data = [ + 'name' => 'foo', + 'value' => 'bar' + ]; + $expected = <<bar EOH; - $this->assertEquals($expected, form_textarea($data)); - } - // ------------------------------------------------------------------------ - public function test_form_dropdown() - { - $expected = <<assertEquals($expected, form_textarea($data)); + } + + // ------------------------------------------------------------------------ + public function test_form_dropdown() + { + $expected = << @@ -299,14 +351,14 @@ EOH; \n EOH; - $options = [ - 'small' => 'Small Shirt', - 'med' => 'Medium Shirt', - 'large' => 'Large Shirt', - 'xlarge' => 'Extra Large Shirt', - ]; - $this->assertEquals($expected, form_dropdown('shirts', $options, 'large')); - $expected = << 'Small Shirt', + 'med' => 'Medium Shirt', + 'large' => 'Large Shirt', + 'xlarge' => 'Extra Large Shirt', + ]; + $this->assertEquals($expected, form_dropdown('shirts', $options, 'large')); + $expected = << @@ -314,19 +366,19 @@ EOH; \n EOH; - $shirts_on_sale = ['small', 'large']; - $this->assertEquals($expected, form_dropdown('shirts', $options, $shirts_on_sale)); - $options = [ - 'Swedish Cars' => [ - 'volvo' => 'Volvo', - 'saab' => 'Saab' - ], - 'German Cars' => [ - 'mercedes' => 'Mercedes', - 'audi' => 'Audi' - ] - ]; - $expected = <<assertEquals($expected, form_dropdown('shirts', $options, $shirts_on_sale)); + $options = [ + 'Swedish Cars' => [ + 'volvo' => 'Volvo', + 'saab' => 'Saab' + ], + 'German Cars' => [ + 'mercedes' => 'Mercedes', + 'audi' => 'Audi' + ] + ]; + $expected = << @@ -338,60 +390,64 @@ EOH; \n EOH; - $this->assertEquals($expected, form_dropdown('cars', $options, ['volvo', 'audi'])); - } - // ------------------------------------------------------------------------ - public function testFormDropdownWithSelectedAttribute() - { - $expected = <<assertEquals($expected, form_dropdown('cars', $options, ['volvo', 'audi'])); + } + + // ------------------------------------------------------------------------ + public function testFormDropdownWithSelectedAttribute() + { + $expected = << EOH; - $data = [ - 'name' => 'foo', - 'selected' => 'bar' - ]; - $options = [ - 'bar' => 'Bar' - ]; - $this->assertEquals($expected, form_dropdown($data, $options)); - } - // ------------------------------------------------------------------------ - public function testFormDropdownWithOptionsAttribute() - { - $expected = << 'foo', + 'selected' => 'bar' + ]; + $options = [ + 'bar' => 'Bar' + ]; + $this->assertEquals($expected, form_dropdown($data, $options)); + } + + // ------------------------------------------------------------------------ + public function testFormDropdownWithOptionsAttribute() + { + $expected = << EOH; - $data = [ - 'name' => 'foo', - 'options' => [ - 'bar' => 'Bar' - ] - ]; - $this->assertEquals($expected, form_dropdown($data)); - } - // ------------------------------------------------------------------------ - public function testFormDropdownWithEmptyArrayOptionValue() - { - $expected = << 'foo', + 'options' => [ + 'bar' => 'Bar' + ] + ]; + $this->assertEquals($expected, form_dropdown($data)); + } + + // ------------------------------------------------------------------------ + public function testFormDropdownWithEmptyArrayOptionValue() + { + $expected = << EOH; - $options = [ - 'bar' => [] - ]; - $this->assertEquals($expected, form_dropdown('foo', $options)); - } - // ------------------------------------------------------------------------ - public function test_form_multiselect() - { - $expected = << [] + ]; + $this->assertEquals($expected, form_dropdown('foo', $options)); + } + + // ------------------------------------------------------------------------ + public function test_form_multiselect() + { + $expected = << @@ -399,169 +455,185 @@ EOH; \n EOH; - $options = [ - 'small' => 'Small Shirt', - 'med' => 'Medium Shirt', - 'large' => 'Large Shirt', - 'xlarge' => 'Extra Large Shirt', - ]; - $this->assertEquals($expected, form_multiselect('shirts[]', $options, ['med', 'large'])); - } - // ------------------------------------------------------------------------ - public function test_form_fieldset() - { - $expected = << 'Small Shirt', + 'med' => 'Medium Shirt', + 'large' => 'Large Shirt', + 'xlarge' => 'Extra Large Shirt', + ]; + $this->assertEquals($expected, form_multiselect('shirts[]', $options, ['med', 'large'])); + } + + // ------------------------------------------------------------------------ + public function test_form_fieldset() + { + $expected = << Address Information\n EOH; - $this->assertEquals($expected, form_fieldset('Address Information')); - } - // ------------------------------------------------------------------------ - public function testFormFieldsetWithNoLegent() - { - $expected = <<assertEquals($expected, form_fieldset('Address Information')); + } + + // ------------------------------------------------------------------------ + public function testFormFieldsetWithNoLegent() + { + $expected = << EOH; - $this->assertEquals($expected, form_fieldset()); - } - // ------------------------------------------------------------------------ - public function testFormFieldsetWithAttributes() - { - $attributes = [ - 'name' => 'bar' - ]; - $expected = <<assertEquals($expected, form_fieldset()); + } + + // ------------------------------------------------------------------------ + public function testFormFieldsetWithAttributes() + { + $attributes = [ + 'name' => 'bar' + ]; + $expected = << Foo EOH; - $this->assertEquals($expected, form_fieldset('Foo', $attributes)); - } - // ------------------------------------------------------------------------ - public function test_form_fieldset_close() - { - $expected = <<assertEquals($expected, form_fieldset('Foo', $attributes)); + } + + // ------------------------------------------------------------------------ + public function test_form_fieldset_close() + { + $expected = << EOH; - $this->assertEquals($expected, form_fieldset_close('')); - } - // ------------------------------------------------------------------------ - public function test_form_checkbox() - { - $expected = <<assertEquals($expected, form_fieldset_close('')); + } + + // ------------------------------------------------------------------------ + public function test_form_checkbox() + { + $expected = <<\n EOH; - $this->assertEquals($expected, form_checkbox('newsletter', 'accept', TRUE)); - } - // ------------------------------------------------------------------------ - public function testFormCheckboxArrayData() - { - $data = [ - 'name' => 'foo', - 'value' => 'bar', - 'checked' => true - ]; - $expected = <<assertEquals($expected, form_checkbox('newsletter', 'accept', TRUE)); + } + + // ------------------------------------------------------------------------ + public function testFormCheckboxArrayData() + { + $data = [ + 'name' => 'foo', + 'value' => 'bar', + 'checked' => true + ]; + $expected = << EOH; - $this->assertEquals($expected, form_checkbox($data)); - } - // ------------------------------------------------------------------------ - public function testFormCheckboxArrayDataWithCheckedFalse() - { - $data = [ - 'name' => 'foo', - 'value' => 'bar', - 'checked' => false - ]; - $expected = <<assertEquals($expected, form_checkbox($data)); + } + + // ------------------------------------------------------------------------ + public function testFormCheckboxArrayDataWithCheckedFalse() + { + $data = [ + 'name' => 'foo', + 'value' => 'bar', + 'checked' => false + ]; + $expected = << EOH; - $this->assertEquals($expected, form_checkbox($data)); - } - // ------------------------------------------------------------------------ - public function test_form_radio() - { - $expected = <<assertEquals($expected, form_checkbox($data)); + } + + // ------------------------------------------------------------------------ + public function test_form_radio() + { + $expected = <<\n EOH; - $this->assertEquals($expected, form_radio('newsletter', 'accept', TRUE)); - } - // ------------------------------------------------------------------------ - public function test_form_submit() - { - $expected = <<assertEquals($expected, form_radio('newsletter', 'accept', TRUE)); + } + + // ------------------------------------------------------------------------ + public function test_form_submit() + { + $expected = <<\n EOH; - $this->assertEquals($expected, form_submit('mysubmit', 'Submit Post!')); - } - // ------------------------------------------------------------------------ - public function test_form_label() - { - $expected = <<assertEquals($expected, form_submit('mysubmit', 'Submit Post!')); + } + + // ------------------------------------------------------------------------ + public function test_form_label() + { + $expected = <<What is your Name EOH; - $this->assertEquals($expected, form_label('What is your Name', 'username')); - } - // ------------------------------------------------------------------------ - public function testFormLabelWithAttributes() - { - $attributes = [ - 'id' => 'label1' - ]; - $expected = <<assertEquals($expected, form_label('What is your Name', 'username')); + } + + // ------------------------------------------------------------------------ + public function testFormLabelWithAttributes() + { + $attributes = [ + 'id' => 'label1' + ]; + $expected = <<bar EOH; - $this->assertEquals($expected, form_label('bar', 'foo', $attributes)); - } - // ------------------------------------------------------------------------ - public function test_form_reset() - { - $expected = <<assertEquals($expected, form_label('bar', 'foo', $attributes)); + } + + // ------------------------------------------------------------------------ + public function test_form_reset() + { + $expected = <<\n EOH; - $this->assertEquals($expected, form_reset('myreset', 'Reset')); - } - // ------------------------------------------------------------------------ - public function test_form_button() - { - $expected = <<assertEquals($expected, form_reset('myreset', 'Reset')); + } + + // ------------------------------------------------------------------------ + public function test_form_button() + { + $expected = <<content\n EOH; - $this->assertEquals($expected, form_button('name', 'content')); - } - // ------------------------------------------------------------------------ - public function testFormButtonWithDataArray() - { - $data = [ - 'name' => 'foo', - 'content' => 'bar' - ]; - $expected = <<assertEquals($expected, form_button('name', 'content')); + } + + // ------------------------------------------------------------------------ + public function testFormButtonWithDataArray() + { + $data = [ + 'name' => 'foo', + 'content' => 'bar' + ]; + $expected = <<bar EOH; - $this->assertEquals($expected, form_button($data)); - } - // ------------------------------------------------------------------------ - public function test_form_close() - { - $expected = <<assertEquals($expected, form_button($data)); + } + + // ------------------------------------------------------------------------ + public function test_form_close() + { + $expected = << EOH; - $this->assertEquals($expected, form_close('')); - } - // ------------------------------------------------------------------------ - public function testFormDatalist() - { - $options = [ - 'foo1', - 'bar1' - ]; - $expected = <<assertEquals($expected, form_close('')); + } + + // ------------------------------------------------------------------------ + public function testFormDatalist() + { + $options = [ + 'foo1', + 'bar1' + ]; + $expected = << EOH; - $this->assertEquals($expected, form_datalist('foo', 'bar', $options)); - } - // ------------------------------------------------------------------------ - public function test_set_value() - { - $_SESSION['_ci_old_input']['post']['foo'] = 'assertEquals('<bar', set_value('foo')); + $this->assertEquals($expected, form_datalist('foo', 'bar', $options)); + } - unset($_SESSION['_ci_old_input']['post']['foo']); - $this->assertEquals('baz', set_value('foo', 'baz')); - } - // ------------------------------------------------------------------------ - public function test_set_select() - { - $_SESSION['_ci_old_input']['post']['foo'] = 'bar'; - $this->assertEquals(' selected="selected"', set_select('foo', 'bar')); + // ------------------------------------------------------------------------ + public function test_set_value() + { + $_SESSION['_ci_old_input']['post']['foo'] = 'assertEquals('<bar', set_value('foo')); - $_SESSION['_ci_old_input']['post']['foo'] = ['foo' => 'bar']; - $this->assertEquals(' selected="selected"', set_select('foo', 'bar')); - $this->assertEquals('', set_select('foo', 'baz')); + unset($_SESSION['_ci_old_input']['post']['foo']); + $this->assertEquals('baz', set_value('foo', 'baz')); + } - unset($_SESSION['_ci_old_input']['post']['foo']); - $this->assertEquals(' selected="selected"', set_select('foo', 'baz', true)); - } - // ------------------------------------------------------------------------ - public function test_set_checkbox() - { - $_SESSION = [ - '_ci_old_input' => [ - 'post' => [ - 'foo' => 'bar' - ] - ] - ]; + // ------------------------------------------------------------------------ + public function test_set_select() + { + $_SESSION['_ci_old_input']['post']['foo'] = 'bar'; + $this->assertEquals(' selected="selected"', set_select('foo', 'bar')); - $this->assertEquals(' checked="checked"', set_checkbox('foo', 'bar')); + $_SESSION['_ci_old_input']['post']['foo'] = ['foo' => 'bar']; + $this->assertEquals(' selected="selected"', set_select('foo', 'bar')); + $this->assertEquals('', set_select('foo', 'baz')); - $_SESSION = [ - '_ci_old_input' => [ - 'post' => [ - 'foo' => ['foo' => 'bar'] - ] - ] - ]; - $this->assertEquals(' checked="checked"', set_checkbox('foo', 'bar')); - $this->assertEquals('', set_checkbox('foo', 'baz')); + unset($_SESSION['_ci_old_input']['post']['foo']); + $this->assertEquals(' selected="selected"', set_select('foo', 'baz', true)); + } + + // ------------------------------------------------------------------------ + public function test_set_checkbox() + { + $_SESSION = [ + '_ci_old_input' => [ + 'post' => [ + 'foo' => 'bar' + ] + ] + ]; + + $this->assertEquals(' checked="checked"', set_checkbox('foo', 'bar')); + + $_SESSION = [ + '_ci_old_input' => [ + 'post' => [ + 'foo' => ['foo' => 'bar'] + ] + ] + ]; + $this->assertEquals(' checked="checked"', set_checkbox('foo', 'bar')); + $this->assertEquals('', set_checkbox('foo', 'baz')); $_SESSION = []; - $this->assertEquals('', set_checkbox('foo', 'bar')); - } - // ------------------------------------------------------------------------ - public function test_set_radio() - { - $_SESSION = [ - '_ci_old_input' => [ - 'post' => [ - 'foo' => 'bar' - ] - ] - ]; + $this->assertEquals('', set_checkbox('foo', 'bar')); + } + + // ------------------------------------------------------------------------ + public function test_set_radio() + { + $_SESSION = [ + '_ci_old_input' => [ + 'post' => [ + 'foo' => 'bar' + ] + ] + ]; + + $this->assertEquals(' checked="checked"', set_radio('foo', 'bar')); + $this->assertEquals('', set_radio('foo', 'baz')); + } - $this->assertEquals(' checked="checked"', set_radio('foo', 'bar')); - $this->assertEquals('', set_radio('foo', 'baz')); - } }