From 520d29578c57e476ece3bdd20c286d196b7b61b4 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 9 Feb 2019 13:52:12 +0100 Subject: Remove the redirector setting Fixes #1239 --- tests/bookmark/LinkDBTest.php | 32 +--------------------------- tests/bookmark/LinkUtilsTest.php | 41 ++++++------------------------------ tests/plugins/PluginMarkdownTest.php | 2 +- tests/updater/UpdaterTest.php | 19 +++++++++++++---- 4 files changed, 23 insertions(+), 71 deletions(-) (limited to 'tests') 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 @@ -361,36 +361,6 @@ class LinkDBTest extends \PHPUnit\Framework\TestCase ); } - /** - * Test real_url without redirector. - */ - public function testLinkRealUrlWithoutRedirector() - { - $db = new LinkDB(self::$testDatastore, false, false); - foreach ($db as $link) { - $this->assertEquals($link['url'], $link['real_url']); - } - } - - /** - * Test real_url with redirector. - */ - public function testLinkRealUrlWithRedirector() - { - $redirector = 'http://redirector.to?'; - $db = new LinkDB(self::$testDatastore, false, false, $redirector); - foreach ($db as $link) { - $this->assertStringStartsWith($redirector, $link['real_url']); - $this->assertNotFalse(strpos($link['real_url'], urlencode('://'))); - } - - $db = new LinkDB(self::$testDatastore, false, false, $redirector, false); - foreach ($db as $link) { - $this->assertStringStartsWith($redirector, $link['real_url']); - $this->assertFalse(strpos($link['real_url'], urlencode('://'))); - } - } - /** * Test filter with string. */ @@ -516,7 +486,7 @@ class LinkDBTest extends \PHPUnit\Framework\TestCase public function testRenameTagCaseSensitive() { self::$refDB->write(self::$testDatastore); - $linkDB = new LinkDB(self::$testDatastore, true, false, ''); + $linkDB = new LinkDB(self::$testDatastore, true, false); $res = $linkDB->renameTag('sTuff', 'Taz'); $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 } /** - * Test text2clickable without a redirector being set. + * Test text2clickable. */ - public function testText2clickableWithoutRedirector() + public function testText2clickable() { $text = 'stuff http://hello.there/is=someone#here otherstuff'; $expectedText = 'stuff ' . 'http://hello.there/is=someone#here otherstuff'; - $processedText = text2clickable($text, ''); + $processedText = text2clickable($text); $this->assertEquals($expectedText, $processedText); $text = 'stuff http://hello.there/is=someone#here(please) otherstuff'; $expectedText = 'stuff ' . 'http://hello.there/is=someone#here(please) otherstuff'; - $processedText = text2clickable($text, ''); + $processedText = text2clickable($text); $this->assertEquals($expectedText, $processedText); + $text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff'; $text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff'; $expectedText = 'stuff ' . 'http://hello.there/is=someone#here(please)&no otherstuff'; - $processedText = text2clickable($text, ''); - $this->assertEquals($expectedText, $processedText); - } - - /** - * Test text2clickable with a redirector set. - */ - public function testText2clickableWithRedirector() - { - $text = 'stuff http://hello.there/is=someone#here otherstuff'; - $redirector = 'http://redirector.to'; - $expectedText = 'stuff http://hello.there/is=someone#here otherstuff'; - $processedText = text2clickable($text, $redirector); - $this->assertEquals($expectedText, $processedText); - } - - /** - * Test text2clickable a redirector set and without URL encode. - */ - public function testText2clickableWithRedirectorDontEncode() - { - $text = 'stuff http://hello.there/?is=someone&or=something#here otherstuff'; - $redirector = 'http://redirector.to'; - $expectedText = 'stuff http://hello.there/?is=someone&or=something#here otherstuff'; - $processedText = text2clickable($text, $redirector, false); + $processedText = text2clickable($text); $this->assertEquals($expectedText, $processedText); } diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php index 5e7c02b0..9ddbc558 100644 --- a/tests/plugins/PluginMarkdownTest.php +++ b/tests/plugins/PluginMarkdownTest.php @@ -107,7 +107,7 @@ class PluginMarkdownTest extends \PHPUnit\Framework\TestCase public function testReverseText2clickable() { $text = 'stuff http://hello.there/is=someone#here otherstuff'; - $clickableText = text2clickable($text, ''); + $clickableText = text2clickable($text); $reversedText = reverse_text2clickable($clickableText); $this->assertEquals($text, $reversedText); } diff --git a/tests/updater/UpdaterTest.php b/tests/updater/UpdaterTest.php index d7df5963..93bc86c1 100644 --- a/tests/updater/UpdaterTest.php +++ b/tests/updater/UpdaterTest.php @@ -287,17 +287,14 @@ $GLOBALS[\'privateLinkByDefault\'] = true;'; $this->conf = new ConfigManager($sandbox); $title = ''; $headerLink = ''; - $redirectorUrl = ''; $this->conf->set('general.title', $title); $this->conf->set('general.header_link', $headerLink); - $this->conf->set('redirector.url', $redirectorUrl); $updater = new Updater(array(), array(), $this->conf, true); $done = $updater->updateMethodEscapeUnescapedConfig(); $this->assertTrue($done); $this->conf->reload(); $this->assertEquals(escape($title), $this->conf->get('general.title')); $this->assertEquals(escape($headerLink), $this->conf->get('general.header_link')); - $this->assertEquals(escape($redirectorUrl), $this->conf->get('redirector.url')); unlink($sandbox . '.json.php'); } @@ -707,7 +704,6 @@ $GLOBALS[\'privateLinkByDefault\'] = true;'; } /** -<<<<<<< HEAD * Test updateMethodWebThumbnailer with thumbnails enabled. */ public function testUpdateMethodWebThumbnailerEnabled() @@ -812,4 +808,19 @@ $GLOBALS[\'privateLinkByDefault\'] = true;'; $linkDB = new LinkDB(self::$testDatastore, true, false); $this->assertTrue($linkDB[1]['sticky']); } + + /** + * Test updateMethodRemoveRedirector(). + */ + public function testUpdateRemoveRedirector() + { + $sandboxConf = 'sandbox/config'; + copy(self::$configFile . '.json.php', $sandboxConf . '.json.php'); + $this->conf = new ConfigManager($sandboxConf); + $updater = new Updater([], null, $this->conf, true); + $this->assertTrue($updater->updateMethodRemoveRedirector()); + $this->assertFalse($this->conf->exists('redirector')); + $this->conf = new ConfigManager($sandboxConf); + $this->assertFalse($this->conf->exists('redirector')); + } } -- cgit v1.2.3