aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2018-12-03 00:23:35 +0100
committerVirtualTam <virtualtam@flibidi.net>2019-01-12 22:47:48 +0100
commitfb1b182fbf0ee5afed586f77eec84d7a906831ef (patch)
treea076afe14d039b0a02d1ecc64eb83e84698c3d1f /tests
parent00af48d9d20af1ce51c8ad42fe354fafc9ceb8a3 (diff)
downloadShaarli-fb1b182fbf0ee5afed586f77eec84d7a906831ef.tar.gz
Shaarli-fb1b182fbf0ee5afed586f77eec84d7a906831ef.tar.zst
Shaarli-fb1b182fbf0ee5afed586f77eec84d7a906831ef.zip
namespacing: \Shaarli\Http\Url
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/http/UrlTest.php (renamed from tests/Url/UrlTest.php)23
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/Url/UrlTest.php b/tests/http/UrlTest.php
index db229ce0..011b416d 100644
--- a/tests/Url/UrlTest.php
+++ b/tests/http/UrlTest.php
@@ -3,12 +3,13 @@
3 * Url's tests 3 * Url's tests
4 */ 4 */
5 5
6require_once 'application/Url.php'; 6namespace Shaarli\Http;
7
7 8
8/** 9/**
9 * Unitary tests for URL utilities 10 * Unitary tests for URL utilities
10 */ 11 */
11class UrlTest extends PHPUnit_Framework_TestCase 12class UrlTest extends \PHPUnit\Framework\TestCase
12{ 13{
13 // base URL for tests 14 // base URL for tests
14 protected static $baseUrl = 'http://domain.tld:3000'; 15 protected static $baseUrl = 'http://domain.tld:3000';
@@ -18,7 +19,7 @@ class UrlTest extends PHPUnit_Framework_TestCase
18 */ 19 */
19 private function assertUrlIsCleaned($query = '', $fragment = '') 20 private function assertUrlIsCleaned($query = '', $fragment = '')
20 { 21 {
21 $url = new Url(self::$baseUrl.$query.$fragment); 22 $url = new Url(self::$baseUrl . $query . $fragment);
22 $url->cleanup(); 23 $url->cleanup();
23 $this->assertEquals(self::$baseUrl, $url->toString()); 24 $this->assertEquals(self::$baseUrl, $url->toString());
24 } 25 }
@@ -38,7 +39,7 @@ class UrlTest extends PHPUnit_Framework_TestCase
38 public function testConstruct() 39 public function testConstruct()
39 { 40 {
40 $ref = 'http://username:password@hostname:9090/path' 41 $ref = 'http://username:password@hostname:9090/path'
41 .'?arg1=value1&arg2=value2#anchor'; 42 . '?arg1=value1&arg2=value2#anchor';
42 $url = new Url($ref); 43 $url = new Url($ref);
43 $this->assertEquals($ref, $url->toString()); 44 $this->assertEquals($ref, $url->toString());
44 } 45 }
@@ -52,7 +53,7 @@ class UrlTest extends PHPUnit_Framework_TestCase
52 $this->assertUrlIsCleaned(); 53 $this->assertUrlIsCleaned();
53 54
54 // URL with no annoying elements 55 // URL with no annoying elements
55 $ref = self::$baseUrl.'?p1=val1&p2=1234#edit'; 56 $ref = self::$baseUrl . '?p1=val1&p2=1234#edit';
56 $url = new Url($ref); 57 $url = new Url($ref);
57 $this->assertEquals($ref, $url->cleanup()); 58 $this->assertEquals($ref, $url->cleanup());
58 } 59 }
@@ -115,26 +116,26 @@ class UrlTest extends PHPUnit_Framework_TestCase
115 // ditch annoying query params and fragment, keep useful params 116 // ditch annoying query params and fragment, keep useful params
116 $url = new Url( 117 $url = new Url(
117 self::$baseUrl 118 self::$baseUrl
118 .'?fb=zomg&my=stuff&utm_medium=numnum&is=kept#tk.rss_all' 119 . '?fb=zomg&my=stuff&utm_medium=numnum&is=kept#tk.rss_all'
119 ); 120 );
120 $this->assertEquals(self::$baseUrl.'?my=stuff&is=kept', $url->cleanup()); 121 $this->assertEquals(self::$baseUrl . '?my=stuff&is=kept', $url->cleanup());
121 122
122 123
123 // ditch annoying query params, keep useful params and fragment 124 // ditch annoying query params, keep useful params and fragment
124 $url = new Url( 125 $url = new Url(
125 self::$baseUrl 126 self::$baseUrl
126 .'?fb=zomg&my=stuff&utm_medium=numnum&is=kept#again' 127 . '?fb=zomg&my=stuff&utm_medium=numnum&is=kept#again'
127 ); 128 );
128 $this->assertEquals( 129 $this->assertEquals(
129 self::$baseUrl.'?my=stuff&is=kept#again', 130 self::$baseUrl . '?my=stuff&is=kept#again',
130 $url->cleanup() 131 $url->cleanup()
131 ); 132 );
132 133
133 // test firefox reader url 134 // test firefox reader url
134 $url = new Url( 135 $url = new Url(
135 'about://reader?url=' . urlencode(self::$baseUrl .'?my=stuff&is=kept') 136 'about://reader?url=' . urlencode(self::$baseUrl . '?my=stuff&is=kept')
136 ); 137 );
137 $this->assertEquals(self::$baseUrl.'?my=stuff&is=kept', $url->cleanup()); 138 $this->assertEquals(self::$baseUrl . '?my=stuff&is=kept', $url->cleanup());
138 } 139 }
139 140
140 /** 141 /**