aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/HttpUtils/PageUrlTest.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2015-09-14 20:40:41 +0200
committerVirtualTam <virtualtam@flibidi.net>2015-09-14 20:40:41 +0200
commit4df3520d6e6768324b3120a3a2b317fb4ef0461b (patch)
treeb4e7c6ddaa1d88cc49bc96c2524f12431d8fcce0 /tests/HttpUtils/PageUrlTest.php
parentce47a75864d7d398a68705df67da2ae00ca89eca (diff)
parent482d67bd523bf12f36508a0131d09fe299ee02f4 (diff)
downloadShaarli-4df3520d6e6768324b3120a3a2b317fb4ef0461b.tar.gz
Shaarli-4df3520d6e6768324b3120a3a2b317fb4ef0461b.tar.zst
Shaarli-4df3520d6e6768324b3120a3a2b317fb4ef0461b.zip
Merge pull request #346 from virtualtam/refactor/http-url-utils
HTTP: move server URL functions to `HttpUtils.php`
Diffstat (limited to 'tests/HttpUtils/PageUrlTest.php')
-rw-r--r--tests/HttpUtils/PageUrlTest.php76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/HttpUtils/PageUrlTest.php b/tests/HttpUtils/PageUrlTest.php
new file mode 100644
index 00000000..4dbbe9cf
--- /dev/null
+++ b/tests/HttpUtils/PageUrlTest.php
@@ -0,0 +1,76 @@
1<?php
2/**
3 * HttpUtils' tests
4 */
5
6require_once 'application/HttpUtils.php';
7
8/**
9 * Unitary tests for page_url()
10 */
11class PageUrlTest extends PHPUnit_Framework_TestCase
12{
13 /**
14 * If on the main page, remove "index.php" from the URL resource
15 */
16 public function testRemoveIndex()
17 {
18 $this->assertEquals(
19 'http://host.tld/?p1=v1&p2=v2',
20 page_url(
21 array(
22 'HTTPS' => 'Off',
23 'SERVER_NAME' => 'host.tld',
24 'SERVER_PORT' => '80',
25 'SCRIPT_NAME' => '/index.php',
26 'QUERY_STRING' => 'p1=v1&p2=v2'
27 )
28 )
29 );
30
31 $this->assertEquals(
32 'http://host.tld/admin/?action=edit_tag',
33 page_url(
34 array(
35 'HTTPS' => 'Off',
36 'SERVER_NAME' => 'host.tld',
37 'SERVER_PORT' => '80',
38 'SCRIPT_NAME' => '/admin/index.php',
39 'QUERY_STRING' => 'action=edit_tag'
40 )
41 )
42 );
43 }
44
45 /**
46 * The resource is != "index.php"
47 */
48 public function testOtherResource()
49 {
50 $this->assertEquals(
51 'http://host.tld/page.php?p1=v1&p2=v2',
52 page_url(
53 array(
54 'HTTPS' => 'Off',
55 'SERVER_NAME' => 'host.tld',
56 'SERVER_PORT' => '80',
57 'SCRIPT_NAME' => '/page.php',
58 'QUERY_STRING' => 'p1=v1&p2=v2'
59 )
60 )
61 );
62
63 $this->assertEquals(
64 'http://host.tld/admin/page.php?action=edit_tag',
65 page_url(
66 array(
67 'HTTPS' => 'Off',
68 'SERVER_NAME' => 'host.tld',
69 'SERVER_PORT' => '80',
70 'SCRIPT_NAME' => '/admin/page.php',
71 'QUERY_STRING' => 'action=edit_tag'
72 )
73 )
74 );
75 }
76}