aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/http/HttpUtils/IndexUrlTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/http/HttpUtils/IndexUrlTest.php')
-rw-r--r--tests/http/HttpUtils/IndexUrlTest.php68
1 files changed, 67 insertions, 1 deletions
diff --git a/tests/http/HttpUtils/IndexUrlTest.php b/tests/http/HttpUtils/IndexUrlTest.php
index bcbe59cb..f283d119 100644
--- a/tests/http/HttpUtils/IndexUrlTest.php
+++ b/tests/http/HttpUtils/IndexUrlTest.php
@@ -5,12 +5,14 @@
5 5
6namespace Shaarli\Http; 6namespace Shaarli\Http;
7 7
8use Shaarli\TestCase;
9
8require_once 'application/http/HttpUtils.php'; 10require_once 'application/http/HttpUtils.php';
9 11
10/** 12/**
11 * Unitary tests for index_url() 13 * Unitary tests for index_url()
12 */ 14 */
13class IndexUrlTest extends \PHPUnit\Framework\TestCase 15class IndexUrlTest extends TestCase
14{ 16{
15 /** 17 /**
16 * If on the main page, remove "index.php" from the URL resource 18 * If on the main page, remove "index.php" from the URL resource
@@ -71,4 +73,68 @@ class IndexUrlTest extends \PHPUnit\Framework\TestCase
71 ) 73 )
72 ); 74 );
73 } 75 }
76
77 /**
78 * The route is stored in REQUEST_URI
79 */
80 public function testPageUrlWithRoute()
81 {
82 $this->assertEquals(
83 'http://host.tld/picture-wall',
84 page_url(
85 array(
86 'HTTPS' => 'Off',
87 'SERVER_NAME' => 'host.tld',
88 'SERVER_PORT' => '80',
89 'SCRIPT_NAME' => '/index.php',
90 'REQUEST_URI' => '/picture-wall',
91 )
92 )
93 );
94
95 $this->assertEquals(
96 'http://host.tld/admin/picture-wall',
97 page_url(
98 array(
99 'HTTPS' => 'Off',
100 'SERVER_NAME' => 'host.tld',
101 'SERVER_PORT' => '80',
102 'SCRIPT_NAME' => '/admin/index.php',
103 'REQUEST_URI' => '/admin/picture-wall',
104 )
105 )
106 );
107 }
108
109 /**
110 * The route is stored in REQUEST_URI and subfolder
111 */
112 public function testPageUrlWithRouteUnderSubfolder()
113 {
114 $this->assertEquals(
115 'http://host.tld/subfolder/picture-wall',
116 page_url(
117 array(
118 'HTTPS' => 'Off',
119 'SERVER_NAME' => 'host.tld',
120 'SERVER_PORT' => '80',
121 'SCRIPT_NAME' => '/subfolder/index.php',
122 'REQUEST_URI' => '/subfolder/picture-wall',
123 )
124 )
125 );
126
127 $this->assertEquals(
128 'http://host.tld/subfolder/admin/picture-wall',
129 page_url(
130 array(
131 'HTTPS' => 'Off',
132 'SERVER_NAME' => 'host.tld',
133 'SERVER_PORT' => '80',
134 'SCRIPT_NAME' => '/subfolder/admin/index.php',
135 'REQUEST_URI' => '/subfolder/admin/picture-wall',
136 )
137 )
138 );
139 }
74} 140}