Skip to content

Commit

Permalink
extensibility enhancements (factories and final classes) (#3724)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitek-rostislav authored Jan 23, 2025
2 parents 1719a6b + 355ed1f commit 24468ae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/Model/FeedItem/GoogleFeedItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Shopsys\FrameworkBundle\Model\Feed\FeedItemInterface;
use Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency;
use Shopsys\FrameworkBundle\Model\Pricing\Price;
use Shopsys\FrameworkBundle\Model\Pricing\PriceInterface;
use Shopsys\FrameworkBundle\Model\Pricing\SpecialPrice\SpecialPrice;

class GoogleFeedItem implements FeedItemInterface
Expand All @@ -20,7 +20,7 @@ class GoogleFeedItem implements FeedItemInterface
* @param int $id
* @param string $name
* @param bool $sellingDenied
* @param \Shopsys\FrameworkBundle\Model\Pricing\Price $price
* @param \Shopsys\FrameworkBundle\Model\Pricing\PriceInterface $price
* @param \Shopsys\FrameworkBundle\Model\Pricing\SpecialPrice\SpecialPrice|null $specialPrice
* @param \Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency $currency
* @param string $url
Expand All @@ -34,7 +34,7 @@ public function __construct(
protected readonly int $id,
protected readonly string $name,
protected readonly bool $sellingDenied,
protected readonly Price $price,
protected readonly PriceInterface $price,
protected readonly ?SpecialPrice $specialPrice,
protected readonly Currency $currency,
protected readonly string $url,
Expand Down Expand Up @@ -111,9 +111,9 @@ public function getAvailability(): string
}

/**
* @return \Shopsys\FrameworkBundle\Model\Pricing\Price
* @return \Shopsys\FrameworkBundle\Model\Pricing\PriceInterface
*/
public function getPrice(): Price
public function getPrice(): PriceInterface
{
return $this->price;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Model/FeedItem/GoogleFeedItemFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Shopsys\FrameworkBundle\Component\Domain\Config\DomainConfig;
use Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency;
use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade;
use Shopsys\FrameworkBundle\Model\Pricing\Price;
use Shopsys\FrameworkBundle\Model\Pricing\PriceInterface;
use Shopsys\FrameworkBundle\Model\Pricing\SpecialPrice\SpecialPrice;
use Shopsys\FrameworkBundle\Model\Pricing\SpecialPrice\SpecialPriceFacade;
use Shopsys\FrameworkBundle\Model\Product\Availability\ProductAvailabilityFacade;
Expand Down Expand Up @@ -70,14 +70,14 @@ protected function getBrandName(Product $product): ?string
/**
* @param \Shopsys\FrameworkBundle\Model\Product\Product $product
* @param \Shopsys\FrameworkBundle\Component\Domain\Config\DomainConfig $domainConfig
* @return \Shopsys\FrameworkBundle\Model\Pricing\Price
* @return \Shopsys\FrameworkBundle\Model\Pricing\PriceInterface
*/
protected function getPrice(Product $product, DomainConfig $domainConfig): Price
protected function getPrice(Product $product, DomainConfig $domainConfig): PriceInterface
{
return $this->productPriceCalculationForCustomerUser->calculateBasicPriceForCustomerUserAndDomainId(
$product,
$domainConfig->getId(),
);
)->getPrice();
}

/**
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/GoogleFeedItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Shopsys\FrameworkBundle\Component\Money\Money;
use Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency;
use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade;
use Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroup;
use Shopsys\FrameworkBundle\Model\Pricing\Price;
use Shopsys\FrameworkBundle\Model\Pricing\SpecialPrice\SpecialPriceFacade;
use Shopsys\FrameworkBundle\Model\Product\Availability\ProductAvailabilityFacade;
Expand Down Expand Up @@ -132,7 +133,7 @@ private function createDomainConfigMock(int $id, string $url, string $locale, Cu
*/
private function mockProductPrice(Product $product, DomainConfig $domain, Price $price): void
{
$productPrice = new ProductPrice($price, false);
$productPrice = new ProductPrice($price, $this->createMock(PricingGroup::class), false);
$this->productPriceCalculationForCustomerUserMock->method('calculateBasicPriceForCustomerUserAndDomainId')
->with($product, $domain->getId(), null)->willReturn($productPrice);
}
Expand Down

0 comments on commit 24468ae

Please sign in to comment.