Permalink
Browse files

MINOR Making HTTPTest less fragile around global state. Improved test…

… readability.
  • Loading branch information...
1 parent 2870eb9 commit f4a16d3c77066d1dacd5ea37763ec6bf21dbcf83 @chillu chillu committed Mar 30, 2011
Showing with 8 additions and 11 deletions.
  1. +8 −11 tests/HTTPTest.php
View
@@ -49,17 +49,14 @@ public function testGetLinksIn() {
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',

0 comments on commit f4a16d3

Please sign in to comment.