浏览代码

requestTest, override globals erase for the next tests. so backup it and restore it.

Cyril Quintin 14 年之前
父节点
当前提交
1e4e899641
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      tests/Symfony/Tests/Component/HttpFoundation/RequestTest.php

+ 6 - 3
tests/Symfony/Tests/Component/HttpFoundation/RequestTest.php

@@ -507,10 +507,12 @@ class RequestTest extends \PHPUnit_Framework_TestCase
 
     public function testOverrideGlobals()
     {
-        $time = $_SERVER['REQUEST_TIME']; // fix for phpunit timer
-
         $request = new Request();
         $request->initialize(array('foo' => 'bar'));
+
+        // as the Request::overrideGlobals really work, it erase $_SERVER, so we must backup it
+        $server = $_SERVER;
+
         $request->overrideGlobals();
 
         $this->assertEquals(array('foo' => 'bar'), $_GET);
@@ -530,7 +532,8 @@ class RequestTest extends \PHPUnit_Framework_TestCase
 
         $this->assertArrayHasKey('HTTP_X_FORWARDED_PROTO', $_SERVER);
 
-        $_SERVER['REQUEST_TIME'] = $time; // fix for phpunit timer
+        // restore initial $_SERVER array
+        $_SERVER = $server;
     }
 
     public function testGetScriptName()