diff options
author | ArthurHoaro <arthur@hoa.ro> | 2019-02-09 13:52:12 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2019-02-09 13:55:11 +0100 |
commit | 520d29578c57e476ece3bdd20c286d196b7b61b4 (patch) | |
tree | 6f221285ec8e30d6ddfb32e996949738ebaa410a /tests/bookmark | |
parent | 905f8675a728841b03b300d2c7dc909a1c4f7f03 (diff) | |
download | Shaarli-520d29578c57e476ece3bdd20c286d196b7b61b4.tar.gz Shaarli-520d29578c57e476ece3bdd20c286d196b7b61b4.tar.zst Shaarli-520d29578c57e476ece3bdd20c286d196b7b61b4.zip |
Remove the redirector setting
Fixes #1239
Diffstat (limited to 'tests/bookmark')
-rw-r--r-- | tests/bookmark/LinkDBTest.php | 32 | ||||
-rw-r--r-- | tests/bookmark/LinkUtilsTest.php | 41 |
2 files changed, 7 insertions, 66 deletions
diff --git a/tests/bookmark/LinkDBTest.php b/tests/bookmark/LinkDBTest.php index ff5c0b97..2990a6b5 100644 --- a/tests/bookmark/LinkDBTest.php +++ b/tests/bookmark/LinkDBTest.php | |||
@@ -362,36 +362,6 @@ class LinkDBTest extends \PHPUnit\Framework\TestCase | |||
362 | } | 362 | } |
363 | 363 | ||
364 | /** | 364 | /** |
365 | * Test real_url without redirector. | ||
366 | */ | ||
367 | public function testLinkRealUrlWithoutRedirector() | ||
368 | { | ||
369 | $db = new LinkDB(self::$testDatastore, false, false); | ||
370 | foreach ($db as $link) { | ||
371 | $this->assertEquals($link['url'], $link['real_url']); | ||
372 | } | ||
373 | } | ||
374 | |||
375 | /** | ||
376 | * Test real_url with redirector. | ||
377 | */ | ||
378 | public function testLinkRealUrlWithRedirector() | ||
379 | { | ||
380 | $redirector = 'http://redirector.to?'; | ||
381 | $db = new LinkDB(self::$testDatastore, false, false, $redirector); | ||
382 | foreach ($db as $link) { | ||
383 | $this->assertStringStartsWith($redirector, $link['real_url']); | ||
384 | $this->assertNotFalse(strpos($link['real_url'], urlencode('://'))); | ||
385 | } | ||
386 | |||
387 | $db = new LinkDB(self::$testDatastore, false, false, $redirector, false); | ||
388 | foreach ($db as $link) { | ||
389 | $this->assertStringStartsWith($redirector, $link['real_url']); | ||
390 | $this->assertFalse(strpos($link['real_url'], urlencode('://'))); | ||
391 | } | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Test filter with string. | 365 | * Test filter with string. |
396 | */ | 366 | */ |
397 | public function testFilterString() | 367 | public function testFilterString() |
@@ -516,7 +486,7 @@ class LinkDBTest extends \PHPUnit\Framework\TestCase | |||
516 | public function testRenameTagCaseSensitive() | 486 | public function testRenameTagCaseSensitive() |
517 | { | 487 | { |
518 | self::$refDB->write(self::$testDatastore); | 488 | self::$refDB->write(self::$testDatastore); |
519 | $linkDB = new LinkDB(self::$testDatastore, true, false, ''); | 489 | $linkDB = new LinkDB(self::$testDatastore, true, false); |
520 | 490 | ||
521 | $res = $linkDB->renameTag('sTuff', 'Taz'); | 491 | $res = $linkDB->renameTag('sTuff', 'Taz'); |
522 | $this->assertEquals(1, count($res)); | 492 | $this->assertEquals(1, count($res)); |
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 | ||