diff options
| -rw-r--r-- | .travis.yml | 2 | ||||
| -rw-r--r-- | phpBB/includes/functions_user.php | 4 | ||||
| -rw-r--r-- | phpBB/styles/prosilver/template/forum_fn.js | 2 | ||||
| -rw-r--r-- | tests/functional/common_groups_test.php | 18 | ||||
| -rw-r--r-- | tests/functions/fixtures/style_select.xml | 4 | ||||
| -rw-r--r-- | tests/functions/validate_hex_colour_test.php | 121 | ||||
| -rw-r--r-- | tests/test_framework/phpbb_database_test_connection_manager.php | 14 | ||||
| -rw-r--r-- | tests/user/fixtures/user_loader.xml | 16 |
8 files changed, 163 insertions, 18 deletions
diff --git a/.travis.yml b/.travis.yml index 8039e1d47e..c89ad38661 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ before_script: - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS phpbb_tests;'; fi" - travis/install-php-extensions.sh - cd phpBB - - php ../composer.phar install --dev + - php ../composer.phar install --dev --no-interaction --prefer-source - cd .. - sh -c "if [ `php -r "echo (int) version_compare(PHP_VERSION, '5.3.19', '>=');"` = "1" ]; then travis/setup-webserver.sh; fi" diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 9a2ad4c25f..7b11e4f01b 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1330,7 +1330,7 @@ function validate_data($data, $val_ary) { $function = array_shift($validate); array_unshift($validate, $data[$var]); - $function_prefix = (function_exists('phpbb_validate_' . $function)) ? 'phpbb_validate_' : 'validate'; + $function_prefix = (function_exists('phpbb_validate_' . $function)) ? 'phpbb_validate_' : 'validate_'; if ($result = call_user_func_array($function_prefix . $function, $validate)) { @@ -2009,7 +2009,7 @@ function validate_jabber($jid) */ function phpbb_validate_hex_colour($colour, $optional = false) { - if (empty($colour)) + if ($colour === '') { return (($optional) ? false : 'WRONG_DATA'); } diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index ef6b7de418..bb29f00490 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -364,7 +364,7 @@ function submit_default_button(event, selector, class_name) { * The non-jQuery code is a mimick of the jQuery code ;) */ function apply_onkeypress_event() { - jQuery('form input[type=text], form input[type=password]').live('keypress', function (e) { + jQuery('form input[type=text], form input[type=password]').on('keypress', function (e) { var default_button = jQuery(this).parents('form').find('input[type=submit].default-submit-action'); if (!default_button || default_button.length <= 0) { diff --git a/tests/functional/common_groups_test.php b/tests/functional/common_groups_test.php index 0bee9ca527..cc6afa54b9 100644 --- a/tests/functional/common_groups_test.php +++ b/tests/functional/common_groups_test.php @@ -17,21 +17,11 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test public function groups_manage_test_data() { return array( - array('#AA0000', 'WRONG_DATA_COLOUR'), - array('AA0000', 'GROUP_UPDATED'), - array('AA0000v', 'WRONG_DATA_COLOUR'), - array('AA00000', 'WRONG_DATA_COLOUR'), - array('vAA0000', 'WRONG_DATA_COLOUR'), - array('AAG000','WRONG_DATA_COLOUR'), - array('a00', 'GROUP_UPDATED'), - array('ag0', 'WRONG_DATA_COLOUR'), - array('#aa0', 'WRONG_DATA_COLOUR'), - array('AA0000 ', 'GROUP_UPDATED'), - array('AA0000 abf', 'WRONG_DATA_COLOUR'), - array('AA0000 AA0000', 'WRONG_DATA_COLOUR'), array('', 'GROUP_UPDATED'), - array('000', 'GROUP_UPDATED'), - array('000000', 'GROUP_UPDATED'), + array('aa0000', 'GROUP_UPDATED'), + + array('AAG000','WRONG_DATA_COLOUR'), + array('#AA0000', 'WRONG_DATA_COLOUR'), ); } diff --git a/tests/functions/fixtures/style_select.xml b/tests/functions/fixtures/style_select.xml index 12d6392ab5..ca95f94461 100644 --- a/tests/functions/fixtures/style_select.xml +++ b/tests/functions/fixtures/style_select.xml @@ -4,20 +4,24 @@ <column>style_id</column> <column>style_name</column> <column>style_active</column> + <column>style_parent_tree</column> <row> <value>1</value> <value>prosilver</value> <value>1</value> + <value></value> </row> <row> <value>2</value> <value>subsilver2</value> <value>1</value> + <value></value> </row> <row> <value>3</value> <value>zoo</value> <value>0</value> + <value></value> </row> </table> </dataset> diff --git a/tests/functions/validate_hex_colour_test.php b/tests/functions/validate_hex_colour_test.php new file mode 100644 index 0000000000..812ebe5eeb --- /dev/null +++ b/tests/functions/validate_hex_colour_test.php @@ -0,0 +1,121 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; + +class phpbb_functions_validate_hex_colour_test extends phpbb_test_case +{ + public function positive_match_data() + { + return array( + array('a00'), + array('AFF'), + array('AA0000'), + array('aa00FF'), + array('000'), + array('000000'), + ); + } + + public function negative_match_data() + { + return array( + // Invalid prefix + array('#aa0'), + array('#AA0000'), + array('vAA0000'), + + // Invalid suffix + array('AA0000v'), + + // Correct length, but out of hex range + array('ag0'), + array('AAG000'), + + // Too long + array('AA00000'), + array('AA0000 '), + array('AA0000 abf'), + array('AA0000 AA0000'), + + // empty() + array('0'), + ); + } + + public function optional_only_data() + { + return array( + // The empty colour, i.e. "no colour". + array(''), + ); + } + + public function strict_negative_match_data() + { + return array_merge( + $this->negative_match_data(), + $this->optional_only_data() + ); + } + + public function nonstrict_positive_match_data() + { + return array_merge( + $this->positive_match_data(), + $this->optional_only_data() + ); + } + + /** + * @dataProvider positive_match_data + */ + public function test_strict_positive_match($input) + { + $this->assertFalse( + phpbb_validate_hex_colour($input, false), + "Failed asserting that $input passes as a valid hex colour." + ); + } + + /** + * @dataProvider strict_negative_match_data + */ + public function test_strict_negative_match($input) + { + $this->assertSame( + 'WRONG_DATA', + phpbb_validate_hex_colour($input, false), + "Failed asserting that $input does not pass as a valid hex colour." + ); + } + + /** + * @dataProvider nonstrict_positive_match_data + */ + public function test_nonstrict_positive_match($input) + { + $this->assertFalse( + phpbb_validate_hex_colour($input, true), + "Failed asserting that $input passes as a valid or optional hex colour." + ); + } + + /** + * @dataProvider negative_match_data + */ + public function test_nonstrict_negative_match($input) + { + $this->assertSame( + 'WRONG_DATA', + phpbb_validate_hex_colour($input, true), + "Failed asserting that $input does not pass as a valid or optional hex colour." + ); + } +} diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index a192d2922f..6bf73dcfa4 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -148,6 +148,20 @@ class phpbb_database_test_connection_manager case 'phpbb_db_driver_mysql': case 'phpbb_db_driver_mysqli': $this->pdo->exec('SET NAMES utf8'); + + /* + * The phpBB MySQL drivers set the STRICT_ALL_TABLES and + * STRICT_TRANS_TABLES flags/modes, so as a minimum requirement + * we want to make sure those are set for the PDO side of the + * test suite. + * + * The TRADITIONAL flag implies STRICT_ALL_TABLES and + * STRICT_TRANS_TABLES as well as other useful strictness flags + * the phpBB MySQL driver does not set. + */ + $this->pdo->exec("SET SESSION sql_mode='TRADITIONAL'"); + break; + default: } } diff --git a/tests/user/fixtures/user_loader.xml b/tests/user/fixtures/user_loader.xml index 737376f326..1fed8b5838 100644 --- a/tests/user/fixtures/user_loader.xml +++ b/tests/user/fixtures/user_loader.xml @@ -2,22 +2,38 @@ <dataset> <table name="phpbb_users"> <column>user_id</column> + <column>user_permissions</column> <column>username</column> <column>username_clean</column> + <column>user_sig</column> + <column>user_occ</column> + <column>user_interests</column> <row> <value>1</value> + <value></value> <value>Guest</value> <value>guest</value> + <value></value> + <value></value> + <value></value> </row> <row> <value>2</value> + <value></value> <value>Admin</value> <value>admin</value> + <value></value> + <value></value> + <value></value> </row> <row> <value>3</value> + <value></value> <value>Test</value> <value>test</value> + <value></value> + <value></value> + <value></value> </row> </table> </dataset> |
