Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #49 from bartoszpietrzak1994/remove-unused-services
Browse files Browse the repository at this point in the history
Unused services removed + ecs fixes
  • Loading branch information
Zales0123 authored Nov 8, 2018
2 parents 0d51f37 + 52b2754 commit c5d0a2b
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 84 deletions.
24 changes: 12 additions & 12 deletions spec/Checker/OrderCustomerRelationCheckerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

final class OrderCustomerRelationCheckerSpec extends ObjectBehavior
{
function it_implements_order_customer_relation_checker_interface(): void
{
$this->shouldImplement(OrderCustomerRelationCheckerInterface::class);
}
function it_implements_order_customer_relation_checker_interface(): void
{
$this->shouldImplement(OrderCustomerRelationCheckerInterface::class);
}

function it_returns_true_when_order_was_placed_by_customer(
function it_returns_true_when_order_was_placed_by_customer(
CustomerInterface $orderCustomer,
CustomerInterface $customer,
OrderInterface $order
Expand All @@ -27,9 +27,9 @@ function it_returns_true_when_order_was_placed_by_customer(
$order->getCustomer()->willReturn($orderCustomer);

$this->wasOrderPlacedByCustomer($order, $customer)->shouldReturn(true);
}
}

function it_returns_false_when_order_was_not_placed_by_customer(
function it_returns_false_when_order_was_not_placed_by_customer(
CustomerInterface $orderCustomer,
CustomerInterface $customer,
OrderInterface $order
Expand All @@ -40,14 +40,14 @@ function it_returns_false_when_order_was_not_placed_by_customer(
$order->getCustomer()->willReturn($orderCustomer);

$this->wasOrderPlacedByCustomer($order, $customer)->shouldReturn(false);
}
}

function it_returns_false_when_order_has_no_customer_assigned(
function it_returns_false_when_order_has_no_customer_assigned(
CustomerInterface $customer,
OrderInterface $order
): void {
$order->getCustomer()->willReturn(null);
$order->getCustomer()->willReturn(null);

$this->wasOrderPlacedByCustomer($order, $customer)->shouldReturn(false);
}
$this->wasOrderPlacedByCustomer($order, $customer)->shouldReturn(false);
}
}
8 changes: 4 additions & 4 deletions spec/Factory/OrderFactorySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ function it_creates_reorder_from_existing_order(
OrderInterface $reorder,
ChannelInterface $channel
): void {
$baseOrderFactory->createNew()->willReturn($reorder);
$reorder->setChannel($channel)->shouldBeCalled();
$baseOrderFactory->createNew()->willReturn($reorder);
$reorder->setChannel($channel)->shouldBeCalled();

$reorderProcessor->process($order, $reorder)->shouldBeCalled();
$reorderProcessor->process($order, $reorder)->shouldBeCalled();

$this->createFromExistingOrder($order, $channel);
$this->createFromExistingOrder($order, $channel);
}
}
34 changes: 11 additions & 23 deletions spec/Reorder/ReordererSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Doctrine\ORM\EntityManagerInterface;
use Nette\InvalidStateException;
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Core\Model\OrderInterface;
Expand All @@ -24,16 +23,13 @@
use Sylius\CustomerReorderPlugin\ReorderEligibility\ReorderEligibilityCheckerResponse;
use Sylius\CustomerReorderPlugin\ReorderEligibility\ResponseProcessing\EligibilityCheckerFailureResponses;
use Sylius\CustomerReorderPlugin\ReorderEligibility\ResponseProcessing\ReorderEligibilityCheckerResponseProcessorInterface;
use Symfony\Component\HttpFoundation\Session\Session;

final class ReordererSpec extends ObjectBehavior
{
function let(
OrderFactoryInterface $orderFactory,
EntityManagerInterface $entityManager,
OrderProcessorInterface $orderProcessor,
MoneyFormatterInterface $moneyFormatter,
Session $session,
ReorderEligibilityChecker $reorderEligibilityChecker,
ReorderEligibilityCheckerResponseProcessorInterface $reorderEligibilityCheckerResponseProcessor,
OrderCustomerRelationCheckerInterface $orderCustomerRelationChecker
Expand All @@ -42,8 +38,6 @@ function let(
$orderFactory,
$entityManager,
$orderProcessor,
$moneyFormatter,
$session,
$reorderEligibilityChecker,
$reorderEligibilityCheckerResponseProcessor,
$orderCustomerRelationChecker
Expand Down Expand Up @@ -87,7 +81,7 @@ function it_creates_and_persists_reorder_from_existing_order(

$reorder->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$this->reorder($order, $channel, $customer);
Expand All @@ -102,7 +96,6 @@ function it_checks_if_orders_totals_differ(
CustomerInterface $customer,
OrderInterface $order,
OrderInterface $reorder,
MoneyFormatterInterface $moneyFormatter,
ArrayCollection $promotions,
ReorderEligibilityCheckerResponse $reorderEligibilityCheckerResponse,
OrderItemInterface $firstOrderItem,
Expand All @@ -119,11 +112,9 @@ function it_checks_if_orders_totals_differ(

$reorder->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$moneyFormatter->format(100, 'USD')->willReturn('$1.00');

$reorderEligibilityCheckerResponse->getMessage()->willReturn(
EligibilityCheckerFailureResponses::TOTAL_AMOUNT_CHANGED
);
Expand All @@ -147,7 +138,6 @@ function it_checks_if_promotion_is_no_longer_available(
CustomerInterface $customer,
OrderInterface $order,
OrderInterface $reorder,
MoneyFormatterInterface $moneyFormatter,
PromotionInterface $firstPromotion,
PromotionInterface $secondPromotion,
ReorderEligibilityCheckerResponse $reorderEligibilityCheckerResponse,
Expand All @@ -156,7 +146,7 @@ function it_checks_if_promotion_is_no_longer_available(
): void {
$order->getPromotions()->willReturn(new ArrayCollection([
$firstPromotion->getWrappedObject(),
$secondPromotion->getWrappedObject()
$secondPromotion->getWrappedObject(),
]));

$orderCustomerRelationChecker->wasOrderPlacedByCustomer($order, $customer)->willReturn(true);
Expand All @@ -168,16 +158,14 @@ function it_checks_if_promotion_is_no_longer_available(

$reorder->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$moneyFormatter->format(100, 'USD')->willReturn('$1.00');

$reorderEligibilityCheckerResponse->getMessage()->willReturn(
EligibilityCheckerFailureResponses::REORDER_PROMOTIONS_CHANGED
);
$reorderEligibilityCheckerResponse->getParameters()->willReturn([
'%promotion_names%' => 'test_promotion_01, test_promotion_02'
'%promotion_names%' => 'test_promotion_01, test_promotion_02',
]);

$reorderEligibilityChecker->check($order, $reorder)->willReturn([$reorderEligibilityCheckerResponse]);
Expand Down Expand Up @@ -210,22 +198,22 @@ function it_checks_if_price_of_any_item_has_changed(

$order->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$orderCustomerRelationChecker->wasOrderPlacedByCustomer($order, $customer)->willReturn(true);

$reorder->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$reorderEligibilityCheckerResponse->getMessage()->willReturn(
EligibilityCheckerFailureResponses::REORDER_ITEMS_PRICES_CHANGED
);

$reorderEligibilityCheckerResponse->getParameters()->willReturn([
'%product_names%' => 'variant_name_02'
'%product_names%' => 'variant_name_02',
]);

$reorderEligibilityChecker->check($order, $reorder)->willReturn([$reorderEligibilityCheckerResponse]);
Expand Down Expand Up @@ -264,20 +252,20 @@ function it_checks_if_any_item_is_out_of_stock(

$order->getItems()->willReturn(new ArrayCollection([
$firstProductVariant->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$orderCustomerRelationChecker->wasOrderPlacedByCustomer($order, $customer)->willReturn(true);

$reorder->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject()
$firstOrderItem->getWrappedObject(),
]));

$reorderEligibilityCheckerResponse->getMessage()->willReturn(
EligibilityCheckerFailureResponses::ITEMS_OUT_OF_STOCK
);
$reorderEligibilityCheckerResponse->getParameters()->willReturn([
'%order_items%' => 'product_variant_02'
'%order_items%' => 'product_variant_02',
]);

$reorderEligibilityChecker->check($order, $reorder)->willReturn([$reorderEligibilityCheckerResponse]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ function it_returns_positive_result_when_prices_are_the_same(
): void {
$order->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$reorder->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$firstOrderItem->getProductName()->willReturn('test_product_name_01');
Expand All @@ -66,7 +66,7 @@ function it_returns_empty_array_when_reorder_has_no_items(
): void {
$order->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$reorder->getItems()->willReturn(new ArrayCollection([]));
Expand All @@ -90,12 +90,12 @@ function it_returns_flash_message_when_reorder_items_quantity_differ(
): void {
$order->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$reorder->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$firstOrderItem->getProductName()->willReturn('test_product_name_01');
Expand All @@ -110,7 +110,7 @@ function it_returns_flash_message_when_reorder_items_quantity_differ(
$response = new ReorderEligibilityCheckerResponse();
$response->setMessage(EligibilityCheckerFailureResponses::INSUFFICIENT_ITEM_QUANTITY);
$response->setParameters([
'%order_items%' => 'test_product_name_01, test_product_name_02'
'%order_items%' => 'test_product_name_01, test_product_name_02',
]);

$this->check($order, $reorder)->shouldBeLike([$response]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Doctrine\Common\Collections\ArrayCollection;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Model\OrderItemInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
Expand Down Expand Up @@ -47,7 +46,7 @@ function it_returns_positive_result_when_all_reorder_items_are_on_hand(
): void {
$order->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$firstOrderItem->getVariant()->willReturn($firstProductVariant);
Expand All @@ -72,7 +71,7 @@ function it_returns_violation_message_when_some_reorder_items_are_out_of_stock(
): void {
$order->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$firstOrderItem->getVariant()->willReturn($firstProductVariant);
Expand All @@ -85,7 +84,7 @@ function it_returns_violation_message_when_some_reorder_items_are_out_of_stock(

$reorderEligibilityConstraintMessageFormatter->format([
'test_name_01',
'test_name_02'
'test_name_02',
])->willReturn('test_name_01, test_name_02');

$response = new ReorderEligibilityCheckerResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ function it_returns_positive_result_when_prices_are_the_same(
): void {
$order->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$reorder->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$firstOrderItem->getProductName()->willReturn('test_product_name_01');
Expand All @@ -66,12 +66,12 @@ function it_returns_violation_message_when_some_prices_are_different(
): void {
$order->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$reorder->getItems()->willReturn(new ArrayCollection([
$firstOrderItem->getWrappedObject(),
$secondOrderItem->getWrappedObject()
$secondOrderItem->getWrappedObject(),
]));

$firstOrderItem->getProductName()->willReturn('test_product_name_01');
Expand All @@ -82,13 +82,13 @@ function it_returns_violation_message_when_some_prices_are_different(

$reorderEligibilityConstraintMessageFormatter->format([
'test_product_name_01',
'test_product_name_02'
'test_product_name_02',
])->willReturn('test_product_name_01, test_product_name_02');

$response = new ReorderEligibilityCheckerResponse();
$response->setMessage(EligibilityCheckerFailureResponses::REORDER_ITEMS_PRICES_CHANGED);
$response->setParameters([
'%product_names%' => 'test_product_name_01, test_product_name_02'
'%product_names%' => 'test_product_name_01, test_product_name_02',
]);

$this->check($order, $reorder)->shouldBeLike([$response]);
Expand Down
Loading

0 comments on commit c5d0a2b

Please sign in to comment.