/**
  * @param Url $url
  *
  * @return Products
  */
 public function extract(Url $url)
 {
     $products = new Products();
     $productsUrls = $this->productListScraper->extractProductLinks($url);
     foreach ($productsUrls as $productUrl) {
         $product = $this->productDetailScraper->extractDetail($productUrl);
         if ($product) {
             $products->add($product);
         }
     }
     return $products;
 }
예제 #2
0
 public function testCalculateTotalWithoutProducts()
 {
     $products = new Products();
     $this->assertEquals(0, $products->calculateTotal());
     $this->assertEquals([], $products->toArray());
 }