diff options
| author | Dhruv Goel <dhruv.goel92@gmail.com> | 2014-06-17 14:56:55 +0530 |
|---|---|---|
| committer | Dhruv Goel <dhruv.goel92@gmail.com> | 2014-06-17 14:56:55 +0530 |
| commit | 7ee3e3f73f2d602fd9eb0b67435aecb553c4b24d (patch) | |
| tree | ef8e88ccfa6ffd731850186288f6e99e362d89b9 /tests | |
| parent | 89af1150718a184249d8040637969b03a3003596 (diff) | |
| parent | f1adf82aeac76601bcf0a32e8be0298624520b35 (diff) | |
| download | forums-7ee3e3f73f2d602fd9eb0b67435aecb553c4b24d.tar forums-7ee3e3f73f2d602fd9eb0b67435aecb553c4b24d.tar.gz forums-7ee3e3f73f2d602fd9eb0b67435aecb553c4b24d.tar.bz2 forums-7ee3e3f73f2d602fd9eb0b67435aecb553c4b24d.tar.xz forums-7ee3e3f73f2d602fd9eb0b67435aecb553c4b24d.zip | |
Merge pull request #2588 from nickvergessen/ticket/12705
Ticket/12705 Fix make_clickable when called with different server_urls
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/text_processing/make_clickable_test.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/text_processing/make_clickable_test.php b/tests/text_processing/make_clickable_test.php index 2c78391453..95e304dd97 100644 --- a/tests/text_processing/make_clickable_test.php +++ b/tests/text_processing/make_clickable_test.php @@ -104,5 +104,50 @@ class phpbb_text_processing_make_clickable_test extends phpbb_test_case $this->assertEquals($expected, $result, $label); } + public function make_clickable_mixed_serverurl_data() + { + $urls = array( + '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' => 'm', 'url' => false, 'text' => false), + 'http://thisdomain.org/path/some?query=abc#test' => array('tag' => 'm', 'url' => false, 'text' => false), + + 'https://www.phpbb.com' => array('tag' => 'm', 'url' => false, 'text' => false), + 'https://www.phpbb.com/' => array('tag' => 'm', 'url' => false, 'text' => false), + 'https://www.phpbb.com/1' => array('tag' => 'l', 'url' => false, 'text' => '1'), + 'https://www.phpbb.com/path/some?query=abc#test' => array('tag' => 'l', 'url' => false, 'text' => 'path/some?query=abc#test'), + ); + + $test_data = array(); + + // run the test for each combination + foreach ($urls as $url => $url_type) + { + // 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 = '<!-- ' . $url_type['tag'] . ' --><a class="' . $class . '" href="' . $url_type['url'] . '">' . $url_type['text'] . '</a><!-- ' . $url_type['tag'] . ' -->'; + + $test_data[] = array($url, $output); + } + + return $test_data; + } + + /** + * @dataProvider make_clickable_mixed_serverurl_data + */ + public function test_make_clickable_mixed_serverurl($input, $expected) + { + $result = make_clickable($input, 'https://www.phpbb.com'); + + $label = 'Making text clickable: ' . $input; + $this->assertEquals($expected, $result, $label); + } + } |
