/** * @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; }
public function testCalculateTotalWithoutProducts() { $products = new Products(); $this->assertEquals(0, $products->calculateTotal()); $this->assertEquals([], $products->toArray()); }