From 5df2bfb537185829678419c6c2a8aeca649f5b49 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Wed, 27 Jul 2016 15:47:23 +0200 Subject: [PATCH] Adapt Behat scenarios to brand new locales logic --- .../managing_channels/adding_channel.feature | 3 +++ ...add_disabled_channel_when_no_other_exist.feature | 6 ++++-- ...lecting_currencies_available_for_channel.feature | 9 ++++++--- .../selecting_default_tax_zone_for_channel.feature | 6 ++++-- .../selecting_locales_available_for_channel.feature | 13 +++++++------ ...ng_payment_methods_available_for_channel.feature | 6 ++++-- ...g_shipping_methods_available_for_channel.feature | 6 ++++-- ...ing_tax_calculation_strategy_for_channel.feature | 7 +++++-- .../Context/Ui/Admin/ManagingChannelsContext.php | 9 +++++++++ src/Sylius/Behat/Page/Admin/Channel/CreatePage.php | 11 +++++++++++ .../Page/Admin/Channel/CreatePageInterface.php | 5 +++++ tests/DataFixtures/ORM/resources/channels.yml | 6 ++++++ 12 files changed, 68 insertions(+), 19 deletions(-) diff --git a/features/channel/managing_channels/adding_channel.feature b/features/channel/managing_channels/adding_channel.feature index c47214b2ce..57fe8629b5 100644 --- a/features/channel/managing_channels/adding_channel.feature +++ b/features/channel/managing_channels/adding_channel.feature @@ -6,6 +6,7 @@ Feature: Adding a new channel Background: Given the store has currency "Euro" + And the store has locale "English (United States)" And I am logged in as an administrator @ui @@ -14,6 +15,7 @@ Feature: Adding a new channel When I specify its code as "MOBILE" And I name it "Mobile channel" And I choose "Euro" as a default currency + And I choose "English (United States)" as a default locale And I add it Then I should be notified that it has been successfully created And the channel "Mobile channel" should appear in the registry @@ -27,6 +29,7 @@ Feature: Adding a new channel And I set its hostname as "m.avengers-gear.com" And I define its color as "blue" And I choose "Euro" as a default currency + And I choose "English (United States)" as a default locale And I add it Then I should be notified that it has been successfully created And the channel "Mobile channel" should appear in the registry diff --git a/features/channel/managing_channels/not_being_able_to_add_disabled_channel_when_no_other_exist.feature b/features/channel/managing_channels/not_being_able_to_add_disabled_channel_when_no_other_exist.feature index d4631d5539..f5ebcde43a 100644 --- a/features/channel/managing_channels/not_being_able_to_add_disabled_channel_when_no_other_exist.feature +++ b/features/channel/managing_channels/not_being_able_to_add_disabled_channel_when_no_other_exist.feature @@ -5,8 +5,9 @@ Feature: Not being able to add a disabled channel when no other exist I want to be prevented from adding disabled channel when no other exist Background: - Given I am logged in as an administrator - And the store has currency "Euro" + Given the store has currency "Euro" + And the store has locale "English (United States)" + And I am logged in as an administrator @ui Scenario: Adding a new disabled channel should result @@ -14,6 +15,7 @@ Feature: Not being able to add a disabled channel when no other exist When I specify its code as "MOBILE" And I name it "Mobile channel" And I choose "Euro" as a default currency + And I choose "English (United States)" as a default locale And I disable it And I add it Then I should be notified that at least one channel has to be defined diff --git a/features/channel/managing_channels/selecting_currencies_available_for_channel.feature b/features/channel/managing_channels/selecting_currencies_available_for_channel.feature index e50493838a..6a418810ed 100644 --- a/features/channel/managing_channels/selecting_currencies_available_for_channel.feature +++ b/features/channel/managing_channels/selecting_currencies_available_for_channel.feature @@ -5,7 +5,8 @@ Feature: Selecting available currencies for a channel I want to be able to select available currencies Background: - Given the store has currency Euro + Given the store has currency "Euro" + And the store has locale "English (United States)" And I am logged in as an administrator @ui @@ -13,7 +14,8 @@ Feature: Selecting available currencies for a channel Given I want to create a new channel When I specify its code as MOBILE And I name it "Mobile store" - And I allow for paying in Euro + And I allow for paying in "Euro" + And I choose "English (United States)" as a default locale And I add it Then I should be notified that it has been successfully created And paying in Euro should be possible for the "Mobile store" channel @@ -22,7 +24,8 @@ Feature: Selecting available currencies for a channel Scenario: Adding currencies to an existing channel Given the store operates on a channel named "Web store" And I want to modify this channel - When I allow for paying in Euro + When I allow for paying in "Euro" + And I choose "English (United States)" as a default locale And I save my changes Then I should be notified that it has been successfully edited And paying in Euro should be possible for the "Web store" channel diff --git a/features/channel/managing_channels/selecting_default_tax_zone_for_channel.feature b/features/channel/managing_channels/selecting_default_tax_zone_for_channel.feature index a70110e87d..a7552f9a9e 100644 --- a/features/channel/managing_channels/selecting_default_tax_zone_for_channel.feature +++ b/features/channel/managing_channels/selecting_default_tax_zone_for_channel.feature @@ -5,9 +5,10 @@ Feature: Selecting default tax zone for a channel I want to be able to select default tax zone Background: - Given there is a zone "EU" containing all members of the European Union + Given the store has currency "Euro" + And the store has locale "English (United States)" + And there is a zone "EU" containing all members of the European Union And there is a zone "The Rest of the World" containing all other countries - And the store has currency "Euro" And I am logged in as an administrator @ui @@ -17,6 +18,7 @@ Feature: Selecting default tax zone for a channel And I name it "Mobile store" And I select the "European Union" as default tax zone And I choose "Euro" as a default currency + And I choose "English (United States)" as a default locale And I add it Then I should be notified that it has been successfully created And the default tax zone for the "Mobile store" channel should be "European Union" diff --git a/features/channel/managing_channels/selecting_locales_available_for_channel.feature b/features/channel/managing_channels/selecting_locales_available_for_channel.feature index 92b25593c7..c6ffe7c2b2 100644 --- a/features/channel/managing_channels/selecting_locales_available_for_channel.feature +++ b/features/channel/managing_channels/selecting_locales_available_for_channel.feature @@ -5,8 +5,8 @@ Feature: Selecting available locales for a channel I want to be able to select available locales Background: - Given the store has locale "Norwegian (Norway)" - And the store has currency "Euro" + Given the store has currency "Euro" + And the store has locale "English (United States)" And I am logged in as an administrator @ui @@ -14,17 +14,18 @@ Feature: Selecting available locales for a channel Given I want to create a new channel When I specify its code as "MOBILE" And I name it "Mobile channel" - And I make it available in "Norwegian (Norway)" + And I make it available in "English (United States)" And I choose "Euro" as a default currency + And I choose "English (United States)" as a default locale And I add it Then I should be notified that it has been successfully created - And the channel "Mobile channel" should be available in "Norwegian (Norway)" + And the channel "Mobile channel" should be available in "English (United States)" @ui Scenario: Adding locales to an existing channel Given the store operates on a channel named "Web Channel" And I want to modify this channel - When I make it available in "Norwegian (Norway)" + When I make it available in "English (United States)" And I save my changes Then I should be notified that it has been successfully edited - And the channel "Web channel" should be available in "Norwegian (Norway)" + And the channel "Web channel" should be available in "English (United States)" diff --git a/features/channel/managing_channels/selecting_payment_methods_available_for_channel.feature b/features/channel/managing_channels/selecting_payment_methods_available_for_channel.feature index bb90ea9385..5068f68a28 100644 --- a/features/channel/managing_channels/selecting_payment_methods_available_for_channel.feature +++ b/features/channel/managing_channels/selecting_payment_methods_available_for_channel.feature @@ -5,8 +5,9 @@ Feature: Selecting available payment methods for a channel I want to be able to select available payment methods Background: - Given the store has a payment method "Offline" with a code "OFF" - And the store has currency "Euro" + Given the store has currency "Euro" + And the store has locale "English (United States)" + And the store has a payment method "Offline" with a code "OFF" And I am logged in as an administrator @ui @@ -16,6 +17,7 @@ Feature: Selecting available payment methods for a channel And I name it "Mobile store" And I select the "Offline" payment method And I choose "Euro" as a default currency + And I choose "English (United States)" as a default locale And I add it Then I should be notified that it has been successfully created And the "Offline" payment method should be available for the "Mobile store" channel diff --git a/features/channel/managing_channels/selecting_shipping_methods_available_for_channel.feature b/features/channel/managing_channels/selecting_shipping_methods_available_for_channel.feature index 1b01c1e055..c9747ea532 100644 --- a/features/channel/managing_channels/selecting_shipping_methods_available_for_channel.feature +++ b/features/channel/managing_channels/selecting_shipping_methods_available_for_channel.feature @@ -5,9 +5,10 @@ Feature: Selecting available shipping methods for a channel I want to be able to select available shipping methods Background: - Given there is a zone "EU" containing all members of the European Union + Given the store has currency "Euro" + And the store has locale "English (United States)" + And there is a zone "EU" containing all members of the European Union And the store allows shipping with "UPS Carrier" identified by "UPS_CARRIER" - And the store has currency "Euro" And I am logged in as an administrator @ui @@ -17,6 +18,7 @@ Feature: Selecting available shipping methods for a channel And I name it "Mobile store" And I select the "UPS Carrier" shipping method And I choose "Euro" as a default currency + And I choose "English (United States)" as a default locale And I add it Then I should be notified that it has been successfully created And the "UPS Carrier" shipping method should be available for the "Mobile store" channel diff --git a/features/channel/managing_channels/selecting_tax_calculation_strategy_for_channel.feature b/features/channel/managing_channels/selecting_tax_calculation_strategy_for_channel.feature index 0a39e230cf..c40448e5e6 100644 --- a/features/channel/managing_channels/selecting_tax_calculation_strategy_for_channel.feature +++ b/features/channel/managing_channels/selecting_tax_calculation_strategy_for_channel.feature @@ -5,8 +5,9 @@ Feature: Selecting tax calculation strategy for a channel I want to be able to select tax calculation strategy Background: - Given I am logged in as an administrator - And the store has currency "Euro" + Given the store has currency "Euro" + And the store has locale "English (United States)" + And I am logged in as an administrator @ui Scenario: Adding a new channel with implicitly selected tax calculation strategy @@ -14,6 +15,7 @@ Feature: Selecting tax calculation strategy for a channel When I specify its code as "MOBILE" And I name it "Mobile store" And I choose "Euro" as a default currency + And I choose "English (United States)" as a default locale And I add it Then I should be notified that it has been successfully created And the tax calculation strategy for the "Mobile store" channel should be "Order items based" @@ -25,6 +27,7 @@ Feature: Selecting tax calculation strategy for a channel And I select the "Order item units based" as tax calculation strategy And I name it "Mobile store" And I choose "Euro" as a default currency + And I choose "English (United States)" as a default locale And I add it Then I should be notified that it has been successfully created And the tax calculation strategy for the "Mobile store" channel should be "Order item units based" diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php index 81950f4a4e..383b1db9ec 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php @@ -109,6 +109,15 @@ final class ManagingChannelsContext implements Context $this->createPage->chooseDefaultCurrency($currency); } + /** + * @When I choose :locale as a default locale + * @When I do not choose default locale + */ + public function iChooseAsADefaultLocale($locale = null) + { + $this->createPage->chooseDefaultLocale($locale); + } + /** * @When I add it * @When I try to add it diff --git a/src/Sylius/Behat/Page/Admin/Channel/CreatePage.php b/src/Sylius/Behat/Page/Admin/Channel/CreatePage.php index 91a1c9f9e5..24dd283fd3 100644 --- a/src/Sylius/Behat/Page/Admin/Channel/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/Channel/CreatePage.php @@ -83,6 +83,16 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface $this->getDocument()->selectFieldOption('Default tax zone', $taxZone); } + /** + * {@inheritdoc} + */ + public function chooseDefaultLocale($locale) + { + if (null !== $locale) { + $this->getElement('default_locale')->selectOption($locale); + } + } + /** * {@inheritdoc} */ @@ -121,6 +131,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface 'name' => '#sylius_channel_name', 'default_currency' => '#sylius_channel_defaultCurrency', 'currencies' => '#sylius_channel_currencies', + 'default_locale' => '#sylius_channel_defaultLocale', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php b/src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php index d69f1b61e1..98481d3312 100644 --- a/src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php +++ b/src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php @@ -72,6 +72,11 @@ interface CreatePageInterface extends BaseCreatePageInterface */ public function chooseDefaultTaxZone($taxZone); + /** + * @param string $locale + */ + public function chooseDefaultLocale($locale); + /** * @param string $currency */ diff --git a/tests/DataFixtures/ORM/resources/channels.yml b/tests/DataFixtures/ORM/resources/channels.yml index 3ed5f2da07..bf0fd0bd97 100644 --- a/tests/DataFixtures/ORM/resources/channels.yml +++ b/tests/DataFixtures/ORM/resources/channels.yml @@ -5,6 +5,7 @@ Sylius\Component\Core\Model\Channel: hostname: "localhost" description: "Lorem ipsum" defaultCurrency: "@currency" + defaultLocale: "@locale" color: "black" enabled: true taxCalculationStrategy: "order_items_based" @@ -14,3 +15,8 @@ Sylius\Component\Currency\Model\Currency: code: EUR exchangeRate: 1 enabled: true + +Sylius\Component\Locale\Model\Locale: + locale: + code: en_US + enabled: true