diff options
Diffstat (limited to 'tests')
26 files changed, 481 insertions, 36 deletions
diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 99f145e427..1fba323277 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -10,7 +10,7 @@ define('IN_PHPBB', true); $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; -$table_prefix = ''; +$table_prefix = 'phpbb_'; error_reporting(E_ALL & ~E_DEPRECATED); diff --git a/tests/dbal/select_test.php b/tests/dbal/select_test.php index 987de5cbff..533416f14b 100644 --- a/tests/dbal/select_test.php +++ b/tests/dbal/select_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_dbal_select_test extends phpbb_database_test_case { diff --git a/tests/dbal/write_test.php b/tests/dbal/write_test.php index a24b6efcc4..4709d45fa5 100644 --- a/tests/dbal/write_test.php +++ b/tests/dbal/write_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_dbal_write_test extends phpbb_database_test_case { diff --git a/tests/mock/cache.php b/tests/mock/cache.php new file mode 100644 index 0000000000..2ac46f7090 --- /dev/null +++ b/tests/mock/cache.php @@ -0,0 +1,61 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2008 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +class phpbb_mock_cache +{ + public function __construct($data = array()) + { + $this->data = $data; + + if (!isset($this->data['_bots'])) + { + $this->data['_bots'] = array(); + } + } + + public function get($var_name) + { + if (isset($this->data[$var_name])) + { + return $this->data[$var_name]; + } + + return false; + } + + public function put($var_name, $var, $ttl = 0) + { + $this->data[$var_name] = $var; + } + + /** + * Obtain active bots + */ + public function obtain_bots() + { + return $this->data['_bots']; + } + + public function set_bots($bots) + { + $this->data['_bots'] = $bots; + } + + public function checkVar(PHPUnit_Framework_Assert $test, $var_name, $data) + { + $test->assertTrue(isset($this->data[$var_name])); + $test->assertEquals($data, $this->data[$var_name]); + } + + public function check(PHPUnit_Framework_Assert $test, $data) + { + $test->assertEquals($data, $this->data); + } +} + diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php new file mode 100644 index 0000000000..2d7d42f82a --- /dev/null +++ b/tests/mock/session_testable.php @@ -0,0 +1,56 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2008 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once '../phpBB/includes/functions.php'; +require_once '../phpBB/includes/session.php'; + +class phpbb_mock_session_testable extends session +{ + private $_cookies = array(); + + public function set_cookie($name, $data, $time) + { + $this->_cookies[$name] = array($data, $time); + } + + /** + * Checks if the cookies were set correctly. + * + * @param PHPUnit_Framework_Assert test The test from which this is called + * @param array(string => mixed) cookies The cookie data to check against. + * The keys are cookie names, the values can either be null to + * check only the existance of the cookie, or an array(d, t), + * where d is the cookie data to check, or null to skip the + * check and t is the cookie time to check, or null to skip. + */ + public function check_cookies(PHPUnit_Framework_Assert $test, $cookies) + { + $test->assertEquals(array_keys($cookies), array_keys($this->_cookies), 'Incorrect cookies were set'); + + foreach ($cookies as $name => $cookie) + { + if (!is_null($cookie)) + { + $data = $cookie[0]; + $time = $cookie[1]; + + if (!is_null($data)) + { + $test->assertEquals($data, $this->_cookies[$name][0], "Cookie $name contains incorrect data"); + } + + if (!is_null($time)) + { + $test->assertEquals($time, $this->_cookies[$name][1], "Cookie $name expires at the wrong time"); + } + } + } + } +} + diff --git a/tests/network/checkdnsrr_test.php b/tests/network/checkdnsrr_test.php index 9410deaf64..5a756dcef8 100644 --- a/tests/network/checkdnsrr_test.php +++ b/tests/network/checkdnsrr_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; /** * @group slow diff --git a/tests/random/gen_rand_string_test.php b/tests/random/gen_rand_string_test.php index fa519f134c..115c55e4e2 100644 --- a/tests/random/gen_rand_string_test.php +++ b/tests/random/gen_rand_string_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_random_gen_rand_string_test extends phpbb_test_case { diff --git a/tests/regex/censor_test.php b/tests/regex/censor_test.php index ae2d86e07e..fa9104e71d 100644 --- a/tests/regex/censor_test.php +++ b/tests/regex/censor_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_regex_censor_test extends phpbb_test_case { @@ -31,9 +31,19 @@ class phpbb_regex_censor_test extends phpbb_test_case /** * @dataProvider censor_test_data */ - public function test_censor($pattern, $subject) + public function test_censor_unicode($pattern, $subject) { - $regex = get_censor_preg_expression($pattern); + $regex = get_censor_preg_expression($pattern, true); + + $this->assertRegExp($regex, $subject); + } + + /** + * @dataProvider censor_test_data + */ + public function test_censor_no_unicode($pattern, $subject) + { + $regex = get_censor_preg_expression($pattern, false); $this->assertRegExp($regex, $subject); } diff --git a/tests/regex/email_test.php b/tests/regex/email_test.php index 5d6e207cbb..0695b801d5 100644 --- a/tests/regex/email_test.php +++ b/tests/regex/email_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_regex_email_test extends phpbb_test_case { diff --git a/tests/regex/ipv4_test.php b/tests/regex/ipv4_test.php index 735a2c4384..9829547508 100644 --- a/tests/regex/ipv4_test.php +++ b/tests/regex/ipv4_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_regex_ipv4_test extends phpbb_test_case { diff --git a/tests/regex/ipv6_test.php b/tests/regex/ipv6_test.php index 187588f861..1b2018403c 100644 --- a/tests/regex/ipv6_test.php +++ b/tests/regex/ipv6_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_regex_ipv6_test extends phpbb_test_case { diff --git a/tests/regex/url_test.php b/tests/regex/url_test.php index 246cbf549c..c3a336063a 100644 --- a/tests/regex/url_test.php +++ b/tests/regex/url_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_regex_url_test extends phpbb_test_case { diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php index 0901b43920..fa17b1909f 100644 --- a/tests/request/request_var_test.php +++ b/tests/request/request_var_test.php @@ -7,8 +7,8 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_request_request_var_test extends phpbb_test_case { diff --git a/tests/security/extract_current_page_test.php b/tests/security/extract_current_page_test.php index ff0ab4d1bb..71c7a3a397 100644 --- a/tests/security/extract_current_page_test.php +++ b/tests/security/extract_current_page_test.php @@ -7,10 +7,10 @@ * */ -require_once __DIR__ . '/base.php'; +require_once dirname(__FILE__) . '/base.php'; -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/session.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; class phpbb_security_extract_current_page_test extends phpbb_security_test_base { diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php index c53414e7df..70ba8527b1 100644 --- a/tests/security/redirect_test.php +++ b/tests/security/redirect_test.php @@ -7,10 +7,10 @@ * */ -require_once __DIR__ . '/base.php'; +require_once dirname(__FILE__) . '/base.php'; -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/session.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; class phpbb_security_redirect_test extends phpbb_security_test_base { diff --git a/tests/session/fixtures/sessions_empty.xml b/tests/session/fixtures/sessions_empty.xml new file mode 100644 index 0000000000..66fa585b18 --- /dev/null +++ b/tests/session/fixtures/sessions_empty.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_users"> + <column>user_id</column> + <column>username_clean</column> + <row> + <value>1</value> + <value>anonymous</value> + </row> + <row> + <value>3</value> + <value>foo</value> + </row> + <row> + <value>4</value> + <value>bar</value> + </row> + </table> +</dataset> diff --git a/tests/session/fixtures/sessions_full.xml b/tests/session/fixtures/sessions_full.xml new file mode 100644 index 0000000000..4559a08c55 --- /dev/null +++ b/tests/session/fixtures/sessions_full.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_users"> + <column>user_id</column> + <column>username_clean</column> + <row> + <value>1</value> + <value>anonymous</value> + </row> + <row> + <value>3</value> + <value>foo</value> + </row> + <row> + <value>4</value> + <value>bar</value> + </row> + </table> + <table name="phpbb_sessions"> + <column>session_id</column> + <column>session_user_id</column> + <column>session_ip</column> + <column>session_browser</column> + <row> + <value>anon_session</value> + <value>1</value> + <value>127.0.0.1</value> + <value>anonymous user agent</value> + </row> + <row> + <value>bar_session</value> + <value>4</value> + <value>127.0.0.1</value> + <value>user agent</value> + </row> + </table> +</dataset> diff --git a/tests/session/session_continue.php b/tests/session/session_continue.php new file mode 100644 index 0000000000..58956c18a9 --- /dev/null +++ b/tests/session/session_continue.php @@ -0,0 +1,117 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2008 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once 'test_framework/framework.php'; +require_once 'mock/cache.php'; +require_once 'mock/session_testable.php'; + +class phpbb_session_continue_test extends phpbb_database_test_case +{ + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_full.xml'); + } + + static public function session_begin_attempts() + { + return array( + array( + 'bar_session', '4', 'user agent', + array( + array('session_id' => 'anon_session', 'session_user_id' => 1), + array('session_id' => 'bar_session', 'session_user_id' => 4) + ), + array(), + 'Check if no new session was created', + ), + array( + 'anon_session', '4', 'user agent', + array( + array('session_id' => 'bar_session', 'session_user_id' => 4), + array('session_id' => null, 'session_user_id' => 1) // use generated SID + ), + array( + 'u' => array('1', null), + 'k' => array(null, null), + 'sid' => array($_SID, null), + ), + 'Check if an anonymous new session was created', + ), + ); + } + + /** + * @dataProvider session_begin_attempts + */ + public function test_session_begin_valid_session($session_id, $user_id, $user_agent, $expected_sessions, $expected_cookies, $message) + { + $session = new phpbb_mock_session_testable; + $session->page = array('page' => 'page', 'forum' => 0); + + // set up all the global variables used in session_create + global $SID, $_SID, $db, $config, $cache; + + $config = $this->get_config(); + $db = $this->new_dbal(); + $cache_data = array( + '_bots' => array(), + ); + $cache = new phpbb_mock_cache; + $SID = $_SID = null; + + $_COOKIE['_sid'] = $session_id; + $_COOKIE['_u'] = $user_id; + $_SERVER['HTTP_USER_AGENT'] = $user_agent; + + $config['session_length'] = time(); // need to do this to allow sessions started at time 0 + $session->session_begin(); + + $sql = 'SELECT session_id, session_user_id + FROM phpbb_sessions'; + + // little tickery to allow using a dataProvider with dynamic expected result + foreach ($expected_sessions as $i => $s) + { + if (is_null($s['session_id'])) + { + $expected_sessions[$i]['session_id'] = $session->session_id; + } + } + + $this->assertResultEquals( + $sql, + $expected_sessions, + 'Check if no new session was created' + ); + + $session->check_cookies($this, $expected_cookies); + + $cache->check($this, $cache_data); + } + static public function get_config() + { + return array( + 'allow_autologin' => false, + 'auth_method' => 'db', + 'forwarded_for_check' => true, + 'active_sessions' => 0, // disable + 'rand_seed' => 'foo', + 'rand_seed_last_update' => 0, + 'max_autologin_time' => 0, + 'session_length' => 100, + 'form_token_lifetime' => 100, + 'cookie_name' => '', + 'limit_load' => 0, + 'limit_search_load' => 0, + 'ip_check' => 3, + 'browser_check' => 1, + ); + } +} + diff --git a/tests/session/session_init.php b/tests/session/session_init.php new file mode 100644 index 0000000000..f6fa564880 --- /dev/null +++ b/tests/session/session_init.php @@ -0,0 +1,76 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2008 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once 'test_framework/framework.php'; +require_once 'mock/cache.php'; +require_once 'mock/session_testable.php'; + +class phpbb_session_init_test extends phpbb_database_test_case +{ + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); + } + + // also see security/extract_current_page.php + + public function test_login_session_create() + { + $session = new phpbb_mock_session_testable; + $session->page = array('page' => 'page', 'forum' => 0); + + // set up all the global variables used in session_create + global $SID, $_SID, $db, $config, $cache; + + $config = $this->get_config(); + $db = $this->new_dbal(); + $cache_data = array( + '_bots' => array(), + ); + $cache = new phpbb_mock_cache; + $SID = $_SID = null; + + $session->session_create(3); + + $sql = 'SELECT session_user_id + FROM phpbb_sessions'; + + $this->assertResultEquals( + $sql, + array(array('session_user_id' => 3)), + 'Check if exacly one session for user id 3 was created' + ); + + $cookie_expire = $session->time_now + (($config['max_autologin_time']) ? 86400 * (int) $config['max_autologin_time'] : 31536000); + + $session->check_cookies($this, array( + 'u' => array(null, $cookie_expire), + 'k' => array(null, $cookie_expire), + 'sid' => array($_SID, $cookie_expire), + )); + + $cache->check($this, $cache_data); + } + + static public function get_config() + { + return array( + 'allow_autologin' => false, + 'auth_method' => 'db', + 'forwarded_for_check' => true, + 'active_sessions' => 0, // disable + 'rand_seed' => 'foo', + 'rand_seed_last_update' => 0, + 'max_autologin_time' => 0, + 'session_length' => 100, + 'form_token_lifetime' => 100, + ); + } +} + diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 35df17e4c6..1b2f35f210 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -7,8 +7,8 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/template.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/template.php'; class phpbb_template_template_test extends phpbb_test_case { diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 9752ec2fe6..32d2696f1c 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -111,9 +111,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(__DIR__ . '/../test_config.php')) + else if (file_exists(dirname(__FILE__) . '/../test_config.php')) { - include(__DIR__ . '/../test_config.php'); + include(dirname(__FILE__) . '/../test_config.php'); return array( 'dbms' => $dbms, @@ -129,7 +129,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test // Silently use sqlite return array( 'dbms' => 'sqlite', - 'dbhost' => __DIR__ . '/../phpbb_unit_tests.sqlite2', // filename + 'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename 'dbport' => '', 'dbname' => '', 'dbuser' => '', @@ -340,7 +340,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test } } - $sql = $this->split_sql_file(file_get_contents(__DIR__ . "/../../phpBB/install/schemas/{$dbms['SCHEMA']}_schema.sql"), $config['dbms']); + $sql = $this->split_sql_file(file_get_contents(dirname(__FILE__) . "/../../phpBB/install/schemas/{$dbms['SCHEMA']}_schema.sql"), $config['dbms']); foreach ($sql as $query) { @@ -376,7 +376,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $config = $this->get_database_config(); - require_once __DIR__ . '/../../phpBB/includes/db/' . $config['dbms'] . '.php'; + require_once dirname(__FILE__) . '/../../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']); @@ -384,6 +384,17 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test return $db; } + public function assertSqlResultEquals($expected, $sql, $message = '') + { + $db = $this->new_dbal(); + + $result = $db->sql_query($sql); + $rows = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + $this->assertEquals($expected, $rows, $message); + } + public function setExpectedTriggerError($errno, $message = '') { $this->get_test_case_helpers()->setExpectedTriggerError($errno, $message); diff --git a/tests/text_processing/make_clickable_test.php b/tests/text_processing/make_clickable_test.php index 75a35daf82..29b982d709 100644 --- a/tests/text_processing/make_clickable_test.php +++ b/tests/text_processing/make_clickable_test.php @@ -7,8 +7,8 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; class phpbb_text_processing_make_clickable_test extends phpbb_test_case { diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php new file mode 100644 index 0000000000..6c60583a7b --- /dev/null +++ b/tests/user/lang_test.php @@ -0,0 +1,58 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; + +class phpbb_user_lang_test extends phpbb_test_case +{ + public function test_user_lang_sprintf() + { + $user = new user; + $user->lang = array( + 'FOO' => 'BAR', + 'BARZ' => 'PENG', + 'EMPTY' => '', + 'ZERO' => '0', + 'STR' => '%d %s, %d topics', + 'STR2' => '%d foos', + 'ARRY' => array( + 0 => 'No posts', // 0 + 1 => '1 post', // 1 + 2 => '%d posts', // 2+ + ), + ); + + // No param + $this->assertEquals($user->lang('FOO'), 'BAR'); + $this->assertEquals($user->lang('EMPTY'), ''); + $this->assertEquals($user->lang('ZERO'), '0'); + + // Invalid index + $this->assertEquals($user->lang('VOID'), 'VOID'); + + // Unnecessary param + $this->assertEquals($user->lang('FOO', 2), 'BAR'); + $this->assertEquals($user->lang('FOO', 2, 3), 'BAR'); + $this->assertEquals($user->lang('FOO', 2, 3, 'BARZ'), 'BAR'); + + // String + $this->assertEquals($user->lang('STR', 24, 'x', 42), '24 x, 42 topics'); + $this->assertEquals($user->lang('STR2', 64), '64 foos'); + + // Array + $this->assertEquals($user->lang('ARRY', 0), 'No posts'); + $this->assertEquals($user->lang('ARRY', 1), '1 post'); + $this->assertEquals($user->lang('ARRY', 2), '2 posts'); + $this->assertEquals($user->lang('ARRY', 123), '123 posts'); + + // Bug PHPBB3-9949 + $this->assertEquals($user->lang('ARRY', 1, 2), '1 post'); + $this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post'); + } +} diff --git a/tests/utf/normalizer_test.php b/tests/utf/normalizer_test.php index 9a9011c0fe..38b4ec1b6b 100644 --- a/tests/utf/normalizer_test.php +++ b/tests/utf/normalizer_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/utf/utf_normalizer.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_normalizer.php'; /** * @group slow @@ -16,8 +16,8 @@ class phpbb_utf_normalizer_test extends phpbb_test_case { static public function setUpBeforeClass() { - self::download('http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt', __DIR__.'/data'); - self::download('http://www.unicode.org/Public/UNIDATA/UnicodeData.txt', __DIR__.'/data'); + self::download('http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt', dirname(__FILE__).'/data'); + self::download('http://www.unicode.org/Public/UNIDATA/UnicodeData.txt', dirname(__FILE__).'/data'); } public function test_normalizer() @@ -62,7 +62,7 @@ class phpbb_utf_normalizer_test extends phpbb_test_case $tested_chars = array(); - $fp = fopen(__DIR__.'/data/NormalizationTest.txt', 'rb'); + $fp = fopen(dirname(__FILE__).'/data/NormalizationTest.txt', 'rb'); while (!feof($fp)) { $line = fgets($fp); @@ -117,7 +117,7 @@ class phpbb_utf_normalizer_test extends phpbb_test_case */ public function test_invariants(array $tested_chars) { - $fp = fopen(__DIR__.'/data/UnicodeData.txt', 'rb'); + $fp = fopen(dirname(__FILE__).'/data/UnicodeData.txt', 'rb'); while (!feof($fp)) { diff --git a/tests/utf/utf8_clean_string_test.php b/tests/utf/utf8_clean_string_test.php index 148297ad4b..e5a771eafa 100644 --- a/tests/utf/utf8_clean_string_test.php +++ b/tests/utf/utf8_clean_string_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; +require_once dirname(__FILE__) . '/../../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 fbc947b92a..03fa9dc38c 100644 --- a/tests/utf/utf8_wordwrap_test.php +++ b/tests/utf/utf8_wordwrap_test.php @@ -7,7 +7,7 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_utf_utf8_wordwrap_test extends phpbb_test_case { |