Exemple #1
0
    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'));
    }
 public function testInsulatedRequests()
 {
     $client = new TestClient();
     $client->insulate();
     $client->setNextScript("new Symfony\\Component\\BrowserKit\\Response('foobar')");
     $client->request('GET', 'http://www.example.com/foo/foobar');
     $this->assertEquals('foobar', $client->getResponse()->getContent(), '->insulate() process the request in a forked process');
     $client->setNextScript("new Symfony\\Component\\BrowserKit\\Response('foobar)");
     try {
         $client->request('GET', 'http://www.example.com/foo/foobar');
         $this->fail('->request() throws a \\RuntimeException if the script has an error');
     } catch (\Exception $e) {
         $this->assertInstanceof('RuntimeException', $e, '->request() throws a \\RuntimeException if the script has an error');
     }
 }
 public function testSetServerParameter()
 {
     $client = new TestClient();
     $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
     $this->assertEquals('Symfony2 BrowserKit', $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'));
 }