aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/HttpUtils/IndexUrlTest.php
diff options
context:
space:
mode:
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}