From a83f063c2cebd50515b99e6ccab5afab4c958c06 Mon Sep 17 00:00:00 2001 From: tiyowan Date: Fri, 16 Mar 2012 23:52:43 +0400 Subject: Add unit tests for form_helper.php * Does not test form_open() and form_open_multipart() * Does not test set_value(), set_select(), set_checkbox() and set_radio() * Above are in progress and will be added once certain issues are resolved --- tests/codeigniter/helpers/form_helper_test.php | 252 +++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 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 new file mode 100644 index 000000000..80bace9d1 --- /dev/null +++ b/tests/codeigniter/helpers/form_helper_test.php @@ -0,0 +1,252 @@ + + +EOH; + + $this->assertEquals($expected, form_hidden('username', 'johndoe')); + } + + public function test_form_input() + { + $expected = << + +EOH; + + $data = array( + '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 = << + +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', + ); + + $this->assertEquals($expected, form_dropdown('shirts', $options, 'large')); + + $expected = << + + + + + + +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' + ), + 'German Cars' => array( + 'mercedes' => 'Mercedes', + 'audi' => 'Audi' + ) + ); + + $expected = << + + + + + + + + + + +EOH; + + $cars_on_sale = array('volvo', 'audi'); + + $this->assertEquals($expected, form_dropdown('cars', $options, $cars_on_sale)); + + } + + public function test_form_multiselect() + { + $expected = << + + + + + + +EOH; + + $options = array( + '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')); + } + + public function test_form_fieldset_close() + { + $expected = << +EOH; + + $this->assertEquals($expected, form_fieldset_close('')); + } + + public function test_form_checkbox() + { + $expected = << + +EOH; + + $this->assertEquals($expected, form_checkbox('newsletter', 'accept', TRUE)); + } + + public function test_form_radio() + { + $expected = << + +EOH; + + $this->assertEquals($expected, form_radio('newsletter', 'accept', TRUE)); + } + + public function test_form_submit() + { + $expected = << + +EOH; + + $this->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 test_form_reset() + { + $expected = << + +EOH; + + $this->assertEquals($expected, form_reset('myreset', 'Reset')); + } + + public function test_form_button() + { + $expected = <<content + +EOH; + + $this->assertEquals($expected, form_button('name','content')); + } + + public function test_form_close() + { + $expected = << +EOH; + + $this->assertEquals($expected, form_close('')); + } + + public function test_form_prep() + { + $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 From c8175be96157bb97374b1d9bb1be91c7b97bd640 Mon Sep 17 00:00:00 2001 From: tschechniker Date: Wed, 4 Apr 2012 14:47:30 +0300 Subject: Added Windows path compatibility to function read_dir --- system/libraries/Zip.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index e91e2a2ff..2ec7befd3 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -279,7 +279,7 @@ class CI_Zip { */ public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) { - $path = rtrim($path, '/\\').'/'; + $path = rtrim($path, '/\\').DIRECTORY_SEPARATOR; if ( ! $fp = @opendir($path)) { return FALSE; @@ -288,7 +288,7 @@ class CI_Zip { // Set the original directory root for child dir's to use as relative if ($root_path === NULL) { - $root_path = dirname($path).'/'; + $root_path = dirname($path).DIRECTORY_SEPARATOR; } while (FALSE !== ($file = readdir($fp))) @@ -300,11 +300,12 @@ class CI_Zip { if (@is_dir($path.$file)) { - $this->read_dir($path.$file.'/', $preserve_filepath, $root_path); + $this->read_dir($path.$file.DIRECTORY_SEPARATOR, $preserve_filepath, $root_path); } elseif (FALSE !== ($data = file_get_contents($path.$file))) { - $name = str_replace('\\', '/', $path); + $name = str_replace("\\", DIRECTORY_SEPARATOR, $path); + $name = str_replace("/", DIRECTORY_SEPARATOR, $path); if ($preserve_filepath === FALSE) { $name = str_replace($root_path, '', $name); -- cgit v1.2.3-24-g4f1b From 7bf632f4ba3a3db1ae38915efe2026d25acc9539 Mon Sep 17 00:00:00 2001 From: Tobias Tschech Date: Wed, 4 Apr 2012 15:18:26 +0300 Subject: Update user_guide_src/source/changelog.rst --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 9929cc368..1c8647bb7 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -194,6 +194,7 @@ Bug fixes for 3.0 - Fixed a bug (#1238) - delete_all() in the `Database Caching Library ` used to delete .htaccess and index.html files, which is a potential security risk. - Fixed a bug in :doc:`Trackback Library ` method validate_url() where it didn't actually do anything, due to input not being passed by reference. - Fixed a bug (#11, #183, #863) - CI_Form_validation::_execute() silently continued to the next rule, if a rule method/function is not found. +- Fixed a bug (#1242) Added Windows path compatibility to function read_dir of ZIP library Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 9664cc9fbb9b7f10776e9ad76ba7b27de5c2cda4 Mon Sep 17 00:00:00 2001 From: Tobias Tschech Date: Wed, 4 Apr 2012 15:22:33 +0300 Subject: Update system/libraries/Zip.php --- system/libraries/Zip.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 2ec7befd3..80438546b 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -304,8 +304,7 @@ class CI_Zip { } elseif (FALSE !== ($data = file_get_contents($path.$file))) { - $name = str_replace("\\", DIRECTORY_SEPARATOR, $path); - $name = str_replace("/", DIRECTORY_SEPARATOR, $path); + $name = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $path); if ($preserve_filepath === FALSE) { $name = str_replace($root_path, '', $name); -- cgit v1.2.3-24-g4f1b From 5d66f6554872e87f896daa8bf6f93e60b0fa34fa Mon Sep 17 00:00:00 2001 From: "M. Fauzilkamil Zainuddin" Date: Wed, 28 Mar 2012 16:02:23 +0800 Subject: Fixing user_guide compilation warnings --- user_guide_src/source/conf.py | 2 +- user_guide_src/source/libraries/form_validation.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py index 593ceaf1c..e972a388b 100644 --- a/user_guide_src/source/conf.py +++ b/user_guide_src/source/conf.py @@ -121,7 +121,7 @@ html_theme_path = ["./_themes"] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +#html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index ef4be5601..028b61c4c 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -608,7 +608,7 @@ call the reset_validation() function before setting up rules and validating the For more info please see the :ref:`function-reference` section below. --.. _saving-groups: +.. _saving-groups: ************************************************ Saving Sets of Validation Rules to a Config File @@ -977,7 +977,7 @@ $this->form_validation->set_data(); $_POST array. $this->form_validation->reset_validation(); -======================================== +=========================================== .. php:method:: reset_validation () -- cgit v1.2.3-24-g4f1b From 1f975cad332154f9b27159ba0fdc0ca8b174d82d Mon Sep 17 00:00:00 2001 From: "M. Fauzilkamil Zainuddin" Date: Wed, 28 Mar 2012 16:34:55 +0800 Subject: Fixing doc link in changelog --- user_guide_src/source/changelog.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 1c8647bb7..b3f6ced57 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -121,7 +121,12 @@ Release Date: Not Released - Changed the :doc:`Session Library ` to select only one row when using database sessions. - Added all_flashdata() method to session class. Returns an associative array of only flashdata. - Allowed for setting table class defaults in a config file. - - Added a Wincache driver to the `Caching Library `. + - Form Validation library now allows setting of error delimiters in the config file via $config['error_prefix'] and $config['error_suffix']. + - Added function error_array() to return all error messages as an array in the Form_validation class. + - Added function set_data() to Form_validation library, which can be used in place of the default $_POST array. + - Added function reset_validation() to form validation library, which resets internal validation variables in case of multiple validation routines. + - Changed the Session library to select only one row when using database sessions. + - Added a Wincache driver to the :doc:`Caching Library `. - Added dsn (delivery status notification) option to the :doc:`Email Library `. - Core -- cgit v1.2.3-24-g4f1b From a396c3bf6398d3d5631725078b81b8d2757481e2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 4 Apr 2012 18:57:39 +0300 Subject: Remove duplicate changelog entries introduced in pull #1225 --- user_guide_src/source/changelog.rst | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index b3f6ced57..189dccf0a 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -121,11 +121,6 @@ Release Date: Not Released - Changed the :doc:`Session Library ` to select only one row when using database sessions. - Added all_flashdata() method to session class. Returns an associative array of only flashdata. - Allowed for setting table class defaults in a config file. - - Form Validation library now allows setting of error delimiters in the config file via $config['error_prefix'] and $config['error_suffix']. - - Added function error_array() to return all error messages as an array in the Form_validation class. - - Added function set_data() to Form_validation library, which can be used in place of the default $_POST array. - - Added function reset_validation() to form validation library, which resets internal validation variables in case of multiple validation routines. - - Changed the Session library to select only one row when using database sessions. - Added a Wincache driver to the :doc:`Caching Library `. - Added dsn (delivery status notification) option to the :doc:`Email Library `. @@ -199,7 +194,7 @@ Bug fixes for 3.0 - Fixed a bug (#1238) - delete_all() in the `Database Caching Library ` used to delete .htaccess and index.html files, which is a potential security risk. - Fixed a bug in :doc:`Trackback Library ` method validate_url() where it didn't actually do anything, due to input not being passed by reference. - Fixed a bug (#11, #183, #863) - CI_Form_validation::_execute() silently continued to the next rule, if a rule method/function is not found. -- Fixed a bug (#1242) Added Windows path compatibility to function read_dir of ZIP library +- Fixed a bug (#1242) - read_dir() in the :doc:`Zip Library ` wasn't compatible with Windows. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From d294a58e1090819e7ce8701f54b80bca43bac6a6 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 4 Apr 2012 13:28:39 -0400 Subject: Make database config easier to work with --- application/config/database.php | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/application/config/database.php b/application/config/database.php index 744de0392..8c06dd2e6 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -75,23 +75,25 @@ $active_group = 'default'; $active_record = TRUE; -$db['default']['dsn'] = ''; -$db['default']['hostname'] = 'localhost'; -$db['default']['username'] = ''; -$db['default']['password'] = ''; -$db['default']['database'] = ''; -$db['default']['dbdriver'] = 'mysql'; -$db['default']['dbprefix'] = ''; -$db['default']['pconnect'] = FALSE; -$db['default']['db_debug'] = TRUE; -$db['default']['cache_on'] = FALSE; -$db['default']['cachedir'] = ''; -$db['default']['char_set'] = 'utf8'; -$db['default']['dbcollat'] = 'utf8_general_ci'; -$db['default']['swap_pre'] = ''; -$db['default']['autoinit'] = TRUE; -$db['default']['stricton'] = FALSE; -$db['default']['failover'] = array(); +$db['default'] = array( + 'dsn' => '', + 'hostname' => 'localhost', + 'username' => '', + 'password' => '', + 'database' => '', + 'dbdriver' => 'mysqli', + 'dbprefix' => '', + 'pconnect' => FALSE, + 'db_debug' => TRUE, + 'cache_on' => FALSE, + 'cachedir' => '', + 'char_set' => 'utf8', + 'dbcollat' => 'utf8_general_ci', + 'swap_pre' => '', + 'autoinit' => TRUE, + 'stricton' => FALSE, + 'failover' => array() +); /* End of file database.php */ /* Location: ./application/config/database.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b