diff --git a/templates/bundles/SyliusShopBundle/Checkout/Complete/_navigation.html.twig b/templates/bundles/SyliusShopBundle/Checkout/Complete/_navigation.html.twig index 8d522d7a..5b3952df 100644 --- a/templates/bundles/SyliusShopBundle/Checkout/Complete/_navigation.html.twig +++ b/templates/bundles/SyliusShopBundle/Checkout/Complete/_navigation.html.twig @@ -1,10 +1,10 @@ {% set payment = order.lastCartPayment() %} {# >>> SyliusTpayPlugin customization #} -{% if payment is not null %} - {% set payment_type = cw_tpay_get_gateway_config_value(payment.method.gatewayConfig, 'type') %} -{% else %} +{% if payment is null %} {% set payment_type = null %} +{% else %} + {% set payment_type = cw_tpay_get_gateway_config_value(payment.method.gatewayConfig, 'type') %} {% endif %} {% if payment_type in ['apple_pay', 'google_pay'] %} diff --git a/tests/E2E/Checkout/FreePaymentCheckoutTest.php b/tests/E2E/Checkout/FreePaymentCheckoutTest.php new file mode 100644 index 00000000..8ded333f --- /dev/null +++ b/tests/E2E/Checkout/FreePaymentCheckoutTest.php @@ -0,0 +1,39 @@ +loadFixtures(['addressed_free_cart.yaml']); + + $this->loginShopUser('tony@nonexisting.cw', 'sylius'); + // the cart is already addressed, so we go straight to selecting a shipping method + $this->showSelectingShippingMethodStep(); + $this->processWithDefaultShippingMethod(); + } + + public function test_it_completes_the_checkout_if_order_total_is_0(): void + { + // total is 0.00 so we do not choose payment method and go straight to complete + $this->placeOrder(); + + $this->assertPageTitleContains('Thank you!'); + } +} diff --git a/tests/E2E/Resources/fixtures/addressed_free_cart.yaml b/tests/E2E/Resources/fixtures/addressed_free_cart.yaml new file mode 100644 index 00000000..40b3fcfa --- /dev/null +++ b/tests/E2E/Resources/fixtures/addressed_free_cart.yaml @@ -0,0 +1,109 @@ +include: + - common/channel.yaml + - common/country.yaml + - common/customer.yaml + - common/payment_method.yaml + - common/shipping_category.yaml + - free_shipping_method.yaml + - common/tax_category.yaml + +Sylius\Component\Core\Model\Product: + product: + fallbackLocale: en_US + currentLocale: en + code: 'MUG_SW' + translations: + - '@product_translation' + +Sylius\Component\Core\Model\ProductTranslation: + product_translation: + name: 'Mug' + slug: 'mug' + locale: 'en_US' + translatable: '@product' + +Sylius\Component\Product\Model\ProductVariantTranslation: + product_variant_translation: + name: 'Mug' + locale: en_US + translatable: '@product_variant' + +Sylius\Component\Core\Model\ProductVariant: + product_variant: + code: 'MUG' + version: 1 + product: '@product' + fallbackLocale: en_US + currentLocale: en + position: 1 + optionValues: ['@product_option_value_color_blue'] + channelPricings: + channel_web: '@product_variant_channel_web_pricing' + translations: + - '@product_variant_translation' + enabled: true + tracked: true + onHold: 0 + onHand: 10 + weight: 100.50 + width: 100.50 + height: 100.50 + depth: 100.50 + taxCategory: '@tax_category_default' + shippingCategory: '@shipping_category_default' + shippingRequired: true + +Sylius\Component\Core\Model\ChannelPricing: + product_variant_channel_web_pricing: + channelCode: 'WEB' + price: 00 + +Sylius\Component\Product\Model\ProductOption: + product_option_color: + code: 'COLOR' + currentLocale: 'en_US' + translations: + - '@product_option_translation_en_EN' + +Sylius\Component\Product\Model\ProductOptionTranslation: + product_option_translation_en_EN: + locale: 'en_US' + name: 'Color' + translatable: '@product_option_color' + +Sylius\Component\Product\Model\ProductOptionValue: + product_option_value_color_blue: + code: 'COLOR_BLUE' + currentLocale: 'en_US' + fallbackLocale: 'en_US' + option: '@product_option_color' + translations: + - '@product_option_value_translation_blue' + +Sylius\Component\Product\Model\ProductOptionValueTranslation: + product_option_value_translation_blue: + locale: 'en_US' + value: 'Blue' + translatable: '@product_option_value_color_blue' + +App\Entity\Order: + addressed_cart: + channel: '@channel_web' + currencyCode: 'USD' + localeCode: 'en_US' + customer: '@customer_tony' + state: 'cart' + checkoutState: 'addressed' + createdByGuest: false + shippingAddress: '@address_tony' + billingAddress: '@address_tony' + __calls: + - addItem: ["@order_item"] + +Sylius\Component\Core\Model\OrderItem: + order_item: + variant: '@product_variant' + +Sylius\Component\Core\Model\OrderItemUnit: + order_item_unit: + __construct: ['@order_item'] diff --git a/tests/E2E/Resources/fixtures/free_shipping_method.yaml b/tests/E2E/Resources/fixtures/free_shipping_method.yaml new file mode 100644 index 00000000..d3766555 --- /dev/null +++ b/tests/E2E/Resources/fixtures/free_shipping_method.yaml @@ -0,0 +1,32 @@ +Sylius\Component\Core\Model\ShippingMethod: + shipping_method_free: + code: 'FREE' + enabled: true + calculator: 'flat_rate' + configuration: + WEB: + amount: 00 + MOBILE: + amount: 00 + zone: '@zone_world' + currentLocale: 'en_US' + translations: ["@shipping_method_translation_free"] + channels: ["@channel_web"] + +Sylius\Component\Shipping\Model\ShippingMethodTranslation: + shipping_method_translation_free: + name: 'FREE' + locale: 'en_US' + description: '' + translatable: '@shipping_method_free' + +Sylius\Component\Addressing\Model\ZoneMember: + zone_member_{US, FR, DE}: + code: '' + +Sylius\Component\Addressing\Model\Zone: + zone_world: + code: 'WORLD' + name: 'World' + type: 'country' + members: ['@zone_member_US', '@zone_member_FR', '@zone_member_DE'] diff --git a/tests/Unit/ContextProvider/BankListContextProviderTest.php b/tests/Unit/ContextProvider/BankListContextProviderTest.php index 25140ddd..0c3e0a30 100644 --- a/tests/Unit/ContextProvider/BankListContextProviderTest.php +++ b/tests/Unit/ContextProvider/BankListContextProviderTest.php @@ -106,5 +106,4 @@ private function createTestObject(): BankListContextProvider { return new BankListContextProvider($this->bankListProvider->reveal()); } - }