diff options
author | VirtualTam <virtualtam@flibidi.net> | 2015-11-26 23:05:58 +0100 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2015-11-26 23:05:58 +0100 |
commit | 61873e3ded8dfba397b39aebd2322d0939c82caa (patch) | |
tree | a0cb54fb7223f23faa67bd90349a0981b9ef04e6 /tests | |
parent | 657f0e25ba2c6f39775a8386b62d7c662ae709f7 (diff) | |
parent | 90e5bd65c9d4a5d3d5cedfeaa1314f2a15df5227 (diff) | |
download | Shaarli-61873e3ded8dfba397b39aebd2322d0939c82caa.tar.gz Shaarli-61873e3ded8dfba397b39aebd2322d0939c82caa.tar.zst Shaarli-61873e3ded8dfba397b39aebd2322d0939c82caa.zip |
Merge pull request #355 from ArthurHoaro/redirector-url
URL encode links when a redirector is set
Diffstat (limited to 'tests')
-rw-r--r-- | tests/LinkDBTest.php | 23 | ||||
-rw-r--r-- | tests/UtilsTest.php | 37 | ||||
-rw-r--r-- | tests/plugins/PlugQrcodeTest.php | 4 |
3 files changed, 62 insertions, 2 deletions
diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php index 8929713d..ff917f6d 100644 --- a/tests/LinkDBTest.php +++ b/tests/LinkDBTest.php | |||
@@ -511,4 +511,27 @@ class LinkDBTest extends PHPUnit_Framework_TestCase | |||
511 | sizeof(self::$publicLinkDB->filterFullText('free software')) | 511 | sizeof(self::$publicLinkDB->filterFullText('free software')) |
512 | ); | 512 | ); |
513 | } | 513 | } |
514 | |||
515 | /** | ||
516 | * Test real_url without redirector. | ||
517 | */ | ||
518 | public function testLinkRealUrlWithoutRedirector() | ||
519 | { | ||
520 | $db = new LinkDB(self::$testDatastore, false, false); | ||
521 | foreach($db as $link) { | ||
522 | $this->assertEquals($link['url'], $link['real_url']); | ||
523 | } | ||
524 | } | ||
525 | |||
526 | /** | ||
527 | * Test real_url with redirector. | ||
528 | */ | ||
529 | public function testLinkRealUrlWithRedirector() | ||
530 | { | ||
531 | $redirector = 'http://redirector.to?'; | ||
532 | $db = new LinkDB(self::$testDatastore, false, false, $redirector); | ||
533 | foreach($db as $link) { | ||
534 | $this->assertStringStartsWith($redirector, $link['real_url']); | ||
535 | } | ||
536 | } | ||
514 | } | 537 | } |
diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index 4847ea94..02eecda2 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php | |||
@@ -187,4 +187,41 @@ class UtilsTest extends PHPUnit_Framework_TestCase | |||
187 | is_session_id_valid('c0ZqcWF3VFE2NmJBdm1HMVQ0ZHJ3UmZPbTFsNGhkNHI=') | 187 | is_session_id_valid('c0ZqcWF3VFE2NmJBdm1HMVQ0ZHJ3UmZPbTFsNGhkNHI=') |
188 | ); | 188 | ); |
189 | } | 189 | } |
190 | |||
191 | /** | ||
192 | * Test text2clickable without a redirector being set. | ||
193 | */ | ||
194 | public function testText2clickableWithoutRedirector() | ||
195 | { | ||
196 | $text = 'stuff http://hello.there/is=someone#here otherstuff'; | ||
197 | $expectedText = 'stuff <a href="http://hello.there/is=someone#here">http://hello.there/is=someone#here</a> otherstuff'; | ||
198 | $processedText = text2clickable($text, ''); | ||
199 | $this->assertEquals($expectedText, $processedText); | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * Test text2clickable a redirector set. | ||
204 | */ | ||
205 | public function testText2clickableWithRedirector() | ||
206 | { | ||
207 | $text = 'stuff http://hello.there/is=someone#here otherstuff'; | ||
208 | $redirector = 'http://redirector.to'; | ||
209 | $expectedText = 'stuff <a href="'. | ||
210 | $redirector . | ||
211 | urlencode('http://hello.there/is=someone#here') . | ||
212 | '">http://hello.there/is=someone#here</a> otherstuff'; | ||
213 | $processedText = text2clickable($text, $redirector); | ||
214 | $this->assertEquals($expectedText, $processedText); | ||
215 | } | ||
216 | |||
217 | /** | ||
218 | * Test testSpace2nbsp. | ||
219 | */ | ||
220 | public function testSpace2nbsp() | ||
221 | { | ||
222 | $text = ' Are you thrilled by flags ?'. PHP_EOL .' Really?'; | ||
223 | $expectedText = ' Are you thrilled by flags ?'. PHP_EOL .' Really?'; | ||
224 | $processedText = space2nbsp($text); | ||
225 | $this->assertEquals($expectedText, $processedText); | ||
226 | } | ||
190 | } | 227 | } |
diff --git a/tests/plugins/PlugQrcodeTest.php b/tests/plugins/PlugQrcodeTest.php index 86dc7f29..c749fa86 100644 --- a/tests/plugins/PlugQrcodeTest.php +++ b/tests/plugins/PlugQrcodeTest.php | |||
@@ -30,7 +30,7 @@ class PlugQrcodeTest extends PHPUnit_Framework_TestCase | |||
30 | 'title' => $str, | 30 | 'title' => $str, |
31 | 'links' => array( | 31 | 'links' => array( |
32 | array( | 32 | array( |
33 | 'url' => $str, | 33 | 'real_url' => $str, |
34 | ) | 34 | ) |
35 | ) | 35 | ) |
36 | ); | 36 | ); |
@@ -39,7 +39,7 @@ class PlugQrcodeTest extends PHPUnit_Framework_TestCase | |||
39 | $link = $data['links'][0]; | 39 | $link = $data['links'][0]; |
40 | // data shouldn't be altered | 40 | // data shouldn't be altered |
41 | $this->assertEquals($str, $data['title']); | 41 | $this->assertEquals($str, $data['title']); |
42 | $this->assertEquals($str, $link['url']); | 42 | $this->assertEquals($str, $link['real_url']); |
43 | 43 | ||
44 | // plugin data | 44 | // plugin data |
45 | $this->assertEquals(1, count($link['link_plugin'])); | 45 | $this->assertEquals(1, count($link['link_plugin'])); |