/** * Test resolve image. * * @dataProvider dataResolveImage */ public function testResolveImage($implementsProduct, $imageResolverResult, $result) { $purchasable = $implementsProduct ? $this->prophesize('Elcodi\\Component\\Product\\Entity\\Interfaces\\ProductInterface') : $this->prophesize('Elcodi\\Component\\Product\\Entity\\Interfaces\\PurchasableInterface'); $purchasable = $purchasable->reveal(); $imageResolver = $this->prophesize('Elcodi\\Component\\Media\\Services\\ImageResolver'); $imageResolver->resolveImage($purchasable)->willReturn($imageResolverResult); $productImageResolver = new ProductImageResolver($imageResolver->reveal()); $this->assertSame($result, $productImageResolver->getValidImage($purchasable)); $purchasableImageResolver = new PurchasableImageResolver(); $purchasableImageResolver->addPurchasableImageResolver($productImageResolver); $this->assertSame($result, $purchasableImageResolver->getValidImage($purchasable)); }
/** * Test resolve image. * * @dataProvider dataResolveImage */ public function testResolveImage($implementsPack, $imagePackResolverResult, $imageProductResolverResult, $imageVariantResolverResult, $result) { $purchasable = $implementsPack ? $this->prophesize('Elcodi\\Component\\Product\\Entity\\Interfaces\\PackInterface') : $this->prophesize('Elcodi\\Component\\Product\\Entity\\Interfaces\\PurchasableInterface'); $productImageResolver = $this->getProductImageMock($imageProductResolverResult); $variantImageResolver = $this->getVariantImageMock($imageVariantResolverResult); if ($implementsPack) { $purchasable->getPurchasables()->willReturn(new ArrayCollection([$this->prophesize('Elcodi\\Component\\Product\\Entity\\Interfaces\\ProductInterface')->reveal(), $this->prophesize('Elcodi\\Component\\Product\\Entity\\Interfaces\\VariantInterface')->reveal()])); } $purchasable = $purchasable->reveal(); $imageResolver = $this->prophesize('Elcodi\\Component\\Media\\Services\\ImageResolver'); $imageResolver->resolveImage($purchasable)->willReturn($imagePackResolverResult); $packImageResolver = new PackImageResolver($imageResolver->reveal()); $packImageResolver->addPurchasableImageResolver($productImageResolver); $packImageResolver->addPurchasableImageResolver($variantImageResolver); $this->assertSame($result, $packImageResolver->getValidImage($purchasable)); $purchasableImageResolver = new PurchasableImageResolver(); $purchasableImageResolver->addPurchasableImageResolver($variantImageResolver); $purchasableImageResolver->addPurchasableImageResolver($productImageResolver); $purchasableImageResolver->addPurchasableImageResolver($packImageResolver); $this->assertSame($result, $purchasableImageResolver->getValidImage($purchasable)); }