]>
Commit | Line | Data |
---|---|---|
482d67bd V |
1 | <?php |
2 | /** | |
3 | * HttpUtils' tests | |
4 | */ | |
5 | ||
6 | require_once 'application/HttpUtils.php'; | |
7 | ||
8 | /** | |
9 | * Unitary tests for page_url() | |
10 | */ | |
11 | class 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 | } |