Skip to content

Commit

Permalink
Change implementations to new interface when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Devos committed May 12, 2020
1 parent 04a7f14 commit b37206e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

namespace Sylius\Bundle\CoreBundle\Templating\Helper;

use Sylius\Component\Core\Calculator\ProductVariantPriceCalculatorInterface;
use Sylius\Component\Core\Calculator\ProductVariantPricesCalculatorInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Symfony\Component\Templating\Helper\Helper;
use Webmozart\Assert\Assert;

class PriceHelper extends Helper
{
/** @var ProductVariantPriceCalculatorInterface */
/** @var ProductVariantPricesCalculatorInterface */
private $productVariantPriceCalculator;

public function __construct(ProductVariantPriceCalculatorInterface $productVariantPriceCalculator)
public function __construct(ProductVariantPricesCalculatorInterface $productVariantPriceCalculator)
{
$this->productVariantPriceCalculator = $productVariantPriceCalculator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
namespace spec\Sylius\Bundle\CoreBundle\Templating\Helper;

use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Calculator\ProductVariantPriceCalculatorInterface;
use Sylius\Component\Core\Calculator\ProductVariantPricesCalculatorInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Symfony\Component\Templating\Helper\Helper;

final class PriceHelperSpec extends ObjectBehavior
{
function let(ProductVariantPriceCalculatorInterface $productVariantPriceCalculator): void
function let(ProductVariantPricesCalculatorInterface $productVariantPriceCalculator): void
{
$this->beConstructedWith($productVariantPriceCalculator);
}
Expand All @@ -34,7 +34,7 @@ function it_is_helper(): void
function it_returns_variant_price_for_channel_given_in_context(
ChannelInterface $channel,
ProductVariantInterface $productVariant,
ProductVariantPriceCalculatorInterface $productVariantPriceCalculator
ProductVariantPricesCalculatorInterface $productVariantPriceCalculator
): void {
$context = ['channel' => $channel];

Expand All @@ -45,7 +45,7 @@ function it_returns_variant_price_for_channel_given_in_context(

function it_throws_invalid_argument_exception_when_channel_key_is_not_present_in_context(
ProductVariantInterface $productVariant,
ProductVariantPriceCalculatorInterface $productVariantPriceCalculator
ProductVariantPricesCalculatorInterface $productVariantPriceCalculator
): void {
$context = ['lennahc' => ''];

Expand All @@ -57,7 +57,7 @@ function it_throws_invalid_argument_exception_when_channel_key_is_not_present_in
function it_returns_variant_original_price_for_channel_given_in_context(
ChannelInterface $channel,
ProductVariantInterface $productVariant,
ProductVariantPriceCalculatorInterface $productVariantPriceCalculator
ProductVariantPricesCalculatorInterface $productVariantPriceCalculator
): void {
$context = ['channel' => $channel];

Expand All @@ -68,7 +68,7 @@ function it_returns_variant_original_price_for_channel_given_in_context(

function it_throws_invalid_argument_exception_when_channel_key_is_not_present_in_context_when_getting_original_price(
ProductVariantInterface $productVariant,
ProductVariantPriceCalculatorInterface $productVariantPriceCalculator
ProductVariantPricesCalculatorInterface $productVariantPriceCalculator
): void {
$context = ['lennahc' => ''];

Expand All @@ -80,7 +80,7 @@ function it_throws_invalid_argument_exception_when_channel_key_is_not_present_in
function it_returns_true_if_variant_is_discounted_for_channel_given_in_context(
ChannelInterface $channel,
ProductVariantInterface $productVariant,
ProductVariantPriceCalculatorInterface $productVariantPriceCalculator
ProductVariantPricesCalculatorInterface $productVariantPriceCalculator
): void {
$context = ['channel' => $channel];

Expand All @@ -93,7 +93,7 @@ function it_returns_true_if_variant_is_discounted_for_channel_given_in_context(
function it_returns_false_if_variant_is_not_discounted_for_channel_given_in_context(
ChannelInterface $channel,
ProductVariantInterface $productVariant,
ProductVariantPriceCalculatorInterface $productVariantPriceCalculator
ProductVariantPricesCalculatorInterface $productVariantPriceCalculator
): void {
$context = ['channel' => $channel];

Expand All @@ -105,7 +105,7 @@ function it_returns_false_if_variant_is_not_discounted_for_channel_given_in_cont

function it_throws_invalid_argument_exception_when_channel_key_is_not_present_in_context_when_checking_if_variant_is_discounted(
ProductVariantInterface $productVariant,
ProductVariantPriceCalculatorInterface $productVariantPriceCalculator
ProductVariantPricesCalculatorInterface $productVariantPriceCalculator
): void {
$context = ['lennahc' => ''];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@
use Sylius\Component\Core\Exception\MissingChannelConfigurationException;
use Sylius\Component\Core\Model\ProductVariantInterface;

interface ProductVariantPricesCalculatorInterface
interface ProductVariantPricesCalculatorInterface extends ProductVariantPriceCalculatorInterface
{
/**
* @throws MissingChannelConfigurationException when price for given channel does not exist
*/
public function calculate(ProductVariantInterface $productVariant, array $context): int;

/**
* @throws MissingChannelConfigurationException when price for given channel does not exist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace spec\Sylius\Component\Core\Calculator;

use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Calculator\ProductVariantPriceCalculatorInterface;
use Sylius\Component\Core\Calculator\ProductVariantPricesCalculatorInterface;
use Sylius\Component\Core\Exception\MissingChannelConfigurationException;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ChannelPricingInterface;
Expand All @@ -24,7 +24,7 @@ final class ProductVariantPriceCalculatorSpec extends ObjectBehavior
{
function it_implements_product_variant_price_calculator_interface(): void
{
$this->shouldImplement(ProductVariantPriceCalculatorInterface::class);
$this->shouldImplement(ProductVariantPricesCalculatorInterface::class);
}

function it_gets_price_for_product_variant_in_given_channel(
Expand Down

0 comments on commit b37206e

Please sign in to comment.