mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[Behat] Refactor behats
This commit is contained in:
parent
17d0041d23
commit
fa872b41d0
7 changed files with 55 additions and 21 deletions
|
|
@ -55,6 +55,7 @@ final readonly class ManagingOrdersContext implements Context
|
|||
* @Given /^I am viewing the summary of (this order)$/
|
||||
* @Given I am viewing the summary of the order :order
|
||||
* @When I view the summary of the order :order
|
||||
* @When /^I view the summary of the (order placed by "[^"]+")$/
|
||||
*/
|
||||
public function iSeeTheOrder(OrderInterface $order): void
|
||||
{
|
||||
|
|
@ -120,7 +121,6 @@ final readonly class ManagingOrdersContext implements Context
|
|||
$this->client->addRequestData('tracking', $trackingCode);
|
||||
$this->client->update();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^I try to view the summary of the (customer's latest cart)$/
|
||||
*/
|
||||
|
|
@ -1267,6 +1267,15 @@ final readonly class ManagingOrdersContext implements Context
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see that customer's IP address is :ipAddress
|
||||
*/
|
||||
public function iShouldSeeCustomersIpAddress(
|
||||
string $ipAddress,
|
||||
): void {
|
||||
Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'customerIp'), $ipAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $address
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -130,6 +130,20 @@ final readonly class OrderContext implements Context
|
|||
$this->objectManager->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^there is a (customer "[^"]+") that placed order with ("[^"]+" product) to ("[^"]+" based billing address) with ("[^"]+" shipping method) and ("[^"]+" payment) method without completing it$/
|
||||
*/
|
||||
public function thereIsACustomerThatPlacedOrderWithProductToBasedBillingAddressWithShippingMethodAndPaymentMethodWithoutCompletingIt(
|
||||
CustomerInterface $customer,
|
||||
ProductInterface $product,
|
||||
AddressInterface $address,
|
||||
ShippingMethodInterface $shippingMethod,
|
||||
PaymentMethodInterface $paymentMethod,
|
||||
): void {
|
||||
$this->placeOrder($product, $shippingMethod, $address, $paymentMethod, $customer, 1, false);
|
||||
$this->objectManager->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^the guest customer placed order with ("[^"]+" product) for "([^"]+)" and ("[^"]+" based billing address) with ("[^"]+" shipping method) and ("[^"]+" payment)$/
|
||||
*/
|
||||
|
|
@ -876,7 +890,7 @@ final readonly class OrderContext implements Context
|
|||
/** @var OrderInterface $order */
|
||||
$order = $this->orderFactory->createNew();
|
||||
|
||||
$order->setCustomer($customer);
|
||||
$order->setCustomerWithAuthorization($customer);
|
||||
$order->setChannel($channel ?? $this->sharedStorage->get('channel'));
|
||||
$order->setLocaleCode($this->sharedStorage->get('locale')->getCode());
|
||||
$order->setCurrencyCode($order->getChannel()->getBaseCurrency()->getCode());
|
||||
|
|
@ -932,6 +946,7 @@ final readonly class OrderContext implements Context
|
|||
ShippingMethodInterface $shippingMethod,
|
||||
AddressInterface $address,
|
||||
PaymentMethodInterface $paymentMethod,
|
||||
bool $completeOrder = true,
|
||||
): void {
|
||||
$order->setShippingAddress($address);
|
||||
$order->setBillingAddress(clone $address);
|
||||
|
|
@ -939,7 +954,9 @@ final readonly class OrderContext implements Context
|
|||
$this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_ADDRESS);
|
||||
|
||||
$this->proceedSelectingShippingAndPaymentMethod($order, $shippingMethod, $paymentMethod);
|
||||
$this->completeCheckout($order);
|
||||
if ($completeOrder) {
|
||||
$this->completeCheckout($order);
|
||||
}
|
||||
}
|
||||
|
||||
private function completeCheckout(OrderInterface $order): void
|
||||
|
|
@ -1139,6 +1156,7 @@ final readonly class OrderContext implements Context
|
|||
PaymentMethodInterface $paymentMethod,
|
||||
CustomerInterface $customer,
|
||||
int $number,
|
||||
bool $completeOrder = true,
|
||||
): void {
|
||||
$variant = $this->getProductVariant($product);
|
||||
|
||||
|
|
@ -1153,12 +1171,17 @@ final readonly class OrderContext implements Context
|
|||
|
||||
$order = $this->createOrder($customer, '#00000' . $number);
|
||||
$order->addItem($item);
|
||||
$order->setCustomer($customer);
|
||||
|
||||
$this->checkoutUsing($order, $shippingMethod, clone $address, $paymentMethod);
|
||||
$this->applyPaymentTransitionOnOrder($order, PaymentTransitions::TRANSITION_COMPLETE);
|
||||
$this->checkoutUsing($order, $shippingMethod, clone $address, $paymentMethod, $completeOrder);
|
||||
|
||||
if ($completeOrder) {
|
||||
$this->applyPaymentTransitionOnOrder($order, PaymentTransitions::TRANSITION_COMPLETE);
|
||||
}
|
||||
|
||||
$this->objectManager->persist($order);
|
||||
$this->sharedStorage->set('order', $order);
|
||||
$this->sharedStorage->set('cart_token', $order->getTokenValue());
|
||||
}
|
||||
|
||||
private function getProductVariant(ProductInterface $product): ProductVariantInterface
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ final readonly class ManagingOrdersContext implements Context
|
|||
* @Given /^I am viewing the summary of (this order)$/
|
||||
* @Given I am viewing the summary of the order :order
|
||||
* @When I view the summary of the order :order
|
||||
* @When /^I view the summary of the (order placed by "[^"]+")$/
|
||||
*/
|
||||
public function iViewTheSummaryOfTheOrder(OrderInterface $order): void
|
||||
{
|
||||
|
|
@ -865,20 +866,12 @@ final readonly class ManagingOrdersContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then /^(the administrator) should know about IP address of (this order made by "[^"]+")$/
|
||||
* @Then I should see that customer's IP address is :ipAddress
|
||||
*/
|
||||
public function theAdministratorShouldKnowAboutIPAddressOfThisOrderMadeBy(
|
||||
AdminUserInterface $user,
|
||||
OrderInterface $order,
|
||||
public function iShouldSeeCustomersIpAddress(
|
||||
string $ipAddress,
|
||||
): void {
|
||||
$this->sharedSecurityService->performActionAsAdminUser(
|
||||
$user,
|
||||
function () use ($order) {
|
||||
$this->showPage->open(['id' => $order->getId()]);
|
||||
|
||||
Assert::notSame($this->showPage->getIpAddressAssigned(), '');
|
||||
},
|
||||
);
|
||||
Assert::same($this->showPage->getIpAddressAssigned(), $ipAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -81,8 +81,12 @@ final class CheckoutCompleteContext implements Context
|
|||
* @When I confirm my order
|
||||
* @When I try to confirm my order
|
||||
*/
|
||||
public function iConfirmMyOrder()
|
||||
public function iConfirmMyOrder(): void
|
||||
{
|
||||
if (!$this->completePage->isOpen()) {
|
||||
$this->completePage->open();
|
||||
}
|
||||
|
||||
$this->completePage->confirmOrder();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ class ShowPage extends SymfonyPage implements ShowPageInterface
|
|||
'cancel_order' => '[data-test-cancel-order]',
|
||||
'currency' => '[data-test-currency]',
|
||||
'customer_email' => '[data-test-customer] [data-test-email]',
|
||||
'ip_address' => '#ipAddress',
|
||||
'ip_address' => '[data-test-ip-address]',
|
||||
'item' => '[data-test-item="%name%"]',
|
||||
'items_total' => '[data-test-items-total]',
|
||||
'notes' => '[data-test-notes]',
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ default:
|
|||
- sylius.behat.context.transform.user
|
||||
- sylius.behat.context.transform.zone
|
||||
- Sylius\Behat\Context\Transform\CatalogPromotionContext
|
||||
- sylius.behat.context.transform.customer
|
||||
|
||||
- sylius.behat.context.setup.address
|
||||
- sylius.behat.context.setup.admin_user
|
||||
|
|
@ -48,13 +49,15 @@ default:
|
|||
- sylius.behat.context.setup.user
|
||||
- sylius.behat.context.setup.zone
|
||||
- Sylius\Behat\Context\Setup\CatalogPromotionContext
|
||||
- sylius.behat.context.setup.admin_security
|
||||
- sylius.behat.context.setup.order
|
||||
|
||||
- sylius.behat.context.api.shop.cart
|
||||
- sylius.behat.context.api.shop.channel
|
||||
- sylius.behat.context.api.shop.address
|
||||
- sylius.behat.context.api.shop.checkout
|
||||
- sylius.behat.context.api.shop.login
|
||||
- sylius.behat.context.api.shop.order
|
||||
- sylius.behat.context.api.admin.login
|
||||
- sylius.behat.context.api.admin.managing_orders
|
||||
|
||||
- sylius.behat.context.api.email
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ default:
|
|||
- sylius.behat.context.setup.taxation
|
||||
- sylius.behat.context.setup.user
|
||||
- sylius.behat.context.setup.zone
|
||||
- sylius.behat.context.setup.order
|
||||
- sylius.behat.context.setup.admin_security
|
||||
- Sylius\Behat\Context\Setup\CatalogPromotionContext
|
||||
|
||||
- sylius.behat.context.ui.admin.managing_orders
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue