From 9a52bd030189280f48a35d3b9e52f9d77071cb5e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 3 Jan 2011 22:21:54 +0100 Subject: [task/phpunit-xml] Use phpunit.xml for test suite PHPBB3-9967 --- .gitignore | 1 + build/build.xml | 11 ++- phpunit.xml.dist | 34 +++++++++ tests/RUNNING_TESTS.txt | 8 +-- tests/all_tests.php | 69 ------------------ tests/bootstrap.php | 30 ++++++++ tests/dbal/all_tests.php | 42 ----------- tests/dbal/select.php | 3 +- tests/dbal/write.php | 3 +- tests/network/all_tests.php | 40 ----------- tests/network/checkdnsrr.php | 3 +- tests/random/all_tests.php | 40 ----------- tests/random/gen_rand_string.php | 3 +- tests/regex/all_tests.php | 46 ------------ tests/regex/email.php | 3 +- tests/regex/ipv4.php | 3 +- tests/regex/ipv6.php | 3 +- tests/regex/url.php | 3 +- tests/request/all_tests.php | 41 ----------- tests/request/request_var.php | 3 +- tests/security/all_tests.php | 86 ----------------------- tests/security/base.php | 54 ++++++++++++++ tests/security/extract_current_page.php | 8 +-- tests/security/redirect.php | 12 ++-- tests/template/all_tests.php | 40 ----------- tests/template/template.php | 4 +- tests/template/templates/_dummy_include.php | 3 - tests/template/templates/_dummy_include.php.inc | 3 + tests/template/templates/includephp.html | 2 +- tests/test_framework/framework.php | 43 ------------ tests/test_framework/phpbb_database_test_case.php | 10 +-- tests/text_processing/all_tests.php | 41 ----------- tests/text_processing/make_clickable.php | 6 +- tests/utf/all_tests.php | 43 ------------ tests/utf/utf8_clean_string_test.php | 3 +- tests/utf/utf8_wordwrap_test.php | 3 +- 36 files changed, 162 insertions(+), 588 deletions(-) create mode 100644 phpunit.xml.dist delete mode 100644 tests/all_tests.php create mode 100644 tests/bootstrap.php delete mode 100644 tests/dbal/all_tests.php delete mode 100644 tests/network/all_tests.php delete mode 100644 tests/random/all_tests.php delete mode 100644 tests/regex/all_tests.php delete mode 100644 tests/request/all_tests.php delete mode 100644 tests/security/all_tests.php create mode 100644 tests/security/base.php delete mode 100644 tests/template/all_tests.php delete mode 100644 tests/template/templates/_dummy_include.php create mode 100644 tests/template/templates/_dummy_include.php.inc delete mode 100644 tests/test_framework/framework.php delete mode 100644 tests/text_processing/all_tests.php delete mode 100644 tests/utf/all_tests.php diff --git a/.gitignore b/.gitignore index 871d17b386..39b9e0a7f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *~ +phpunit.xml phpBB/cache/*.php phpBB/config.php phpBB/files/* diff --git a/build/build.xml b/build/build.xml index 8d2afcb00c..8321edf374 100644 --- a/build/build.xml +++ b/build/build.xml @@ -42,12 +42,11 @@ - - + diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000000..e3416c6db3 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,34 @@ + + + + + + ./tests/ + + + + + + ./tests/ + ./phpBB/ + + + ./phpBB/includes/db/ + ./phpBB/includes/utf/utf_tools.php + ./phpBB/includes/functions.php + ./phpBB/includes/functions_content.php + ./phpBB/includes/session.php + ./phpBB/includes/template.php + + + diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt index 74a0635c1a..ac07978d3e 100644 --- a/tests/RUNNING_TESTS.txt +++ b/tests/RUNNING_TESTS.txt @@ -7,7 +7,7 @@ Prerequisites PHPUnit ------- -phpBB unit tests use PHPUnit framework. Version 3.3 or better is required +phpBB unit tests use PHPUnit framework. Version 3.5 or better is required to run the tests. PHPUnit prefers to be installed via PEAR; refer to http://www.phpunit.de/ for more information. @@ -41,14 +41,14 @@ will run phpunit with the same parameters as in the shown test_config.php file: $ PHPBB_TEST_DBMS='mysqli' PHPBB_TEST_DBHOST='localhost' \ PHPBB_TEST_DBNAME='database' PHPBB_TEST_DBUSER='user' \ - PHPBB_TEST_DBPASSWD='password' phpunit all_tests.php + PHPBB_TEST_DBPASSWD='password' phpunit Running ======= -Once the prerequisites are installed, run the tests from tests directory: +Once the prerequisites are installed, run the tests from the project root directory (above phpBB): - $ phpunit all_tests.php + $ phpunit More Information ================ diff --git a/tests/all_tests.php b/tests/all_tests.php deleted file mode 100644 index d1d711c4d7..0000000000 --- a/tests/all_tests.php +++ /dev/null @@ -1,69 +0,0 @@ -= 0) -{ - PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist('./'); -} -else -{ - PHPUnit_Util_Filter::addDirectoryToFilter('./'); -} - -class phpbb_all_tests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('phpBB'); - - $suite->addTest(phpbb_utf_all_tests::suite()); - $suite->addTest(phpbb_request_all_tests::suite()); - $suite->addTest(phpbb_security_all_tests::suite()); - $suite->addTest(phpbb_template_all_tests::suite()); - $suite->addTest(phpbb_text_processing_all_tests::suite()); - $suite->addTest(phpbb_dbal_all_tests::suite()); - $suite->addTest(phpbb_regex_all_tests::suite()); - $suite->addTest(phpbb_network_all_tests::suite()); - $suite->addTest(phpbb_random_all_tests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_all_tests::main') -{ - phpbb_all_tests::main(); -} - diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000000..9683ba0d47 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,30 @@ += 6.0.0 we do not need some code +if (version_compare(PHP_VERSION, '6.0.0-dev', '>=')) +{ + define('STRIP', false); +} +else +{ + @set_magic_quotes_runtime(0); + define('STRIP', (get_magic_quotes_gpc()) ? true : false); +} + +require_once $phpbb_root_path . 'includes/constants.php'; + +require_once 'test_framework/phpbb_test_case_helpers.php'; +require_once 'test_framework/phpbb_test_case.php'; +require_once 'test_framework/phpbb_database_test_case.php'; diff --git a/tests/dbal/all_tests.php b/tests/dbal/all_tests.php deleted file mode 100644 index cfa8176246..0000000000 --- a/tests/dbal/all_tests.php +++ /dev/null @@ -1,42 +0,0 @@ -addTestSuite('phpbb_dbal_select_test'); - $suite->addTestSuite('phpbb_dbal_write_test'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_dbal_all_tests::main') -{ - phpbb_dbal_all_tests::main(); -} diff --git a/tests/dbal/select.php b/tests/dbal/select.php index 70f27549d2..987de5cbff 100644 --- a/tests/dbal/select.php +++ b/tests/dbal/select.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_dbal_select_test extends phpbb_database_test_case { diff --git a/tests/dbal/write.php b/tests/dbal/write.php index 01deacda69..a24b6efcc4 100644 --- a/tests/dbal/write.php +++ b/tests/dbal/write.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_dbal_write_test extends phpbb_database_test_case { diff --git a/tests/network/all_tests.php b/tests/network/all_tests.php deleted file mode 100644 index b500647f81..0000000000 --- a/tests/network/all_tests.php +++ /dev/null @@ -1,40 +0,0 @@ -addTestSuite('phpbb_network_checkdnsrr_test'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_network_all_tests::main') -{ - phpbb_network_all_tests::main(); -} diff --git a/tests/network/checkdnsrr.php b/tests/network/checkdnsrr.php index 57fe2761cc..427132e508 100644 --- a/tests/network/checkdnsrr.php +++ b/tests/network/checkdnsrr.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_network_checkdnsrr_test extends phpbb_test_case { diff --git a/tests/random/all_tests.php b/tests/random/all_tests.php deleted file mode 100644 index c6ffe78024..0000000000 --- a/tests/random/all_tests.php +++ /dev/null @@ -1,40 +0,0 @@ -addTestSuite('phpbb_random_gen_rand_string_test'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_random_all_tests::main') -{ - phpbb_random_all_tests::main(); -} diff --git a/tests/random/gen_rand_string.php b/tests/random/gen_rand_string.php index cd58d14ed3..fa519f134c 100644 --- a/tests/random/gen_rand_string.php +++ b/tests/random/gen_rand_string.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_random_gen_rand_string_test extends phpbb_test_case { diff --git a/tests/regex/all_tests.php b/tests/regex/all_tests.php deleted file mode 100644 index 316a9d4a58..0000000000 --- a/tests/regex/all_tests.php +++ /dev/null @@ -1,46 +0,0 @@ -addTestSuite('phpbb_regex_email_test'); - $suite->addTestSuite('phpbb_regex_ipv4_test'); - $suite->addTestSuite('phpbb_regex_ipv6_test'); - $suite->addTestSuite('phpbb_regex_url_test'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_regex_all_tests::main') -{ - phpbb_regex_all_tests::main(); -} diff --git a/tests/regex/email.php b/tests/regex/email.php index 8658b8af36..5d6e207cbb 100644 --- a/tests/regex/email.php +++ b/tests/regex/email.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_regex_email_test extends phpbb_test_case { diff --git a/tests/regex/ipv4.php b/tests/regex/ipv4.php index 9d131ad0ca..735a2c4384 100644 --- a/tests/regex/ipv4.php +++ b/tests/regex/ipv4.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_regex_ipv4_test extends phpbb_test_case { diff --git a/tests/regex/ipv6.php b/tests/regex/ipv6.php index 3d7a72e492..187588f861 100644 --- a/tests/regex/ipv6.php +++ b/tests/regex/ipv6.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_regex_ipv6_test extends phpbb_test_case { diff --git a/tests/regex/url.php b/tests/regex/url.php index 678b7d108f..246cbf549c 100644 --- a/tests/regex/url.php +++ b/tests/regex/url.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_regex_url_test extends phpbb_test_case { diff --git a/tests/request/all_tests.php b/tests/request/all_tests.php deleted file mode 100644 index 1ee3029b36..0000000000 --- a/tests/request/all_tests.php +++ /dev/null @@ -1,41 +0,0 @@ -addTestSuite('phpbb_request_request_var_test'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_request_all_tests::main') -{ - phpbb_request_all_tests::main(); -} - diff --git a/tests/request/request_var.php b/tests/request/request_var.php index b1dacef3fd..804e5d6390 100644 --- a/tests/request/request_var.php +++ b/tests/request/request_var.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_request_request_var_test extends phpbb_test_case { diff --git a/tests/security/all_tests.php b/tests/security/all_tests.php deleted file mode 100644 index 8e3916733f..0000000000 --- a/tests/security/all_tests.php +++ /dev/null @@ -1,86 +0,0 @@ - gzip,deflate - [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 - DOCUMENT_ROOT] => /var/www/ - [SCRIPT_FILENAME] => /var/www/tests/index.php -*/ - - // Set no user and trick a bit to circumvent errors - $user = new user(); - $user->lang = true; - $user->browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : ''; - $user->referer = (!empty($_SERVER['HTTP_REFERER'])) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : ''; - $user->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : ''; - $user->host = (!empty($_SERVER['HTTP_HOST'])) ? (string) strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); - $user->page = session::extract_current_page($phpbb_root_path); - } - - protected function tearDown() - { - global $user; - $user = NULL; - } - - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - // I bet there is a better method calling this... :) - $suite = new phpbb_security_all_tests('phpBB Security Fixes'); - - $suite->addTestSuite('phpbb_security_extract_current_page_test'); - $suite->addTestSuite('phpbb_security_redirect_test'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_security_all_tests::main') -{ - phpbb_security_all_tests::main(); -} diff --git a/tests/security/base.php b/tests/security/base.php new file mode 100644 index 0000000000..db9c884cf4 --- /dev/null +++ b/tests/security/base.php @@ -0,0 +1,54 @@ + gzip,deflate + [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 + DOCUMENT_ROOT] => /var/www/ + [SCRIPT_FILENAME] => /var/www/tests/index.php +*/ + + // Set no user and trick a bit to circumvent errors + $user = new user(); + $user->lang = true; + $user->browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : ''; + $user->referer = (!empty($_SERVER['HTTP_REFERER'])) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : ''; + $user->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : ''; + $user->host = (!empty($_SERVER['HTTP_HOST'])) ? (string) strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); + $user->page = session::extract_current_page($phpbb_root_path); + } + + protected function tearDown() + { + global $user; + $user = NULL; + } +} diff --git a/tests/security/extract_current_page.php b/tests/security/extract_current_page.php index 8c72fe1440..ff0ab4d1bb 100644 --- a/tests/security/extract_current_page.php +++ b/tests/security/extract_current_page.php @@ -7,12 +7,12 @@ * */ -require_once 'test_framework/framework.php'; +require_once __DIR__ . '/base.php'; -require_once '../phpBB/includes/functions.php'; -require_once '../phpBB/includes/session.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/session.php'; -class phpbb_security_extract_current_page_test extends phpbb_test_case +class phpbb_security_extract_current_page_test extends phpbb_security_test_base { public static function security_variables() { diff --git a/tests/security/redirect.php b/tests/security/redirect.php index 37b0a5bb41..c53414e7df 100644 --- a/tests/security/redirect.php +++ b/tests/security/redirect.php @@ -7,12 +7,12 @@ * */ -require_once 'test_framework/framework.php'; +require_once __DIR__ . '/base.php'; -require_once '../phpBB/includes/functions.php'; -require_once '../phpBB/includes/session.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/session.php'; -class phpbb_security_redirect_test extends phpbb_test_case +class phpbb_security_redirect_test extends phpbb_security_test_base { public static function provider() { @@ -22,13 +22,15 @@ class phpbb_security_redirect_test extends phpbb_test_case array('bad://localhost/phpBB/index.php', 'Tried to redirect to potentially insecure url.', false), array('http://www.otherdomain.com/somescript.php', false, 'http://localhost/phpBB'), array("http://localhost/phpBB/memberlist.php\n\rConnection: close", 'Tried to redirect to potentially insecure url.', false), - array('javascript:test', false, 'http://localhost/phpBB/../tests/javascript:test'), + array('javascript:test', false, 'http://localhost/phpBB/../javascript:test'), array('http://localhost/phpBB/index.php;url=', 'Tried to redirect to potentially insecure url.', false), ); } protected function setUp() { + parent::setUp(); + $GLOBALS['config'] = array( 'force_server_vars' => '0', ); diff --git a/tests/template/all_tests.php b/tests/template/all_tests.php deleted file mode 100644 index ea258c1680..0000000000 --- a/tests/template/all_tests.php +++ /dev/null @@ -1,40 +0,0 @@ -addTestSuite('phpbb_template_template_test'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_template_all_tests::main') -{ - phpbb_template_all_tests::main(); -} diff --git a/tests/template/template.php b/tests/template/template.php index 0c2ca8a032..861adf63e8 100644 --- a/tests/template/template.php +++ b/tests/template/template.php @@ -7,9 +7,7 @@ * */ -require_once 'test_framework/framework.php'; - -require_once '../phpBB/includes/template.php'; +require_once __DIR__ . '/../../phpBB/includes/template.php'; class phpbb_template_template_test extends phpbb_test_case { diff --git a/tests/template/templates/_dummy_include.php b/tests/template/templates/_dummy_include.php deleted file mode 100644 index 1de5dddf59..0000000000 --- a/tests/template/templates/_dummy_include.php +++ /dev/null @@ -1,3 +0,0 @@ - + diff --git a/tests/test_framework/framework.php b/tests/test_framework/framework.php deleted file mode 100644 index 3a11cc6df9..0000000000 --- a/tests/test_framework/framework.php +++ /dev/null @@ -1,43 +0,0 @@ -= 6.0.0 we do not need some code -if (version_compare(PHP_VERSION, '6.0.0-dev', '>=')) -{ - define('STRIP', false); -} -else -{ - @set_magic_quotes_runtime(0); - define('STRIP', (get_magic_quotes_gpc()) ? true : false); -} - -require_once $phpbb_root_path . 'includes/constants.php'; - -// require at least PHPUnit 3.3.0 -require_once 'PHPUnit/Runner/Version.php'; -if (version_compare(PHPUnit_Runner_Version::id(), '3.3.0', '<')) -{ - trigger_error('PHPUnit >= 3.3.0 required'); -} - -if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0', '<')) -{ - require_once 'PHPUnit/Framework.php'; - require_once 'PHPUnit/Extensions/Database/TestCase.php'; -} - -require_once 'test_framework/phpbb_test_case_helpers.php'; -require_once 'test_framework/phpbb_test_case.php'; -require_once 'test_framework/phpbb_database_test_case.php'; diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index a64bae8c57..81c4a4f94e 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -96,9 +96,9 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test 'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : '', ); } - else if (file_exists('test_config.php')) + else if (file_exists(__DIR__ . '/../test_config.php')) { - include('test_config.php'); + include(__DIR__ . '/../test_config.php'); return array( 'dbms' => $dbms, @@ -114,7 +114,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test // Silently use sqlite return array( 'dbms' => 'sqlite', - 'dbhost' => 'phpbb_unit_tests.sqlite2', // filename + 'dbhost' => __DIR__ . '/../phpbb_unit_tests.sqlite2', // filename 'dbport' => '', 'dbname' => '', 'dbuser' => '', @@ -325,7 +325,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test } } - $sql = $this->split_sql_file(file_get_contents("../phpBB/install/schemas/{$dbms['SCHEMA']}_schema.sql"), $config['dbms']); + $sql = $this->split_sql_file(file_get_contents(__DIR__ . "/../../phpBB/install/schemas/{$dbms['SCHEMA']}_schema.sql"), $config['dbms']); foreach ($sql as $query) { @@ -361,7 +361,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $config = $this->get_database_config(); - require_once '../phpBB/includes/db/' . $config['dbms'] . '.php'; + require_once __DIR__ . '/../../phpBB/includes/db/' . $config['dbms'] . '.php'; $dbal = 'dbal_' . $config['dbms']; $db = new $dbal(); $db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']); diff --git a/tests/text_processing/all_tests.php b/tests/text_processing/all_tests.php deleted file mode 100644 index 5e759c72ee..0000000000 --- a/tests/text_processing/all_tests.php +++ /dev/null @@ -1,41 +0,0 @@ -addTestSuite('phpbb_text_processing_make_clickable_test'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_text_processing_all_tests::main') -{ - phpbb_text_processing_all_tests::main(); -} - diff --git a/tests/text_processing/make_clickable.php b/tests/text_processing/make_clickable.php index a667dd705e..75a35daf82 100644 --- a/tests/text_processing/make_clickable.php +++ b/tests/text_processing/make_clickable.php @@ -7,10 +7,8 @@ * */ -require_once 'test_framework/framework.php'; - -require_once '../phpBB/includes/functions.php'; -require_once '../phpBB/includes/functions_content.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; class phpbb_text_processing_make_clickable_test extends phpbb_test_case { diff --git a/tests/utf/all_tests.php b/tests/utf/all_tests.php deleted file mode 100644 index 0d5d44d695..0000000000 --- a/tests/utf/all_tests.php +++ /dev/null @@ -1,43 +0,0 @@ -addTestSuite('phpbb_utf_utf8_wordwrap_test'); - $suite->addTestSuite('phpbb_utf_utf8_clean_string_test'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_utf_all_tests::main') -{ - phpbb_utf_all_tests::main(); -} - diff --git a/tests/utf/utf8_clean_string_test.php b/tests/utf/utf8_clean_string_test.php index 870ad76fc4..148297ad4b 100644 --- a/tests/utf/utf8_clean_string_test.php +++ b/tests/utf/utf8_clean_string_test.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/utf/utf_tools.php'; +require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_utf_utf8_clean_string_test extends phpbb_test_case { diff --git a/tests/utf/utf8_wordwrap_test.php b/tests/utf/utf8_wordwrap_test.php index ef1165a897..fbc947b92a 100644 --- a/tests/utf/utf8_wordwrap_test.php +++ b/tests/utf/utf8_wordwrap_test.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/utf/utf_tools.php'; +require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_utf_utf8_wordwrap_test extends phpbb_test_case { -- cgit v1.2.1 From cdeffdd59f79310e68d8931e54877359ba58c8e1 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 5 Jan 2011 00:40:07 +0100 Subject: [ticket/9589] nginx.conf.sample -> nginx.sample.conf PHPBB3-9589 --- phpBB/docs/nginx.conf.sample | 70 -------------------------------------------- phpBB/docs/nginx.sample.conf | 70 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 70 deletions(-) delete mode 100644 phpBB/docs/nginx.conf.sample create mode 100644 phpBB/docs/nginx.sample.conf diff --git a/phpBB/docs/nginx.conf.sample b/phpBB/docs/nginx.conf.sample deleted file mode 100644 index a22a126ff4..0000000000 --- a/phpBB/docs/nginx.conf.sample +++ /dev/null @@ -1,70 +0,0 @@ -# Sample nginx configuration file for phpBB. -# Global settings have been removed, copy them -# from your system's nginx.conf. -# Tested with nginx 0.8.35. - -http { - # Compression - requires gzip and gzip static modules. - gzip on; - gzip_static on; - gzip_vary on; - gzip_http_version 1.1; - gzip_min_length 700; - gzip_comp_level 6; - gzip_disable "MSIE [1-6]\."; - - # Catch-all server for requests to invalid hosts. - # Also catches vulnerability scanners probing IP addresses. - # Should be first. - server { - listen 80; - server_name bogus; - return 444; - root /var/empty; - } - - # If you have domains with and without www prefix, - # redirect one to the other. - server { - listen 80; - server_name myforums.com; - rewrite ^(.*)$ http://www.myforums.com$1 permanent; - } - - # The actual board domain. - server { - listen 80; - server_name www.myforums.com; - - root /path/to/phpbb; - - location / { - # phpbb uses index.htm - index index.php index.html index.htm; - } - - # Deny access to internal phpbb files. - location ~ /(config\.php|common\.php|includes|cache|files|store|images/avatars/upload) { - deny all; - } - - # Pass the php scripts to fastcgi server specified in upstream declaration. - location ~ \.php$ { - fastcgi_pass php; - # Necessary for php. - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - # Unmodified fastcgi_params from nginx distribution. - include fastcgi_params; - } - - # Deny access to version control system directories. - location ~ /\.svn|/\.git { - deny all; - } - } - - # If running php as fastcgi, specify php upstream. - upstream php { - server unix:/tmp/php.sock; - } -} diff --git a/phpBB/docs/nginx.sample.conf b/phpBB/docs/nginx.sample.conf new file mode 100644 index 0000000000..a22a126ff4 --- /dev/null +++ b/phpBB/docs/nginx.sample.conf @@ -0,0 +1,70 @@ +# Sample nginx configuration file for phpBB. +# Global settings have been removed, copy them +# from your system's nginx.conf. +# Tested with nginx 0.8.35. + +http { + # Compression - requires gzip and gzip static modules. + gzip on; + gzip_static on; + gzip_vary on; + gzip_http_version 1.1; + gzip_min_length 700; + gzip_comp_level 6; + gzip_disable "MSIE [1-6]\."; + + # Catch-all server for requests to invalid hosts. + # Also catches vulnerability scanners probing IP addresses. + # Should be first. + server { + listen 80; + server_name bogus; + return 444; + root /var/empty; + } + + # If you have domains with and without www prefix, + # redirect one to the other. + server { + listen 80; + server_name myforums.com; + rewrite ^(.*)$ http://www.myforums.com$1 permanent; + } + + # The actual board domain. + server { + listen 80; + server_name www.myforums.com; + + root /path/to/phpbb; + + location / { + # phpbb uses index.htm + index index.php index.html index.htm; + } + + # Deny access to internal phpbb files. + location ~ /(config\.php|common\.php|includes|cache|files|store|images/avatars/upload) { + deny all; + } + + # Pass the php scripts to fastcgi server specified in upstream declaration. + location ~ \.php$ { + fastcgi_pass php; + # Necessary for php. + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + # Unmodified fastcgi_params from nginx distribution. + include fastcgi_params; + } + + # Deny access to version control system directories. + location ~ /\.svn|/\.git { + deny all; + } + } + + # If running php as fastcgi, specify php upstream. + upstream php { + server unix:/tmp/php.sock; + } +} -- cgit v1.2.1 From b720edb05bafb1a5f75da049226c2c8270511f92 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 7 Jan 2011 00:16:28 +0100 Subject: [task/phpunit-xml] Force error reporting level E_ALL | ~E_DEPRECATED. PHPBB3-9967 --- tests/bootstrap.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 9683ba0d47..99f145e427 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,6 +12,8 @@ $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; $table_prefix = ''; +error_reporting(E_ALL & ~E_DEPRECATED); + // If we are on PHP >= 6.0.0 we do not need some code if (version_compare(PHP_VERSION, '6.0.0-dev', '>=')) { -- cgit v1.2.1 From b4f95deefc9d456c5a2d0f6338f6dcecc0829652 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 7 Jan 2011 00:29:44 +0100 Subject: [task/phpunit-xml] Only blacklist the tests directory and do not whitelist. It would be ideal if we could whitelist the entire phpBB directory or at least includes, but at present that still breaks because of classes with the same name. PHPBB3-9967 --- phpunit.xml.dist | 9 --------- 1 file changed, 9 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e3416c6db3..d1d8adbdd5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -20,15 +20,6 @@ ./tests/ - ./phpBB/ - - ./phpBB/includes/db/ - ./phpBB/includes/utf/utf_tools.php - ./phpBB/includes/functions.php - ./phpBB/includes/functions_content.php - ./phpBB/includes/session.php - ./phpBB/includes/template.php - -- cgit v1.2.1 From b48b90977382e936a4d98981e55b02c8e574e07b Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 7 Jan 2011 01:07:21 +0100 Subject: [task/phpunit-xml] Manually blacklisting a few PHPUnit classes from backups. The blacklisting of these static variables is necessary because code coverage will otherwise consume too much memory. The problem did not exist in earlier PHPUnit versions because all classes beginning with PHPUnit are automatically blacklisted, and code coverage as well as a few other internal classes were still internal parts of PHPunit. These were now moved to PHP_ namespace, causing the problem with backupStaticAttributes. PHPBB3-9967 --- tests/test_framework/phpbb_database_test_case.php | 15 +++++++++++++++ tests/test_framework/phpbb_test_case.php | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 81c4a4f94e..9752ec2fe6 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -13,6 +13,21 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test protected $test_case_helpers; + public function __construct($name = NULL, array $data = array(), $dataName = '') + { + parent::__construct($name, $data, $dataName); + $this->backupStaticAttributesBlacklist += array( + 'PHP_CodeCoverage' => array('instance'), + 'PHP_CodeCoverage_Filter' => array('instance'), + 'PHP_CodeCoverage_Util' => array('ignoredLines', 'templateMethods'), + 'PHP_Timer' => array('startTimes',), + 'PHP_Token_Stream' => array('customTokens'), + 'PHP_Token_Stream_CachingFactory' => array('cache'), + + 'phpbb_database_test_case' => array('already_connected'), + ); + } + public function get_test_case_helpers() { if (!$this->test_case_helpers) diff --git a/tests/test_framework/phpbb_test_case.php b/tests/test_framework/phpbb_test_case.php index fe90d321dc..f189da3671 100644 --- a/tests/test_framework/phpbb_test_case.php +++ b/tests/test_framework/phpbb_test_case.php @@ -11,6 +11,21 @@ class phpbb_test_case extends PHPUnit_Framework_TestCase { protected $test_case_helpers; + public function __construct($name = NULL, array $data = array(), $dataName = '') + { + parent::__construct($name, $data, $dataName); + $this->backupStaticAttributesBlacklist += array( + 'PHP_CodeCoverage' => array('instance'), + 'PHP_CodeCoverage_Filter' => array('instance'), + 'PHP_CodeCoverage_Util' => array('ignoredLines', 'templateMethods'), + 'PHP_Timer' => array('startTimes',), + 'PHP_Token_Stream' => array('customTokens'), + 'PHP_Token_Stream_CachingFactory' => array('cache'), + + 'phpbb_database_test_case' => array('already_connected'), + ); + } + public function get_test_case_helpers() { if (!$this->test_case_helpers) -- cgit v1.2.1