Ver Fonte

[BrowserKit] added tests for setServerParameter/getServerParameter methods

hidenorigoto há 14 anos atrás
pai
commit
43952b3175
1 ficheiros alterados com 23 adições e 0 exclusões
  1. 23 0
      tests/Symfony/Tests/Component/BrowserKit/ClientTest.php

+ 23 - 0
tests/Symfony/Tests/Component/BrowserKit/ClientTest.php

@@ -308,4 +308,27 @@ class ClientTest extends \PHPUnit_Framework_TestCase
             $this->assertInstanceof('RuntimeException', $e, '->request() throws a \RuntimeException if the script has an error');
         }
     }
+
+    public function testGetServerParameter()
+    {
+        $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('testvalue', $client->getServerParameter('testkey', 'testvalue'));
+    }
+
+    public function testSetServerParameter()
+    {
+        $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'));
+
+        $client->setServerParameter('HTTP_HOST', 'testhost');
+        $this->assertEquals('testhost', $client->getServerParameter('HTTP_HOST'));
+
+        $client->setServerParameter('HTTP_USER_AGENT', 'testua');
+        $this->assertEquals('testua', $client->getServerParameter('HTTP_USER_AGENT'));
+    }
 }