aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/UtilsTest.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2015-11-26 23:05:58 +0100
committerVirtualTam <virtualtam@flibidi.net>2015-11-26 23:05:58 +0100
commit61873e3ded8dfba397b39aebd2322d0939c82caa (patch)
treea0cb54fb7223f23faa67bd90349a0981b9ef04e6 /tests/UtilsTest.php
parent657f0e25ba2c6f39775a8386b62d7c662ae709f7 (diff)
parent90e5bd65c9d4a5d3d5cedfeaa1314f2a15df5227 (diff)
downloadShaarli-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/UtilsTest.php')
-rw-r--r--tests/UtilsTest.php37
1 files changed, 37 insertions, 0 deletions
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 = '&nbsp; Are you &nbsp; thrilled &nbsp;by flags &nbsp; ?'. PHP_EOL .'&nbsp;Really?';
224 $processedText = space2nbsp($text);
225 $this->assertEquals($expectedText, $processedText);
226 }
190} 227}