Example #1
0
 /**
  * Returns the DOM crawler which can be used to interact with the web page
  * structure, submit forms, click links or fetch specific parts of the
  * website's contents.
  *
  * The returned DOM crawler is bound to the response of the last executed
  * request.
  *
  * @return \Symfony\Component\DomCrawler\Crawler
  * @api
  */
 public function getCrawler()
 {
     $crawler = new Crawler(NULL, $this->lastRequest->getBaseUri());
     $crawler->addContent($this->lastResponse->getContent(), $this->lastResponse->getHeader('Content-Type'));
     return $crawler;
 }
Example #2
0
    /**
     * RFC 2616 / 4.4 (Message Length)
     *
     * @test
     */
    public function makeStandardsCompliantSetsBodyAndContentLengthForHeadRequests()
    {
        $request = Request::create(new Uri('http://localhost'), 'HEAD');
        $content = '
			Pat grabbed her hat
			and her fat, wooden bat
			When her friends couldn\'t play,
			Pat yelled out, "Drat!"
			But then she hit balls
			to her dog and _-at.
		';
        $response = new Response();
        $response->setContent($content);
        $response->makeStandardsCompliant($request);
        $this->assertEquals('', $response->getContent());
        $this->assertEquals(strlen($content), $response->getHeader('Content-Length'));
        $response = new Response();
        $response->setHeader('Content-Length', 275);
        $response->makeStandardsCompliant($request);
        $this->assertEquals(275, $response->getHeader('Content-Length'));
    }