true, 'auto_id' => true, 'auto_id_prefix' => 'form_', 'form_method' => 'post', 'form_template' => "\n\t\t{open}\n\t\t\n{fields}\n\t\t
\n\t\t{close}\n", 'fieldset_template' => "\n\t\t{open}\n{fields}
\n\t\t{close}\n", 'field_template' => "\t\t\n\t\t\t{label}{required}\n\t\t\t{field} {description} {error_msg}\n\t\t\n", 'multi_field_template' => "\t\t\n\t\t\t{group_label}{required}\n\t\t\t{fields}\n\t\t\t\t{field} {label}
\n{fields}{description}\t\t\t{error_msg}\n\t\t\t\n\t\t\n", 'error_template' => '{error_msg}', 'required_mark' => '*', 'inline_errors' => false, 'error_class' => 'validation_error', )); Config::set('security.csrf_auto_token', false); Config::set('security.csrf_token_key', 'fuel_csrf_token'); } /** * Tests Form::input() * * test for data prepping * * @test */ public function test_input_prep() { $output = Form::input('name', '"H&M"'); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', ''); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', "0"); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', 0); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', 1); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', 10); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', true); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', false); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', null); $expected = ''; $this->assertEquals($expected, $output); } /** * Tests Form::input() * * test for dont_prep * * @test */ public function test_input_dont_prep() { $output = Form::input('name', '"'H&M'"', array('dont_prep' => true)); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', '', array('dont_prep' => true)); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', "0", array('dont_prep' => true)); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', 0, array('dont_prep' => true)); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', 1, array('dont_prep' => true)); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', 10, array('dont_prep' => true)); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', true, array('dont_prep' => true)); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', false, array('dont_prep' => true)); $expected = ''; $this->assertEquals($expected, $output); $output = Form::input('name', null, array('dont_prep' => true)); $expected = ''; $this->assertEquals($expected, $output); } /** * Tests Form::textarea() * * test for data prepping * * @test */ public function test_textarea_prep() { $output = Form::textarea('name', '"H&M"'); $expected = ''; $this->assertEquals($expected, $output); } /** * Tests Form::textarea() * * test for dont_prep * * @test */ public function test_textarea_dont_prep() { $output = Form::textarea('name', '"'H&M'"', array('dont_prep' => true)); $expected = ''; $this->assertEquals($expected, $output); } /** * Tests Form::select() * * test for data prepping * * @test */ public function test_select_prep() { $output = Form::select('fieldname', null, array( 'key_H&M' => 'val_H&M', 'key_""' => 'val_""', ) ); $expected = ''; $this->assertEquals($expected, $output); } /** * Tests Form::prep_value() * * @test */ public function test_prep_value() { $output = Form::prep_value('<"H&M">'); $expected = '<"H&M">'; $this->assertEquals($expected, $output); } /** * Tests Form::select() * * test for dont_prep * * @test */ public function test_select_dont_prep() { $output = Form::select('fieldname', null, array( 'key_H&M' => 'val_H&M', 'key_"'"' => 'val_"'"', ), array( 'dont_prep' => true, ) ); $expected = ''; $this->assertEquals($expected, $output); } /** * Tests Form::prep_value() * * test of invalid string * * @test */ public function test_prep_value_invalid_utf8() { // 6 byte UTF-8 string, which is invalid now $utf8_string = "\xFC\x84\x80\x80\x80\x80"; $output = Form::prep_value($utf8_string); $expected = ''; $this->assertEquals($expected, $output); } /** * Tests Form::label() * * @test */ public function test_label_auto_id_true() { $config = \Config::get('form.auto_id'); \Config::set('form.auto_id', true); $form = \Form::forge(__METHOD__); $label = 'label'; $id = 'id'; $output = $form->label($label, $id); $expected = ''; $this->assertEquals($expected, $output); \Config::set('form.auto_id', $config); } /** * Tests Form::label() * * @test */ public function test_label_auto_id_false() { $config = \Config::get('form.auto_id'); \Config::set('form.auto_id', false); $form = \Form::forge(__METHOD__); $label = 'label'; $id = 'id'; $output = $form->label($label, $id); $expected = ''; $this->assertEquals($expected, $output); \Config::set('form.auto_id', $config); } /** * Tests Form::open() * * @test */ public function test_open() { $form = \Form::forge(__METHOD__); $output = $form->open('uri/to/form'); $expected = '
'; $this->assertEquals($expected, $output); } /** * Tests Form::open() * * @test */ public function test_open_auto_csrf_token() { \Config::set('security.csrf_auto_token', true); $form = \Form::forge(__METHOD__); $output = $form->open('uri/to/form'); $expected = ''.PHP_EOL.''; $this->assertStringMatchesFormat($expected, $output); } /** * Tests Form::open() * * @test */ public function test_open_static() { $output = Form::open('uri/to/form'); $expected = ''; $this->assertEquals($expected, $output); } /** * Tests Form::open() * * @test */ public function test_open_auto_csrf_token_static() { \Config::set('security.csrf_auto_token', true); $output = Form::open('uri/to/form'); $expected = ''.PHP_EOL.''; $this->assertStringMatchesFormat($expected, $output); } }