aboutsummaryrefslogtreecommitdiffstats
path: root/tests/text_processing/make_clickable.php
diff options
context:
space:
mode:
authorIgor Wiedler <igor@wiedler.ch>2011-01-10 00:18:37 +0100
committerIgor Wiedler <igor@wiedler.ch>2011-01-10 00:18:37 +0100
commit01fe91c5c4e897801f5c179cd4060e686762f105 (patch)
tree178535f1cecfa2fd5748b21f9d59d1d471d1bd35 /tests/text_processing/make_clickable.php
parent0a945100fd285658f1c3c936d413939eb11a6e16 (diff)
downloadforums-01fe91c5c4e897801f5c179cd4060e686762f105.tar
forums-01fe91c5c4e897801f5c179cd4060e686762f105.tar.gz
forums-01fe91c5c4e897801f5c179cd4060e686762f105.tar.bz2
forums-01fe91c5c4e897801f5c179cd4060e686762f105.tar.xz
forums-01fe91c5c4e897801f5c179cd4060e686762f105.zip
[ticket/9987] Rename test files to include a _test suffix
PHPBB3-9987
Diffstat (limited to 'tests/text_processing/make_clickable.php')
-rw-r--r--tests/text_processing/make_clickable.php104
1 files changed, 0 insertions, 104 deletions
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 @@
-<?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';
-require_once __DIR__ . '/../../phpBB/includes/functions_content.php';
-
-class phpbb_text_processing_make_clickable_test extends phpbb_test_case
-{
- public static function make_clickable_data()
- {
- // value => 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,
- '&gt;cs text' => true,
- '&quot;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&amp;long=query&amp;too=1' => array('tag' => 'm', 'url' => false, 'text' => 'http://example.com/some/very/long/path/ ... uery&amp;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['tag'] . ' --><a class="' . $class . '" href="' . $url_type['url'] . '">' . $url_type['text'] . '</a><!-- ' . $url_type['tag'] . ' -->' . $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);
- }
-
-}
-