diff options
Diffstat (limited to 'tests')
35 files changed, 561 insertions, 792 deletions
diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt index f1b40f71ad..ac07978d3e 100644 --- a/tests/RUNNING_TESTS.txt +++ b/tests/RUNNING_TESTS.txt @@ -1,33 +1,57 @@ Running Tests -------------- +============= 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. PHP extensions -============== +-------------- Unit tests use several PHP extensions that board code does not use. Currently the following PHP extensions must be installed and enabled to run unit tests: - ctype +Database Tests +-------------- +By default all tests requiring a database connection will use sqlite. If you +do not have sqlite installed the tests will be skipped. If you wish to run the +tests on a different database you have to create a test_config.php file within +your tests directory following the same format as phpBB's config.php. An example +for mysqli can be found below. More information on configuration options can be +found on the wiki (see below). + + <?php + $dbms = 'mysqli'; + $dbhost = 'localhost'; + $dbport = ''; + $dbname = 'database'; + $dbuser = 'user'; + $dbpasswd = 'password'; + +Alternatively you can specify parameters in the environment, so e.g. the following +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 + 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 ----------------- +================ Further information is available on phpbb wiki: http://wiki.phpbb.com/display/DEV/Unit+Tests 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 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2008 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License -* -*/ - -error_reporting(E_ALL); - -if (!defined('PHPUnit_MAIN_METHOD')) -{ - define('PHPUnit_MAIN_METHOD', 'phpbb_all_tests::main'); -} - -require_once 'test_framework/framework.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'utf/all_tests.php'; -require_once 'request/all_tests.php'; -require_once 'security/all_tests.php'; -require_once 'template/all_tests.php'; -require_once 'text_processing/all_tests.php'; -require_once 'dbal/all_tests.php'; -require_once 'regex/all_tests.php'; -require_once 'network/all_tests.php'; -require_once 'random/all_tests.php'; - -// exclude the test directory from code coverage reports -if (version_compare(PHPUnit_Runner_Version::id(), '3.5.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/test_framework/framework.php b/tests/bootstrap.php index 3a11cc6df9..99f145e427 100644 --- a/tests/test_framework/framework.php +++ b/tests/bootstrap.php @@ -8,10 +8,12 @@ */ define('IN_PHPBB', true); -$phpbb_root_path = '../phpBB/'; +$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', '>=')) { @@ -25,19 +27,6 @@ else 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/dbal/all_tests.php b/tests/dbal/all_tests.php deleted file mode 100644 index 7aee0f6b16..0000000000 --- a/tests/dbal/all_tests.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2008 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License -* -*/ - -if (!defined('PHPUnit_MAIN_METHOD')) -{ - define('PHPUnit_MAIN_METHOD', 'phpbb_dbal_all_tests::main'); -} - -require_once 'test_framework/framework.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'dbal/dbal.php'; - -class phpbb_dbal_all_tests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('phpBB Database Abstraction Layer'); - - $suite->addTestSuite('phpbb_dbal_test'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_dbal_all_tests::main') -{ - phpbb_dbal_all_tests::main(); -} diff --git a/tests/dbal/fixtures/config.xml b/tests/dbal/fixtures/config.xml new file mode 100644 index 0000000000..019f582a91 --- /dev/null +++ b/tests/dbal/fixtures/config.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_config"> + <column>config_name</column> + <column>config_value</column> + <column>is_dynamic</column> + <row> + <value>config1</value> + <value>foo</value> + <value>0</value> + </row> + <row> + <value>config2</value> + <value>bar</value> + <value>1</value> + </row> + </table> +</dataset> diff --git a/tests/dbal/dbal.php b/tests/dbal/select_test.php index 663323ad61..987de5cbff 100644 --- a/tests/dbal/dbal.php +++ b/tests/dbal/select_test.php @@ -7,10 +7,9 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; -class phpbb_dbal_test extends phpbb_database_test_case +class phpbb_dbal_select_test extends phpbb_database_test_case { public function getDataSet() { @@ -318,174 +317,4 @@ class phpbb_dbal_test extends phpbb_database_test_case $db->sql_freeresult($result); } - - public static function build_array_insert_data() - { - return array( - array(array( - 'config_name' => 'test_version', - 'config_value' => '0.0.0', - 'is_dynamic' => 1, - )), - array(array( - 'config_name' => 'second config', - 'config_value' => '10', - 'is_dynamic' => 0, - )), - ); - } - - /** - * @dataProvider build_array_insert_data - */ - public function test_build_array_insert($sql_ary) - { - $db = $this->new_dbal(); - - $sql = 'INSERT INTO phpbb_config ' . $db->sql_build_array('INSERT', $sql_ary); - $result = $db->sql_query($sql); - - $sql = "SELECT * - FROM phpbb_config - WHERE config_name = '" . $sql_ary['config_name'] . "'"; - $result = $db->sql_query_limit($sql, 1); - - $this->assertEquals($sql_ary, $db->sql_fetchrow($result)); - - $db->sql_freeresult($result); - } - - public static function delete_data() - { - return array( - array( - "WHERE config_name = 'test_version'", - array( - array( - 'config_name' => 'second config', - 'config_value' => '10', - 'is_dynamic' => 0, - ), - ), - ), - array( - '', - array(), - ), - ); - } - - /** - * @dataProvider delete_data - */ - public function test_delete($where, $expected) - { - $db = $this->new_dbal(); - - $sql = 'DELETE FROM phpbb_config - ' . $where; - $result = $db->sql_query($sql); - - $sql = 'SELECT * - FROM phpbb_config'; - $result = $db->sql_query($sql); - - $this->assertEquals($expected, $db->sql_fetchrowset($result)); - - $db->sql_freeresult($result); - } - - public function test_multiple_insert() - { - $db = $this->new_dbal(); - - $batch_ary = array( - array( - 'config_name' => 'batch one', - 'config_value' => 'b1', - 'is_dynamic' => 0, - ), - array( - 'config_name' => 'batch two', - 'config_value' => 'b2', - 'is_dynamic' => 1, - ), - ); - - $result = $db->sql_multi_insert('phpbb_config', $batch_ary); - - $sql = 'SELECT * - FROM phpbb_config - ORDER BY config_name ASC'; - $result = $db->sql_query($sql); - - $this->assertEquals($batch_ary, $db->sql_fetchrowset($result)); - - $db->sql_freeresult($result); - } - - public static function update_data() - { - return array( - array( - array( - 'config_value' => '20', - 'is_dynamic' => 0, - ), - " WHERE config_name = 'batch one'", - array( - array( - 'config_name' => 'batch one', - 'config_value' => '20', - 'is_dynamic' => 0, - ), - array( - 'config_name' => 'batch two', - 'config_value' => 'b2', - 'is_dynamic' => 1, - ), - ), - ), - array( - array( - 'config_value' => '0', - 'is_dynamic' => 1, - ), - '', - array( - array( - 'config_name' => 'batch one', - 'config_value' => '0', - 'is_dynamic' => 1, - ), - array( - 'config_name' => 'batch two', - 'config_value' => '0', - 'is_dynamic' => 1, - ), - ), - ), - ); - } - - /** - * @dataProvider update_data - */ - public function test_update($sql_ary, $where, $expected) - { - $db = $this->new_dbal(); - - $sql = 'UPDATE phpbb_config - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . $where; - $result = $db->sql_query($sql); - - $sql = 'SELECT * - FROM phpbb_config - ORDER BY config_name ASC'; - $result = $db->sql_query($sql); - - $this->assertEquals($expected, $db->sql_fetchrowset($result)); - - $db->sql_freeresult($result); - } } diff --git a/tests/dbal/write_test.php b/tests/dbal/write_test.php new file mode 100644 index 0000000000..a24b6efcc4 --- /dev/null +++ b/tests/dbal/write_test.php @@ -0,0 +1,171 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2008 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once __DIR__ . '/../../phpBB/includes/functions.php'; + +class phpbb_dbal_write_test extends phpbb_database_test_case +{ + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml'); + } + + public static function build_array_insert_data() + { + return array( + array(array( + 'config_name' => 'test_version', + 'config_value' => '0.0.0', + 'is_dynamic' => 1, + )), + array(array( + 'config_name' => 'second config', + 'config_value' => '10', + 'is_dynamic' => 0, + )), + ); + } + + /** + * @dataProvider build_array_insert_data + */ + public function test_build_array_insert($sql_ary) + { + $db = $this->new_dbal(); + + $sql = 'INSERT INTO phpbb_config ' . $db->sql_build_array('INSERT', $sql_ary); + $result = $db->sql_query($sql); + + $sql = "SELECT * + FROM phpbb_config + WHERE config_name = '" . $sql_ary['config_name'] . "'"; + $result = $db->sql_query_limit($sql, 1); + + $this->assertEquals($sql_ary, $db->sql_fetchrow($result)); + + $db->sql_freeresult($result); + } + + public function test_delete() + { + $db = $this->new_dbal(); + + $sql = "DELETE FROM phpbb_config + WHERE config_name = 'config1'"; + $result = $db->sql_query($sql); + + $sql = 'SELECT * + FROM phpbb_config'; + $result = $db->sql_query($sql); + $rows = $db->sql_fetchrowset($result); + + $this->assertEquals(1, sizeof($rows)); + $this->assertEquals('config2', $rows[0]['config_name']); + + $db->sql_freeresult($result); + } + + public function test_multiple_insert() + { + $db = $this->new_dbal(); + + // empty the table + $sql = 'DELETE FROM phpbb_config'; + $db->sql_query($sql); + + $batch_ary = array( + array( + 'config_name' => 'batch one', + 'config_value' => 'b1', + 'is_dynamic' => 0, + ), + array( + 'config_name' => 'batch two', + 'config_value' => 'b2', + 'is_dynamic' => 1, + ), + ); + + $result = $db->sql_multi_insert('phpbb_config', $batch_ary); + + $sql = 'SELECT * + FROM phpbb_config + ORDER BY config_name ASC'; + $result = $db->sql_query($sql); + + $this->assertEquals($batch_ary, $db->sql_fetchrowset($result)); + + $db->sql_freeresult($result); + } + + public static function update_data() + { + return array( + array( + array( + 'config_value' => '23', + 'is_dynamic' => 0, + ), + " WHERE config_name = 'config1'", + array( + array( + 'config_name' => 'config1', + 'config_value' => '23', + 'is_dynamic' => 0, + ), + array( + 'config_name' => 'config2', + 'config_value' => 'bar', + 'is_dynamic' => 1, + ), + ), + ), + array( + array( + 'config_value' => '0', + 'is_dynamic' => 1, + ), + '', + array( + array( + 'config_name' => 'config1', + 'config_value' => '0', + 'is_dynamic' => 1, + ), + array( + 'config_name' => 'config2', + 'config_value' => '0', + 'is_dynamic' => 1, + ), + ), + ), + ); + } + + /** + * @dataProvider update_data + */ + public function test_update($sql_ary, $where, $expected) + { + $db = $this->new_dbal(); + + $sql = 'UPDATE phpbb_config + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . $where; + $result = $db->sql_query($sql); + + $sql = 'SELECT * + FROM phpbb_config + ORDER BY config_name ASC'; + $result = $db->sql_query($sql); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + + $db->sql_freeresult($result); + } +} 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 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2010 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License -* -*/ - -if (!defined('PHPUnit_MAIN_METHOD')) -{ - define('PHPUnit_MAIN_METHOD', 'phpbb_network_all_tests::main'); -} - -require_once 'test_framework/framework.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'network/checkdnsrr.php'; - -class phpbb_network_all_tests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('phpBB Network Functions'); - - $suite->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_test.php index 57fe2761cc..427132e508 100644 --- a/tests/network/checkdnsrr.php +++ b/tests/network/checkdnsrr_test.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 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2010 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License -* -*/ - -if (!defined('PHPUnit_MAIN_METHOD')) -{ - define('PHPUnit_MAIN_METHOD', 'phpbb_random_all_tests::main'); -} - -require_once 'test_framework/framework.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'random/gen_rand_string.php'; - -class phpbb_random_all_tests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('phpBB Random Functions'); - - $suite->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_test.php index cd58d14ed3..fa519f134c 100644 --- a/tests/random/gen_rand_string.php +++ b/tests/random/gen_rand_string_test.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 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2010 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License -* -*/ - -if (!defined('PHPUnit_MAIN_METHOD')) -{ - define('PHPUnit_MAIN_METHOD', 'phpbb_regex_all_tests::main'); -} - -require_once 'test_framework/framework.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'regex/email.php'; -require_once 'regex/ipv4.php'; -require_once 'regex/ipv6.php'; -require_once 'regex/url.php'; - -class phpbb_regex_all_tests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('phpBB Regular Expressions'); - - $suite->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/censor_test.php b/tests/regex/censor_test.php new file mode 100644 index 0000000000..ae2d86e07e --- /dev/null +++ b/tests/regex/censor_test.php @@ -0,0 +1,40 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2010 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once __DIR__ . '/../../phpBB/includes/functions.php'; + +class phpbb_regex_censor_test extends phpbb_test_case +{ + public function censor_test_data() + { + return array( + array('bad*word', 'bad word'), + array('bad***word', 'bad word'), + array('bad**word', 'bad word'), + array('*bad*word*', 'bad word'), + array('b*d', 'bad'), + array('*bad*', 'bad'), + array('*b*d*', 'bad'), + array('*b*d*', 'b d'), + array('b*d*word', 'bad word'), + array('**b**d**word**', 'bad word'), + array('**b**d**word**', 'the bad word catched'), + ); + } + + /** + * @dataProvider censor_test_data + */ + public function test_censor($pattern, $subject) + { + $regex = get_censor_preg_expression($pattern); + + $this->assertRegExp($regex, $subject); + } +}
\ No newline at end of file diff --git a/tests/regex/email.php b/tests/regex/email_test.php index 8658b8af36..5d6e207cbb 100644 --- a/tests/regex/email.php +++ b/tests/regex/email_test.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_test.php index 9d131ad0ca..735a2c4384 100644 --- a/tests/regex/ipv4.php +++ b/tests/regex/ipv4_test.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_test.php index 3d7a72e492..187588f861 100644 --- a/tests/regex/ipv6.php +++ b/tests/regex/ipv6_test.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_test.php index 678b7d108f..246cbf549c 100644 --- a/tests/regex/url.php +++ b/tests/regex/url_test.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 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2008 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License -* -*/ - -if (!defined('PHPUnit_MAIN_METHOD')) -{ - define('PHPUnit_MAIN_METHOD', 'phpbb_request_all_tests::main'); -} - -require_once 'test_framework/framework.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'request/request_var.php'; - -class phpbb_request_all_tests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('phpBB Request Parameter Handling'); - - $suite->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_test.php index b1dacef3fd..0901b43920 100644 --- a/tests/request/request_var.php +++ b/tests/request/request_var_test.php @@ -7,8 +7,8 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_request_request_var_test extends phpbb_test_case { diff --git a/tests/security/all_tests.php b/tests/security/base.php index 8e3916733f..db9c884cf4 100644 --- a/tests/security/all_tests.php +++ b/tests/security/base.php @@ -7,18 +7,7 @@ * */ -if (!defined('PHPUnit_MAIN_METHOD')) -{ - define('PHPUnit_MAIN_METHOD', 'phpbb_security_all_tests::main'); -} - -require_once 'test_framework/framework.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'security/extract_current_page.php'; -require_once 'security/redirect.php'; - -class phpbb_security_all_tests extends PHPUnit_Framework_TestSuite +abstract class phpbb_security_test_base extends phpbb_test_case { /** * Set up the required user object and server variables for the suites @@ -62,25 +51,4 @@ class phpbb_security_all_tests extends PHPUnit_Framework_TestSuite 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/extract_current_page.php b/tests/security/extract_current_page_test.php index 8c72fe1440..ff0ab4d1bb 100644 --- a/tests/security/extract_current_page.php +++ b/tests/security/extract_current_page_test.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_test.php index 37b0a5bb41..c53414e7df 100644 --- a/tests/security/redirect.php +++ b/tests/security/redirect_test.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 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2008 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License -* -*/ - -if (!defined('PHPUnit_MAIN_METHOD')) -{ - define('PHPUnit_MAIN_METHOD', 'phpbb_template_all_tests::main'); -} - -require_once 'test_framework/framework.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'template/template.php'; - -class phpbb_template_all_tests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('phpBB Template Engine'); - - $suite->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_test.php index 024d3712f7..35df17e4c6 100644 --- a/tests/template/template.php +++ b/tests/template/template_test.php @@ -7,9 +7,8 @@ * */ -require_once 'test_framework/framework.php'; - -require_once '../phpBB/includes/template.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/template.php'; class phpbb_template_template_test extends phpbb_test_case { @@ -36,6 +35,7 @@ class phpbb_template_template_test extends phpbb_test_case // reset the error level even when an error occured // PHPUnit turns trigger_error into exceptions as well error_reporting($error_level); + ob_end_clean(); throw $exception; } 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 @@ -<?php - -echo "testing included php"; diff --git a/tests/template/templates/_dummy_include.php.inc b/tests/template/templates/_dummy_include.php.inc new file mode 100644 index 0000000000..aacb6b2045 --- /dev/null +++ b/tests/template/templates/_dummy_include.php.inc @@ -0,0 +1,3 @@ +<?php +// extension is .php.inc so PHPUnit ignores it +echo "testing included php"; diff --git a/tests/template/templates/includephp.html b/tests/template/templates/includephp.html index 3e13fa33fa..117d4273f0 100644 --- a/tests/template/templates/includephp.html +++ b/tests/template/templates/includephp.html @@ -1 +1 @@ -<!-- INCLUDEPHP ../templates/_dummy_include.php --> +<!-- INCLUDEPHP ../templates/_dummy_include.php.inc --> diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index f6bf420ebc..9752ec2fe6 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -9,14 +9,33 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_TestCase { + private static $already_connected; + protected $test_case_helpers; - public function init_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) { $this->test_case_helpers = new phpbb_test_case_helpers($this); } + + return $this->test_case_helpers; } public function get_dbms_data($dbms) @@ -50,7 +69,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test 'mssqlnative' => array( 'SCHEMA' => 'mssql', 'DELIM' => 'GO', - 'PDO' => 'odbc', + 'PDO' => 'sqlsrv', ), 'oracle' => array( 'SCHEMA' => 'oracle', @@ -79,6 +98,50 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test } } + public function get_database_config() + { + if (isset($_SERVER['PHPBB_TEST_DBMS'])) + { + return array( + 'dbms' => isset($_SERVER['PHPBB_TEST_DBMS']) ? $_SERVER['PHPBB_TEST_DBMS'] : '', + 'dbhost' => isset($_SERVER['PHPBB_TEST_DBHOST']) ? $_SERVER['PHPBB_TEST_DBHOST'] : '', + 'dbport' => isset($_SERVER['PHPBB_TEST_DBPORT']) ? $_SERVER['PHPBB_TEST_DBPORT'] : '', + 'dbname' => isset($_SERVER['PHPBB_TEST_DBNAME']) ? $_SERVER['PHPBB_TEST_DBNAME'] : '', + 'dbuser' => isset($_SERVER['PHPBB_TEST_DBUSER']) ? $_SERVER['PHPBB_TEST_DBUSER'] : '', + 'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : '', + ); + } + else if (file_exists(__DIR__ . '/../test_config.php')) + { + include(__DIR__ . '/../test_config.php'); + + return array( + 'dbms' => $dbms, + 'dbhost' => $dbhost, + 'dbport' => $dbport, + 'dbname' => $dbname, + 'dbuser' => $dbuser, + 'dbpasswd' => $dbpasswd, + ); + } + else if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>=')) + { + // Silently use sqlite + return array( + 'dbms' => 'sqlite', + 'dbhost' => __DIR__ . '/../phpbb_unit_tests.sqlite2', // filename + 'dbport' => '', + 'dbname' => '', + 'dbuser' => '', + 'dbpasswd' => '', + ); + } + else + { + $this->markTestSkipped('Missing test_config.php: See first error.'); + } + } + // NOTE: This function is not the same as split_sql_file from functions_install public function split_sql_file($sql, $dbms) { @@ -99,7 +162,8 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test if ($dbms == 'sqlite') { - // trim # off query to satisfy sqlite + // remove comment lines starting with # - they are not proper sqlite + // syntax and break sqlite2 foreach ($data as $i => $query) { $data[$i] = preg_replace('/^#.*$/m', "\n", $query); @@ -109,79 +173,198 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test return $data; } - public function getConnection() + /** + * Retrieves a list of all tables from the database. + * + * @param PDO $pdo + * @param string $dbms + * @return array(string) + */ + function get_tables($pdo, $dbms) { - static $already_connected; + switch ($pdo) + { + case 'mysql': + case 'mysql4': + case 'mysqli': + $sql = 'SHOW TABLES'; + break; + + case 'sqlite': + $sql = 'SELECT name + FROM sqlite_master + WHERE type = "table"'; + break; + + case 'mssql': + case 'mssql_odbc': + case 'mssqlnative': + $sql = "SELECT name + FROM sysobjects + WHERE type='U'"; + break; + + case 'postgres': + $sql = 'SELECT relname + FROM pg_stat_user_tables'; + break; - $this->init_test_case_helpers(); - $database_config = $this->test_case_helpers->get_database_config(); + case 'firebird': + $sql = 'SELECT rdb$relation_name + FROM rdb$relations + WHERE rdb$view_source is null + AND rdb$system_flag = 0'; + break; - $dbms_data = $this->get_dbms_data($database_config['dbms']); + case 'oracle': + $sql = 'SELECT table_name + FROM USER_TABLES'; + break; + } + + $result = $pdo->query($sql); - if ($already_connected) + $tables = array(); + while ($row = $result->fetch(PDO::FETCH_NUM)) { - if ($database_config['dbms'] == 'sqlite') - { - $pdo = new PDO($dbms_data['PDO'] . ':' . $database_config['dbhost']); - } - else - { - $pdo = new PDO($dbms_data['PDO'] . ':host=' . $database_config['dbhost'] . ';dbname=' . $database_config['dbname'], $database_config['dbuser'], $database_config['dbpasswd']); - } + $tables[] = current($row); } - else + + return $tables; + } + + /** + * Returns a PDO connection for the configured database. + * + * @param array $config The database configuration + * @param array $dbms Information on the used DBMS. + * @param bool $use_db Whether the DSN should be tied to a + * particular database making it impossible + * to delete that database. + * @return PDO The PDO database connection. + */ + public function new_pdo($config, $dbms, $use_db) + { + $dsn = $dbms['PDO'] . ':'; + + switch ($dbms['PDO']) { - if ($database_config['dbms'] == 'sqlite') - { - // delete existing database - if (file_exists($database_config['dbhost'])) + case 'sqlite2': + $dsn .= $config['dbhost']; + break; + + case 'sqlsrv': + // prefix the hostname (or DSN) with Server= so using just (local)\SQLExpress + // works for example, further parameters can still be appended using ;x=y + $dsn .= 'Server='; + // no break -> rest like ODBC + case 'odbc': + // for ODBC assume dbhost is a suitable DSN + // e.g. Driver={SQL Server Native Client 10.0};Server=(local)\SQLExpress; + $dsn .= $config['dbhost']; + + if ($use_db) { - unlink($database_config['dbhost']); + $dsn .= ';Database=' . $config['dbname']; } + break; - $pdo = new PDO($dbms_data['PDO'] . ':' . $database_config['dbhost']); - } - else - { - $pdo = new PDO($dbms_data['PDO'] . ':host=' . $database_config['dbhost'] . ';', $database_config['dbuser'], $database_config['dbpasswd']);try + default: + $dsn .= 'host=' . $config['dbhost']; + + if ($use_db) { - $pdo->exec('DROP DATABASE ' . $database_config['dbname']); + $dsn .= ';dbname=' . $config['dbname']; } - catch (PDOException $e){} // ignore non existent db - - $pdo->exec('CREATE DATABASE ' . $database_config['dbname']); + break; + } - $pdo = new PDO($dbms_data['PDO'] . ':host=' . $database_config['dbhost'] . ';dbname=' . $database_config['dbname'], $database_config['dbuser'], $database_config['dbpasswd']); - } + $pdo = new PDO($dsn, $config['dbuser'], $config['dbpasswd']);; - // good for debug - // $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + // good for debug + // $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - if ($database_config['dbms'] == 'mysql') - { - $sth = $pdo->query('SELECT VERSION() AS version'); - $row = $sth->fetch(PDO::FETCH_ASSOC); + return $pdo; + } - if (version_compare($row['version'], '4.1.3', '>=')) + private function recreate_db($config, $dbms) + { + switch ($config['dbms']) + { + case 'sqlite': + if (file_exists($config['dbhost'])) { - $dbms_data['SCHEMA'] .= '_41'; + unlink($config['dbhost']); } - else + break; + + default: + $pdo = $this->new_pdo($config, $dbms, false); + + try { - $dbms_data['SCHEMA'] .= '_40'; + $pdo->exec('DROP DATABASE ' . $config['dbname']); } + catch (PDOException $e) + { + // try to delete all tables if dropping the database was not possible. + foreach ($this->get_tables() as $table) + { + try + { + $pdo->exec('DROP TABLE ' . $table); + } + catch (PDOException $e){} // ignore non-existent tables + } + } - unset($row, $sth); - } + $pdo->exec('CREATE DATABASE ' . $config['dbname']); + break; + } + } - $sql_query = $this->split_sql_file(file_get_contents("../phpBB/install/schemas/{$dbms_data['SCHEMA']}_schema.sql"), $database_config['dbms']); + private function load_schema($pdo, $config, $dbms) + { + if ($config['dbms'] == 'mysql') + { + $sth = $pdo->query('SELECT VERSION() AS version'); + $row = $sth->fetch(PDO::FETCH_ASSOC); - foreach ($sql_query as $sql) + if (version_compare($row['version'], '4.1.3', '>=')) + { + $dbms['SCHEMA'] .= '_41'; + } + else { - $pdo->exec($sql); + $dbms['SCHEMA'] .= '_40'; } + } + + $sql = $this->split_sql_file(file_get_contents(__DIR__ . "/../../phpBB/install/schemas/{$dbms['SCHEMA']}_schema.sql"), $config['dbms']); + + foreach ($sql as $query) + { + $pdo->exec($query); + } + } + + public function getConnection() + { + $config = $this->get_database_config(); + $dbms = $this->get_dbms_data($config['dbms']); + + if (!self::$already_connected) + { + $this->recreate_db($config, $dbms); + } + + $pdo = $this->new_pdo($config, $dbms, true); - $already_connected = true; + if (!self::$already_connected) + { + $this->load_schema($pdo, $config, $dbms); + + self::$already_connected = true; } return $this->createDefaultDBConnection($pdo, 'testdb'); @@ -189,13 +372,20 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test public function new_dbal() { - $this->init_test_case_helpers(); - return $this->test_case_helpers->new_dbal(); + global $phpbb_root_path, $phpEx; + + $config = $this->get_database_config(); + + 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']); + + return $db; } public function setExpectedTriggerError($errno, $message = '') { - $this->init_test_case_helpers(); - $this->test_case_helpers->setExpectedTriggerError($errno, $message); + $this->get_test_case_helpers()->setExpectedTriggerError($errno, $message); } } diff --git a/tests/test_framework/phpbb_test_case.php b/tests/test_framework/phpbb_test_case.php index af867b29ff..f189da3671 100644 --- a/tests/test_framework/phpbb_test_case.php +++ b/tests/test_framework/phpbb_test_case.php @@ -11,17 +11,33 @@ class phpbb_test_case extends PHPUnit_Framework_TestCase { protected $test_case_helpers; - public function init_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) { $this->test_case_helpers = new phpbb_test_case_helpers($this); } + + return $this->test_case_helpers; } public function setExpectedTriggerError($errno, $message = '') { - $this->init_test_case_helpers(); - $this->test_case_helpers->setExpectedTriggerError($errno, $message); + $this->get_test_case_helpers()->setExpectedTriggerError($errno, $message); } } diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 7c026e496e..0acdce32e0 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -18,74 +18,6 @@ class phpbb_test_case_helpers $this->test_case = $test_case; } - public function get_database_config() - { - static $show_error = true; - - if (file_exists('test_config.php')) - { - include('test_config.php'); - - return array( - 'dbms' => $dbms, - 'dbhost' => $dbhost, - 'dbport' => $dbport, - 'dbname' => $dbname, - 'dbuser' => $dbuser, - 'dbpasswd' => $dbpasswd, - ); - } - else if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>=')) - { - // Silently use sqlite - return array( - 'dbms' => 'sqlite', - 'dbhost' => 'phpbb_unit_tests.sqlite2', // filename - 'dbport' => '', - 'dbname' => '', - 'dbuser' => '', - 'dbpasswd' => '', - ); - } - else - { - if ($show_error) - { - $show_error = false; - } - else - { - $this->test_case->markTestSkipped('Missing test_config.php: See first error.'); - return; - } - - trigger_error("You have to create a test_config.php like this: -\"<?php -\$dbms = 'mysqli'; -\$dbhost = 'localhost'; -\$dbport = ''; -\$dbname = 'database'; -\$dbuser = 'user'; -\$dbpasswd = 'password'; -\" - -NOTE: The database is dropped and recreated with the phpbb-db-schema! Do NOT specify a database with important data.", E_USER_ERROR); - } - } - - public function new_dbal() - { - global $phpbb_root_path, $phpEx; - $config = $this->get_database_config(); - - require_once '../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']); - - return $db; - } - public function setExpectedTriggerError($errno, $message = '') { $exceptionName = ''; 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 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2008 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License -* -*/ - -if (!defined('PHPUnit_MAIN_METHOD')) -{ - define('PHPUnit_MAIN_METHOD', 'phpbb_text_processing_all_tests::main'); -} - -require_once 'test_framework/framework.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'text_processing/make_clickable.php'; - -class phpbb_text_processing_all_tests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('phpBB Text Processing Tools'); - - $suite->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_test.php index a667dd705e..75a35daf82 100644 --- a/tests/text_processing/make_clickable.php +++ b/tests/text_processing/make_clickable_test.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 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2008 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License -* -*/ - -if (!defined('PHPUnit_MAIN_METHOD')) -{ - define('PHPUnit_MAIN_METHOD', 'phpbb_utf_all_tests::main'); -} - -require_once 'test_framework/framework.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -require_once 'utf/utf8_wordwrap_test.php'; -require_once 'utf/utf8_clean_string_test.php'; - -class phpbb_utf_all_tests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('phpBB Unicode Transformation Format'); - - $suite->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 { |