aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/HttpUtils/IndexUrlTest.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/IndexUrlTest.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/IndexUrlTest.php')
-rw-r--r--tests/HttpUtils/IndexUrlTest.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/HttpUtils/IndexUrlTest.php b/tests/HttpUtils/IndexUrlTest.php
new file mode 100644
index 00000000..337dcab0
--- /dev/null
+++ b/tests/HttpUtils/IndexUrlTest.php
@@ -0,0 +1,72 @@
1<?php
2/**
3 * HttpUtils' tests
4 */
5
6require_once 'application/HttpUtils.php';
7
8/**
9 * Unitary tests for index_url()
10 */
11class IndexUrlTest 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/',
20 index_url(
21 array(
22 'HTTPS' => 'Off',
23 'SERVER_NAME' => 'host.tld',
24 'SERVER_PORT' => '80',
25 'SCRIPT_NAME' => '/index.php'
26 )
27 )
28 );
29
30 $this->assertEquals(
31 'http://host.tld/admin/',
32 index_url(
33 array(
34 'HTTPS' => 'Off',
35 'SERVER_NAME' => 'host.tld',
36 'SERVER_PORT' => '80',
37 'SCRIPT_NAME' => '/admin/index.php'
38 )
39 )
40 );
41 }
42
43 /**
44 * The resource is != "index.php"
45 */
46 public function testOtherResource()
47 {
48 $this->assertEquals(
49 'http://host.tld/page.php',
50 page_url(
51 array(
52 'HTTPS' => 'Off',
53 'SERVER_NAME' => 'host.tld',
54 'SERVER_PORT' => '80',
55 'SCRIPT_NAME' => '/page.php'
56 )
57 )
58 );
59
60 $this->assertEquals(
61 'http://host.tld/admin/page.php',
62 page_url(
63 array(
64 'HTTPS' => 'Off',
65 'SERVER_NAME' => 'host.tld',
66 'SERVER_PORT' => '80',
67 'SCRIPT_NAME' => '/admin/page.php'
68 )
69 )
70 );
71 }
72}