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 --- tests/text_processing/all_tests.php | 41 -------------------------------- tests/text_processing/make_clickable.php | 6 ++--- 2 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 tests/text_processing/all_tests.php (limited to 'tests/text_processing') 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 { -- cgit v1.2.1 From 01fe91c5c4e897801f5c179cd4060e686762f105 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 10 Jan 2011 00:18:37 +0100 Subject: [ticket/9987] Rename test files to include a _test suffix PHPBB3-9987 --- tests/text_processing/make_clickable.php | 104 -------------------------- tests/text_processing/make_clickable_test.php | 104 ++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 104 deletions(-) delete mode 100644 tests/text_processing/make_clickable.php create mode 100644 tests/text_processing/make_clickable_test.php (limited to 'tests/text_processing') diff --git a/tests/text_processing/make_clickable.php b/tests/text_processing/make_clickable.php deleted file mode 100644 index 75a35daf82..0000000000 --- a/tests/text_processing/make_clickable.php +++ /dev/null @@ -1,104 +0,0 @@ - whether it should work - $prefix_texts = array( - '' => true, - "np \n" => true, - 'bp text ' => true, - 'cp text>' => true, - 'ep text.' => array('w' => false), // doesn't work for www. type urls, but for everything else - ); - $suffix_texts = array( - '' => true, - "\n ns" => true, - ' bs text.' => true, - '>cs text' => true, - '"ds text' => true, - '. es text.' => true, - ', fs text.' => true, - ); - - $urls = array( - 'http://example.com' => array('tag' => 'm', 'url' => false, 'text' => false), // false means same as key - 'http://example.com/' => array('tag' => 'm', 'url' => false, 'text' => false), - 'http://example.com/path?query=abc' => array('tag' => 'm', 'url' => false, 'text' => false), - 'http://example.com/1' => array('tag' => 'm', 'url' => false, 'text' => false), - 'http://example.com/some/very/long/path/with/over/55/characters?and=a&long=query&too=1' => array('tag' => 'm', 'url' => false, 'text' => 'http://example.com/some/very/long/path/ ... uery&too=1'), - 'http://localhost' => array('tag' => 'm', 'url' => false, 'text' => false), - 'http://localhost/#abc' => array('tag' => 'm', 'url' => false, 'text' => false), - - 'www.example.com/path/' => array('tag' => 'w', 'url' => 'http://www.example.com/path/', 'text' => false), - 'randomwww.example.com/path/' => false, - - 'http://thisdomain.org' => array('tag' => 'm', 'url' => false, 'text' => false), - 'http://thisdomain.org/' => array('tag' => 'm', 'url' => false, 'text' => false), - 'http://thisdomain.org/1' => array('tag' => 'l', 'url' => false, 'text' => '1'), - 'http://thisdomain.org/path/some?query=abc#test' => array('tag' => 'l', 'url' => false, 'text' => 'path/some?query=abc#test'), - - 'javascript:www.example.com/' => false, - ); - - $test_data = array(); - - // run the test for each combination - foreach ($prefix_texts as $prefix => $prefix_success) - { - foreach ($suffix_texts as $suffix => $suffix_success) - { - foreach ($urls as $url => $url_type) - { - $input = $prefix . $url . $suffix; - // no valid url => no change - $output = $input; - - if ( - ($prefix_success && $suffix_success && is_array($url_type)) && - // handle except syntax for prefix/suffix - (!is_array($prefix_success) || !isset($prefix_success[$url_type['tag']]) || $prefix_success[$url_type['tag']] == true) && - (!is_array($suffix_success) || !isset($suffix_success[$url_type['tag']]) || $suffix_success[$url_type['tag']] == true) - ) - { - // false means it's the same as the url, less typing - $url_type['url'] = ($url_type['url']) ? $url_type['url'] : $url; - $url_type['text'] = ($url_type['text']) ? $url_type['text'] : $url; - - $class = ($url_type['tag'] === 'l') ? 'postlink-local' : 'postlink'; - - // replace the url with the desired output format - $output = $prefix . '' . $url_type['text'] . '' . $suffix; - } - $test_data[] = array($input, $output); - } - } - } - - return $test_data; - } - - /** - * @dataProvider make_clickable_data - */ - public function test_make_clickable($input, $expected) - { - $result = make_clickable($input, 'http://thisdomain.org'); - - $label = 'Making text clickable: ' . $input; - $this->assertEquals($expected, $result, $label); - } - -} - diff --git a/tests/text_processing/make_clickable_test.php b/tests/text_processing/make_clickable_test.php new file mode 100644 index 0000000000..75a35daf82 --- /dev/null +++ b/tests/text_processing/make_clickable_test.php @@ -0,0 +1,104 @@ + whether it should work + $prefix_texts = array( + '' => true, + "np \n" => true, + 'bp text ' => true, + 'cp text>' => true, + 'ep text.' => array('w' => false), // doesn't work for www. type urls, but for everything else + ); + $suffix_texts = array( + '' => true, + "\n ns" => true, + ' bs text.' => true, + '>cs text' => true, + '"ds text' => true, + '. es text.' => true, + ', fs text.' => true, + ); + + $urls = array( + 'http://example.com' => array('tag' => 'm', 'url' => false, 'text' => false), // false means same as key + 'http://example.com/' => array('tag' => 'm', 'url' => false, 'text' => false), + 'http://example.com/path?query=abc' => array('tag' => 'm', 'url' => false, 'text' => false), + 'http://example.com/1' => array('tag' => 'm', 'url' => false, 'text' => false), + 'http://example.com/some/very/long/path/with/over/55/characters?and=a&long=query&too=1' => array('tag' => 'm', 'url' => false, 'text' => 'http://example.com/some/very/long/path/ ... uery&too=1'), + 'http://localhost' => array('tag' => 'm', 'url' => false, 'text' => false), + 'http://localhost/#abc' => array('tag' => 'm', 'url' => false, 'text' => false), + + 'www.example.com/path/' => array('tag' => 'w', 'url' => 'http://www.example.com/path/', 'text' => false), + 'randomwww.example.com/path/' => false, + + 'http://thisdomain.org' => array('tag' => 'm', 'url' => false, 'text' => false), + 'http://thisdomain.org/' => array('tag' => 'm', 'url' => false, 'text' => false), + 'http://thisdomain.org/1' => array('tag' => 'l', 'url' => false, 'text' => '1'), + 'http://thisdomain.org/path/some?query=abc#test' => array('tag' => 'l', 'url' => false, 'text' => 'path/some?query=abc#test'), + + 'javascript:www.example.com/' => false, + ); + + $test_data = array(); + + // run the test for each combination + foreach ($prefix_texts as $prefix => $prefix_success) + { + foreach ($suffix_texts as $suffix => $suffix_success) + { + foreach ($urls as $url => $url_type) + { + $input = $prefix . $url . $suffix; + // no valid url => no change + $output = $input; + + if ( + ($prefix_success && $suffix_success && is_array($url_type)) && + // handle except syntax for prefix/suffix + (!is_array($prefix_success) || !isset($prefix_success[$url_type['tag']]) || $prefix_success[$url_type['tag']] == true) && + (!is_array($suffix_success) || !isset($suffix_success[$url_type['tag']]) || $suffix_success[$url_type['tag']] == true) + ) + { + // false means it's the same as the url, less typing + $url_type['url'] = ($url_type['url']) ? $url_type['url'] : $url; + $url_type['text'] = ($url_type['text']) ? $url_type['text'] : $url; + + $class = ($url_type['tag'] === 'l') ? 'postlink-local' : 'postlink'; + + // replace the url with the desired output format + $output = $prefix . '' . $url_type['text'] . '' . $suffix; + } + $test_data[] = array($input, $output); + } + } + } + + return $test_data; + } + + /** + * @dataProvider make_clickable_data + */ + public function test_make_clickable($input, $expected) + { + $result = make_clickable($input, 'http://thisdomain.org'); + + $label = 'Making text clickable: ' . $input; + $this->assertEquals($expected, $result, $label); + } + +} + -- cgit v1.2.1 From 14891cdf4ecf0e3ee164962be6685b8563f37a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Mon, 31 Jan 2011 12:58:18 +0100 Subject: [ticket/10011] Tests don't work on PHP < 5.3 Due to the usage of `__DIR__` for the file includes the tests can't be ran on systems with PHP < 5.3. Replace all occurances of `__DIR__` with `dirname(__FILE__)`. PHPBB3-10011 --- tests/text_processing/make_clickable_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/text_processing') 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 { -- cgit v1.2.1