Skip to content

Commit

Permalink
OP-554 - Fix behats tests, update composer.json
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusz-rup committed Jan 15, 2025
1 parent 879bb72 commit 9554bb6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ tests/Application/web/*

/etc/build/*
!/etc/build/.gitkeep
.idea
package-lock.json
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"require-dev": {
"behat/behat": "^3.14",
"behat/mink-selenium2-driver": "^1.6",
"behat/mink-selenium2-driver": "1.6.0",
"bitbag/coding-standard": "^3.0",
"dmore/behat-chrome-extension": "^1.4",
"dmore/chrome-mink-driver": "^2.9",
Expand Down
14 changes: 6 additions & 8 deletions tests/Behat/Context/Setup/RelatedProductsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\OrderPaymentStates;
use Sylius\Component\Core\Model\OrderItemInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
Expand All @@ -35,6 +36,8 @@ public function __construct(
private readonly FactoryInterface $orderItemFactory,
private readonly FactoryInterface $customerFactory,
private readonly WorkflowInterface $orderWorkflow,
private readonly WorkflowInterface $orderPaymentWorkflow,
private readonly WorkflowInterface $shipmentWorkflow,
private readonly OrderItemQuantityModifierInterface $itemQuantityModifier,
private readonly EntityManagerInterface $entityManager
) {
Expand Down Expand Up @@ -63,9 +66,7 @@ private function createOrdersWithProducts(
for ($i = 0; $i < $numberOfOrders; ++$i) {
$order = $this->createOrder();


$this->orderWorkflow->apply($order, OrderTransitions::TRANSITION_CREATE);

$this->applyPaymentTransitionOnOrder($order, PaymentTransitions::TRANSITION_COMPLETE);

foreach ($products as $product) {
Expand Down Expand Up @@ -119,8 +120,7 @@ private function createCustomer(): CustomerInterface
private function applyPaymentTransitionOnOrder(OrderInterface $order, string $transition)
{
foreach ($order->getPayments() as $payment) {
$this->orderWorkflow->get($payment, PaymentTransitions::GRAPH)
->apply($payment, $transition);
$this->orderWorkflow->apply($payment, $transition);
}
}

Expand All @@ -137,13 +137,11 @@ private function addVariantWithPriceToOrder(OrderInterface $order, ProductVarian

private function payOrder(OrderInterface $order): void
{
$this->orderWorkflow->get($order, OrderPaymentTransitions::GRAPH)
->apply(OrderPaymentTransitions::TRANSITION_PAY);
$this->orderPaymentWorkflow->apply($order,OrderPaymentTransitions::TRANSITION_PAY);
}

private function shipOrder(OrderInterface $order): void
{
$this->orderWorkflow->get($order, OrderShippingTransitions::GRAPH)
->apply(OrderShippingTransitions::TRANSITION_SHIP);
$this->shipmentWorkflow->apply($order,OrderShippingTransitions::TRANSITION_SHIP);
}
}
2 changes: 2 additions & 0 deletions tests/Behat/Resources/services/contexts/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<argument type="service" id="sylius.factory.order_item" />
<argument type="service" id="sylius.factory.customer" />
<argument type="service" id="state_machine.sylius_order" />
<argument type="service" id="state_machine.sylius_order_payment" />
<argument type="service" id="state_machine.sylius_order_shipping" />
<argument type="service" id="sylius.modifier.order_item_quantity"/>
<argument type="service" id="doctrine.orm.entity_manager" />
</service>
Expand Down

0 comments on commit 9554bb6

Please sign in to comment.