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'
73 * Detect if the server uses a specific port (!= 80)
75 public function testPort()
79 'http://host.tld:8080',
83 'SERVER_NAME' => 'host.tld',
84 'SERVER_PORT' => '8080'
91 'https://host.tld:8080',
95 'SERVER_NAME' => 'host.tld',
96 'SERVER_PORT' => '8080'
103 * HTTP server on port 80
105 public function testStandardHttpPort()
112 'SERVER_NAME' => 'host.tld',
113 'SERVER_PORT' => '80'
120 * HTTPS server on port 443
122 public function testStandardHttpsPort()
129 'SERVER_NAME' => 'host.tld',
130 'SERVER_PORT' => '443'