From 8fe4fa2aef6f06a598d33a9b620656d183dc60a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Chru=C5=9Bciel?= Date: Fri, 22 Apr 2016 10:36:24 +0200 Subject: [PATCH] [DX] Cleanup currency feature --- etc/behat/services/contexts/ui.xml | 4 ++-- .../suites/ui/currency/managing_currencies.yml | 6 +++--- .../browsing_currencies.feature | 4 +--- .../Behat/Context/Setup/CurrencyContext.php | 16 ++++++++++++++-- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/etc/behat/services/contexts/ui.xml b/etc/behat/services/contexts/ui.xml index ed226ece56..1d0e8d48c2 100644 --- a/etc/behat/services/contexts/ui.xml +++ b/etc/behat/services/contexts/ui.xml @@ -15,7 +15,7 @@ Sylius\Behat\Context\Ui\Admin\ManagingChannelsContext Sylius\Behat\Context\Ui\Admin\ManagingCountriesContext - Sylius\Behat\Context\Ui\Admin\ManagingCurrenciesContext + Sylius\Behat\Context\Ui\Admin\ManagingCurrenciesContext Sylius\Behat\Context\Ui\Admin\ManagingCustomersContext Sylius\Behat\Context\Ui\Admin\ManagingLocalesContext Sylius\Behat\Context\Ui\Admin\ManagingPaymentMethodsContext @@ -54,7 +54,7 @@ - + diff --git a/etc/behat/suites/ui/currency/managing_currencies.yml b/etc/behat/suites/ui/currency/managing_currencies.yml index 61123e4386..7178be2cb1 100644 --- a/etc/behat/suites/ui/currency/managing_currencies.yml +++ b/etc/behat/suites/ui/currency/managing_currencies.yml @@ -3,7 +3,7 @@ default: suites: - ui_managing_currency: + ui_managing_currencies: contexts_as_services: - sylius.behat.context.hook.doctrine_orm @@ -14,6 +14,6 @@ default: - sylius.behat.context.setup.security - sylius.behat.context.setup.currency - - sylius.behat.context.ui.admin.managing_currency + - sylius.behat.context.ui.admin.managing_currencies filters: - tags: @managing_currencies && @ui + tags: "@managing_currencies && @ui" diff --git a/features/currency/managing_currency/browsing_currencies.feature b/features/currency/managing_currency/browsing_currencies.feature index d760439a54..876cacf928 100644 --- a/features/currency/managing_currency/browsing_currencies.feature +++ b/features/currency/managing_currency/browsing_currencies.feature @@ -5,9 +5,7 @@ Feature: Browsing currencies I want to browse currencies Background: - Given the store has currency "Euro" - And the store has currency "British Pound Sterling" - And the store has currency "US Dollar" + Given the store has currency "Euro", "British Pound Sterling" and "US Dollar" And I am logged in as an administrator @ui diff --git a/src/Sylius/Behat/Context/Setup/CurrencyContext.php b/src/Sylius/Behat/Context/Setup/CurrencyContext.php index 802d0df34d..01f4f4099b 100644 --- a/src/Sylius/Behat/Context/Setup/CurrencyContext.php +++ b/src/Sylius/Behat/Context/Setup/CurrencyContext.php @@ -14,6 +14,7 @@ namespace Sylius\Behat\Context\Setup; use Behat\Behat\Context\Context; use Sylius\Component\Core\Test\Services\SharedStorageInterface; use Sylius\Component\Currency\Converter\CurrencyNameConverterInterface; +use Sylius\Component\Currency\Model\CurrencyInterface; use Sylius\Component\Resource\Factory\FactoryInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; @@ -82,6 +83,16 @@ final class CurrencyContext implements Context $this->createCurrency($currencyName); } + /** + * @Given the store has currency :firstCurrencyName, :secondCurrencyName and :thirdCurrencyName + */ + public function theStoreHasCurrencyAnd($firstCurrencyName, $secondCurrencyName, $thirdCurrencyName) + { + $this->createCurrency($firstCurrencyName); + $this->createCurrency($secondCurrencyName); + $this->createCurrency($thirdCurrencyName); + } + /** * @Given the store has disabled currency :currencyName */ @@ -105,11 +116,12 @@ final class CurrencyContext implements Context */ private function createCurrency($currencyName, $enabled = true, $exchangeRate = 1.0) { + /** @var CurrencyInterface $currency */ $currency = $this->currencyFactory->createNew(); $currency->setCode($this->currencyNameConverter->convertToCode($currencyName)); $currency->setExchangeRate($exchangeRate); - if (!$enabled) { - $currency->disable(); + if (is_bool($enabled)) { + $currency->setEnabled($enabled); } $this->sharedStorage->set('currency', $currency);