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'
76 'SERVER_NAME' => 'host.tld',
77 'SERVER_PORT' => '80',
78 'HTTP_X_FORWARDED_PROTO' => 'https',
79 'HTTP_X_FORWARDED_PORT' => '443'
85 'https://host.tld:4974',
89 'SERVER_NAME' => 'host.tld',
90 'SERVER_PORT' => '80',
91 'HTTP_X_FORWARDED_PROTO' => 'https, https',
92 'HTTP_X_FORWARDED_PORT' => '4974, 80'
99 * Detect if the server uses a specific port (!= 80)
101 public function testPort()
105 'http://host.tld:8080',
109 'SERVER_NAME' => 'host.tld',
110 'SERVER_PORT' => '8080'
117 'https://host.tld:8080',
121 'SERVER_NAME' => 'host.tld',
122 'SERVER_PORT' => '8080'
129 * HTTP server on port 80
131 public function testStandardHttpPort()
138 'SERVER_NAME' => 'host.tld',
139 'SERVER_PORT' => '80'
146 * HTTPS server on port 443
148 public function testStandardHttpsPort()
155 'SERVER_NAME' => 'host.tld',
156 'SERVER_PORT' => '443'