From 99b782d8a3d92c4703a059cbd62e2f1e6fea689c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 9 Jun 2012 22:24:46 +0300 Subject: Cleanup and optimize helper tests for speed --- tests/codeigniter/helpers/form_helper_test.php | 112 ++++++++++++------------- 1 file changed, 55 insertions(+), 57 deletions(-) (limited to 'tests/codeigniter/helpers/form_helper_test.php') diff --git a/tests/codeigniter/helpers/form_helper_test.php b/tests/codeigniter/helpers/form_helper_test.php index 80bace9d1..1a30ed993 100644 --- a/tests/codeigniter/helpers/form_helper_test.php +++ b/tests/codeigniter/helpers/form_helper_test.php @@ -3,26 +3,26 @@ require BASEPATH . 'core/Common.php'; require BASEPATH . 'helpers/form_helper.php'; -class Form_helper_test extends CI_TestCase +class Form_helper_test extends CI_TestCase { public function test_form_hidden() - { + { $expected = << EOH; - + $this->assertEquals($expected, form_hidden('username', 'johndoe')); } - + public function test_form_input() { $expected = << EOH; - + $data = array( 'name' => 'username', 'id' => 'username', @@ -34,37 +34,37 @@ EOH; $this->assertEquals($expected, form_input($data)); } - + public function test_form_password() - { + { $expected = << EOH; - + $this->assertEquals($expected, form_password('password')); } - + public function test_form_upload() - { + { $expected = << EOH; - + $this->assertEquals($expected, form_upload('attachment')); } - + public function test_form_textarea() - { + { $expected = <<Notes EOH; - + $this->assertEquals($expected, form_textarea('notes', 'Notes')); } - + public function test_form_dropdown() { $expected = << EOH; - + $options = array( - 'small' => 'Small Shirt', - 'med' => 'Medium Shirt', - 'large' => 'Large Shirt', - 'xlarge' => 'Extra Large Shirt', + 'small' => 'Small Shirt', + 'med' => 'Medium Shirt', + 'large' => 'Large Shirt', + 'xlarge' => 'Extra Large Shirt', ); - + $this->assertEquals($expected, form_dropdown('shirts', $options, 'large')); - + $expected = << @@ -95,22 +95,22 @@ EOH; EOH; - + $shirts_on_sale = array('small', 'large'); - + $this->assertEquals($expected, form_dropdown('shirts', $options, $shirts_on_sale)); - + $options = array( 'Swedish Cars' => array( - 'volvo' => 'Volvo', - 'saab' => 'Saab' + 'volvo' => 'Volvo', + 'saab' => 'Saab' ), 'German Cars' => array( - 'mercedes' => 'Mercedes', - 'audi' => 'Audi' + 'mercedes' => 'Mercedes', + 'audi' => 'Audi' ) ); - + $expected = << @@ -124,13 +124,10 @@ EOH; EOH; - - $cars_on_sale = array('volvo', 'audi'); - - $this->assertEquals($expected, form_dropdown('cars', $options, $cars_on_sale)); - + + $this->assertEquals($expected, form_dropdown('cars', $options, array('volvo', 'audi'))); } - + public function test_form_multiselect() { $expected = << EOH; - + $options = array( - 'small' => 'Small Shirt', - 'med' => 'Medium Shirt', - 'large' => 'Large Shirt', - 'xlarge' => 'Extra Large Shirt', - ); - + 'small' => 'Small Shirt', + 'med' => 'Medium Shirt', + 'large' => 'Large Shirt', + 'xlarge' => 'Extra Large Shirt', + ); + $this->assertEquals($expected, form_multiselect('shirts[]', $options, array('med', 'large'))); } - + public function test_form_fieldset() { $expected = <<Address Information EOH; - + $this->assertEquals($expected, form_fieldset('Address Information')); } @@ -169,10 +166,10 @@ EOH; $expected = << EOH; - + $this->assertEquals($expected, form_fieldset_close('')); } - + public function test_form_checkbox() { $expected = <<assertEquals($expected, form_checkbox('newsletter', 'accept', TRUE)); } - + public function test_form_radio() { $expected = <<assertEquals($expected, form_radio('newsletter', 'accept', TRUE)); } - + public function test_form_submit() { $expected = <<assertEquals($expected, form_submit('mysubmit', 'Submit Post!')); } - + public function test_form_label() { $expected = <<assertEquals($expected, form_label('What is your Name', 'username')); } - + public function test_form_reset() { $expected = <<assertEquals($expected, form_reset('myreset', 'Reset')); } - + public function test_form_button() { $expected = <<assertEquals($expected, form_button('name','content')); + $this->assertEquals($expected, form_button('name', 'content')); } - + public function test_form_close() { $expected = <<assertEquals($expected, form_close('')); } - + public function test_form_prep() { - $expected = "Here is a string containing "quoted" text."; - + $expected = 'Here is a string containing "quoted" text.'; + $this->assertEquals($expected, form_prep('Here is a string containing "quoted" text.')); } + } /* End of file form_helper_test.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b