Skip to content

Commit 5e4b8c7

Browse files
committed
add test case for SERVER_NAME detection
1 parent c414833 commit 5e4b8c7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/TestCase/EnvironmentsTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,21 @@ public function testHostEnvironmentDetection()
122122
$_SERVER['HTTP_HOST'] = $backup;
123123
}
124124

125+
public function testServerNameEnvironmentDetection()
126+
{
127+
Environments::tearDown();
128+
EnvironmentsTestWrapper::prepareTestEnvironments();
129+
130+
$hostBackup = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
131+
$serverNameBackup = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost';
132+
$_SERVER['HTTP_HOST'] = null;
133+
$_SERVER['SERVER_NAME'] = 'test.com';
134+
$this->assertEquals('testing', EnvironmentsTestWrapper::getEnvironment());
135+
136+
$_SERVER['HTTP_HOST'] = $hostBackup;
137+
$_SERVER['SERVER_NAME'] = $serverNameBackup;
138+
}
139+
125140
public function testPathEnvironmentDetection()
126141
{
127142
Environments::tearDown();

0 commit comments

Comments
 (0)