aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/http/HttpUtils/PageUrlTest.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2018-12-03 00:34:53 +0100
committerVirtualTam <virtualtam@flibidi.net>2019-01-12 22:47:48 +0100
commit51753e403fa69c0ce124ede27d300477e3e799ca (patch)
tree0afe2a84598648b49cc53bb3e8640569ac370240 /tests/http/HttpUtils/PageUrlTest.php
parentfb1b182fbf0ee5afed586f77eec84d7a906831ef (diff)
downloadShaarli-51753e403fa69c0ce124ede27d300477e3e799ca.tar.gz
Shaarli-51753e403fa69c0ce124ede27d300477e3e799ca.tar.zst
Shaarli-51753e403fa69c0ce124ede27d300477e3e799ca.zip
namespacing: move HTTP utilities along \Shaarli\Http\ classes
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'tests/http/HttpUtils/PageUrlTest.php')
-rw-r--r--tests/http/HttpUtils/PageUrlTest.php78
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/http/HttpUtils/PageUrlTest.php b/tests/http/HttpUtils/PageUrlTest.php
new file mode 100644
index 00000000..f1991716
--- /dev/null
+++ b/tests/http/HttpUtils/PageUrlTest.php
@@ -0,0 +1,78 @@
1<?php
2/**
3 * HttpUtils' tests
4 */
5
6namespace Shaarli\Http;
7
8require_once 'application/http/HttpUtils.php';
9
10/**
11 * Unitary tests for page_url()
12 */
13class PageUrlTest extends \PHPUnit\Framework\TestCase
14{
15 /**
16 * If on the main page, remove "index.php" from the URL resource
17 */
18 public function testRemoveIndex()
19 {
20 $this->assertEquals(
21 'http://host.tld/?p1=v1&p2=v2',
22 page_url(
23 array(
24 'HTTPS' => 'Off',
25 'SERVER_NAME' => 'host.tld',
26 'SERVER_PORT' => '80',
27 'SCRIPT_NAME' => '/index.php',
28 'QUERY_STRING' => 'p1=v1&p2=v2'
29 )
30 )
31 );
32
33 $this->assertEquals(
34 'http://host.tld/admin/?action=edit_tag',
35 page_url(
36 array(
37 'HTTPS' => 'Off',
38 'SERVER_NAME' => 'host.tld',
39 'SERVER_PORT' => '80',
40 'SCRIPT_NAME' => '/admin/index.php',
41 'QUERY_STRING' => 'action=edit_tag'
42 )
43 )
44 );
45 }
46
47 /**
48 * The resource is != "index.php"
49 */
50 public function testOtherResource()
51 {
52 $this->assertEquals(
53 'http://host.tld/page.php?p1=v1&p2=v2',
54 page_url(
55 array(
56 'HTTPS' => 'Off',
57 'SERVER_NAME' => 'host.tld',
58 'SERVER_PORT' => '80',
59 'SCRIPT_NAME' => '/page.php',
60 'QUERY_STRING' => 'p1=v1&p2=v2'
61 )
62 )
63 );
64
65 $this->assertEquals(
66 'http://host.tld/admin/page.php?action=edit_tag',
67 page_url(
68 array(
69 'HTTPS' => 'Off',
70 'SERVER_NAME' => 'host.tld',
71 'SERVER_PORT' => '80',
72 'SCRIPT_NAME' => '/admin/page.php',
73 'QUERY_STRING' => 'action=edit_tag'
74 )
75 )
76 );
77 }
78}