6 require_once 'application/HttpUtils.php';
9 * Unitary tests for server_url()
11 class ServerUrlTest
extends PHPUnit_Framework_TestCase
14 * Detect if the server uses SSL
16 public function testHttpsScheme()
23 'SERVER_NAME' => 'host.tld',
24 'SERVER_PORT' => '443'
30 'https://host.tld:8080',
34 'SERVER_NAME' => 'host.tld',
35 'SERVER_PORT' => '8080'
42 * Detect a Proxy with SSL enabled
44 public function testHttpsProxyForward()
47 'https://host.tld:8080',
51 'SERVER_NAME' => 'host.tld',
52 'SERVER_PORT' => '80',
53 'HTTP_X_FORWARDED_PROTO' => 'https',
54 'HTTP_X_FORWARDED_PORT' => '8080'
64 'SERVER_NAME' => 'host.tld',
65 'SERVER_PORT' => '80',
66 'HTTP_X_FORWARDED_PROTO' => 'https'
72 'https://host.tld:4974',
76 'SERVER_NAME' => 'host.tld',
77 'SERVER_PORT' => '80',
78 'HTTP_X_FORWARDED_PROTO' => 'https, https',
79 'HTTP_X_FORWARDED_PORT' => '4974, 80'
86 * Detect if the server uses a specific port (!= 80)
88 public function testPort()
92 'http://host.tld:8080',
96 'SERVER_NAME' => 'host.tld',
97 'SERVER_PORT' => '8080'
104 'https://host.tld:8080',
108 'SERVER_NAME' => 'host.tld',
109 'SERVER_PORT' => '8080'
116 * HTTP server on port 80
118 public function testStandardHttpPort()
125 'SERVER_NAME' => 'host.tld',
126 'SERVER_PORT' => '80'
133 * HTTPS server on port 443
135 public function testStandardHttpsPort()
142 'SERVER_NAME' => 'host.tld',
143 'SERVER_PORT' => '443'