aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/http/HttpUtils/IndexUrlTest.php
diff options
context:
space:
mode:
authorAurélien Tamisier <virtualtam+github@flibidi.net>2019-01-18 21:26:03 +0100
committerGitHub <noreply@github.com>2019-01-18 21:26:03 +0100
commitff3b5dc5542ec150f0d9b447394364a15e9156d0 (patch)
tree5e926e36816d510e3b3a10e20b94c23f43b55092 /tests/http/HttpUtils/IndexUrlTest.php
parent1826e383ecf501302974132fd443cf1ca06e10f6 (diff)
parentdea72c711ff740b3b829d238fcf85648465143a0 (diff)
downloadShaarli-ff3b5dc5542ec150f0d9b447394364a15e9156d0.tar.gz
Shaarli-ff3b5dc5542ec150f0d9b447394364a15e9156d0.tar.zst
Shaarli-ff3b5dc5542ec150f0d9b447394364a15e9156d0.zip
Merge pull request #1248 from virtualtam/refactor/namespacing
Ensure all PHP classes are properly namespaced
Diffstat (limited to 'tests/http/HttpUtils/IndexUrlTest.php')
-rw-r--r--tests/http/HttpUtils/IndexUrlTest.php74
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/http/HttpUtils/IndexUrlTest.php b/tests/http/HttpUtils/IndexUrlTest.php
new file mode 100644
index 00000000..bcbe59cb
--- /dev/null
+++ b/tests/http/HttpUtils/IndexUrlTest.php
@@ -0,0 +1,74 @@
1<?php
2/**
3 * HttpUtils' tests
4 */
5
6namespace Shaarli\Http;
7
8require_once 'application/http/HttpUtils.php';
9
10/**
11 * Unitary tests for index_url()
12 */
13class IndexUrlTest 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/',
22 index_url(
23 array(
24 'HTTPS' => 'Off',
25 'SERVER_NAME' => 'host.tld',
26 'SERVER_PORT' => '80',
27 'SCRIPT_NAME' => '/index.php'
28 )
29 )
30 );
31
32 $this->assertEquals(
33 'http://host.tld/admin/',
34 index_url(
35 array(
36 'HTTPS' => 'Off',
37 'SERVER_NAME' => 'host.tld',
38 'SERVER_PORT' => '80',
39 'SCRIPT_NAME' => '/admin/index.php'
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',
52 page_url(
53 array(
54 'HTTPS' => 'Off',
55 'SERVER_NAME' => 'host.tld',
56 'SERVER_PORT' => '80',
57 'SCRIPT_NAME' => '/page.php'
58 )
59 )
60 );
61
62 $this->assertEquals(
63 'http://host.tld/admin/page.php',
64 page_url(
65 array(
66 'HTTPS' => 'Off',
67 'SERVER_NAME' => 'host.tld',
68 'SERVER_PORT' => '80',
69 'SCRIPT_NAME' => '/admin/page.php'
70 )
71 )
72 );
73 }
74}