aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/bookmark/LinkUtilsTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2019-02-24 11:29:56 +0100
committerGitHub <noreply@github.com>2019-02-24 11:29:56 +0100
commit015314f3c6a1ce0b2c45fdb2fb0d36a15cab10f5 (patch)
treec805547e171afd615b90486fa8bd7656f5fb9090 /tests/bookmark/LinkUtilsTest.php
parent0ee11e93907f0132e3b25a185093047bcd6b141d (diff)
parent520d29578c57e476ece3bdd20c286d196b7b61b4 (diff)
downloadShaarli-015314f3c6a1ce0b2c45fdb2fb0d36a15cab10f5.tar.gz
Shaarli-015314f3c6a1ce0b2c45fdb2fb0d36a15cab10f5.tar.zst
Shaarli-015314f3c6a1ce0b2c45fdb2fb0d36a15cab10f5.zip
Merge pull request #1269 from ArthurHoaro/feature/remove-redirector
Remove the redirector setting
Diffstat (limited to 'tests/bookmark/LinkUtilsTest.php')
-rw-r--r--tests/bookmark/LinkUtilsTest.php41
1 files changed, 6 insertions, 35 deletions
diff --git a/tests/bookmark/LinkUtilsTest.php b/tests/bookmark/LinkUtilsTest.php
index 1b8688e6..bd08f036 100644
--- a/tests/bookmark/LinkUtilsTest.php
+++ b/tests/bookmark/LinkUtilsTest.php
@@ -216,56 +216,27 @@ class LinkUtilsTest extends \PHPUnit\Framework\TestCase
216 } 216 }
217 217
218 /** 218 /**
219 * Test text2clickable without a redirector being set. 219 * Test text2clickable.
220 */ 220 */
221 public function testText2clickableWithoutRedirector() 221 public function testText2clickable()
222 { 222 {
223 $text = 'stuff http://hello.there/is=someone#here otherstuff'; 223 $text = 'stuff http://hello.there/is=someone#here otherstuff';
224 $expectedText = 'stuff <a href="http://hello.there/is=someone#here">' 224 $expectedText = 'stuff <a href="http://hello.there/is=someone#here">'
225 . 'http://hello.there/is=someone#here</a> otherstuff'; 225 . 'http://hello.there/is=someone#here</a> otherstuff';
226 $processedText = text2clickable($text, ''); 226 $processedText = text2clickable($text);
227 $this->assertEquals($expectedText, $processedText); 227 $this->assertEquals($expectedText, $processedText);
228 228
229 $text = 'stuff http://hello.there/is=someone#here(please) otherstuff'; 229 $text = 'stuff http://hello.there/is=someone#here(please) otherstuff';
230 $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)">' 230 $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)">'
231 . 'http://hello.there/is=someone#here(please)</a> otherstuff'; 231 . 'http://hello.there/is=someone#here(please)</a> otherstuff';
232 $processedText = text2clickable($text, ''); 232 $processedText = text2clickable($text);
233 $this->assertEquals($expectedText, $processedText); 233 $this->assertEquals($expectedText, $processedText);
234 234
235 $text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff'; 235 $text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff';
236 $text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff';
236 $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)&no">' 237 $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)&no">'
237 . 'http://hello.there/is=someone#here(please)&no</a> otherstuff'; 238 . 'http://hello.there/is=someone#here(please)&no</a> otherstuff';
238 $processedText = text2clickable($text, ''); 239 $processedText = text2clickable($text);
239 $this->assertEquals($expectedText, $processedText);
240 }
241
242 /**
243 * Test text2clickable with a redirector set.
244 */
245 public function testText2clickableWithRedirector()
246 {
247 $text = 'stuff http://hello.there/is=someone#here otherstuff';
248 $redirector = 'http://redirector.to';
249 $expectedText = 'stuff <a href="' .
250 $redirector .
251 urlencode('http://hello.there/is=someone#here') .
252 '">http://hello.there/is=someone#here</a> otherstuff';
253 $processedText = text2clickable($text, $redirector);
254 $this->assertEquals($expectedText, $processedText);
255 }
256
257 /**
258 * Test text2clickable a redirector set and without URL encode.
259 */
260 public function testText2clickableWithRedirectorDontEncode()
261 {
262 $text = 'stuff http://hello.there/?is=someone&or=something#here otherstuff';
263 $redirector = 'http://redirector.to';
264 $expectedText = 'stuff <a href="' .
265 $redirector .
266 'http://hello.there/?is=someone&or=something#here' .
267 '">http://hello.there/?is=someone&or=something#here</a> otherstuff';
268 $processedText = text2clickable($text, $redirector, false);
269 $this->assertEquals($expectedText, $processedText); 240 $this->assertEquals($expectedText, $processedText);
270 } 241 }
271 242