Browse Source

Don't tell a lie to every WebServers

sasezaki 14 năm trước cách đây
mục cha
commit
266e60e7a2

+ 2 - 1
src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php

@@ -34,7 +34,8 @@ abstract class WebTestCase extends \PHPUnit_Framework_TestCase
      *
      * @return Client A Client instance
      */
-    static protected function createClient(array $options = array(), array $server = array())
+    static protected function createClient(array $options = array(), 
+                                           array $server = array('HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3'))
     {
         static::$kernel = static::createKernel($options);
         static::$kernel->boot();

+ 1 - 1
src/Symfony/Component/BrowserKit/Client.php

@@ -104,7 +104,7 @@ abstract class Client
     {
         $this->server = array_merge(array(
             'HTTP_HOST'       => 'localhost',
-            'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3',
+            'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
         ), $server);
     }
 

+ 2 - 3
tests/Symfony/Tests/Component/BrowserKit/ClientTest.php

@@ -313,8 +313,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
     {
         $client = new TestClient();
         $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
-        $this->assertEquals('Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3', $client->getServerParameter('HTTP_USER_AGENT'));
-
+        $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
         $this->assertEquals('testvalue', $client->getServerParameter('testkey', 'testvalue'));
     }
 
@@ -323,7 +322,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
         $client = new TestClient();
 
         $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
-        $this->assertEquals('Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3', $client->getServerParameter('HTTP_USER_AGENT'));
+        $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
 
         $client->setServerParameter('HTTP_HOST', 'testhost');
         $this->assertEquals('testhost', $client->getServerParameter('HTTP_HOST'));