mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Making HTTPTest less fragile around global state. Improved test readability.
This commit is contained in:
parent
2870eb9212
commit
f4a16d3c77
@ -49,17 +49,14 @@ class HTTPTest extends SapphireTest {
|
||||
public function testSetGetVar() {
|
||||
// Hackery to work around volatile URL formats in test invocation,
|
||||
// and the inability of Director::absoluteBaseURL() to produce consistent URLs.
|
||||
$expectedPath = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
|
||||
|
||||
// TODO This should test the absolute URL, but we can't get it reliably
|
||||
// with port and auth URI parts.
|
||||
foreach(array(Director::makeRelative($expectedPath), 'foo=bar') as $e) {
|
||||
$this->assertContains(
|
||||
$e,
|
||||
HTTP::setGetVar('foo', 'bar'),
|
||||
'Omitting a URL falls back to current URL'
|
||||
);
|
||||
}
|
||||
$origURI = $_SERVER['REQUEST_URI'];
|
||||
$_SERVER['REQUEST_URI'] = 'relative/url/';
|
||||
$this->assertContains(
|
||||
'relative/url/?foo=bar',
|
||||
HTTP::setGetVar('foo', 'bar'),
|
||||
'Omitting a URL falls back to current URL'
|
||||
);
|
||||
$_SERVER['REQUEST_URI'] = $origURI;
|
||||
|
||||
$this->assertEquals(
|
||||
'relative/url?foo=bar',
|
||||
|
Loading…
x
Reference in New Issue
Block a user