Esempio n. 1
0
 /**
  * Test getting the size back from Content-Length in our response object.
  */
 public function testGetSize()
 {
     $expectedUrl = 'http://www.google.com/this-is-a-test-url';
     $expectedSize = 1235122;
     $request = new Request('GET', $expectedUrl);
     $response = new Response(200, ['Content-Length' => $expectedSize]);
     $sut = new Url($request, $response);
     $this->assertEquals($sut->getSize(), $expectedSize);
 }
Esempio n. 2
0
 /**
  * Method to parse the dom from a Url to create a Product.
  *
  * @param Url $url
  * @return Product
  */
 public function getProductFromUrl(Url $url)
 {
     // dom parse the information we need from the page
     $crawler = new Crawler($url->getResponseContents());
     // @todo review description data - it is a mess, crappy content?
     // are we after the meta description or value in the information tab?
     // going for information tab
     // and create the new product
     return new Product($crawler->filter("div.productSummary h1")->text(), $crawler->filter("#information div.productText")->first()->text(), $crawler->filter("p.pricePerUnit")->text(), $url);
 }