[DX] Cleanup currency feature

This commit is contained in:
Łukasz Chruściel 2016-04-22 10:36:24 +02:00
parent a5d6e1839f
commit 8fe4fa2aef
4 changed files with 20 additions and 10 deletions

View file

@ -15,7 +15,7 @@
<parameters>
<parameter key="sylius.behat.context.ui.admin.managing_channels.class">Sylius\Behat\Context\Ui\Admin\ManagingChannelsContext</parameter>
<parameter key="sylius.behat.context.ui.admin.managing_countries.class">Sylius\Behat\Context\Ui\Admin\ManagingCountriesContext</parameter>
<parameter key="sylius.behat.context.ui.admin.managing_currency.class">Sylius\Behat\Context\Ui\Admin\ManagingCurrenciesContext</parameter>
<parameter key="sylius.behat.context.ui.admin.managing_currencies.class">Sylius\Behat\Context\Ui\Admin\ManagingCurrenciesContext</parameter>
<parameter key="sylius.behat.context.ui.admin.managing_customers.class">Sylius\Behat\Context\Ui\Admin\ManagingCustomersContext</parameter>
<parameter key="sylius.behat.context.ui.admin.managing_locales.class">Sylius\Behat\Context\Ui\Admin\ManagingLocalesContext</parameter>
<parameter key="sylius.behat.context.ui.admin.managing_payment_methods.class">Sylius\Behat\Context\Ui\Admin\ManagingPaymentMethodsContext</parameter>
@ -54,7 +54,7 @@
<tag name="sylius.behat.context" />
</service>
<service id="sylius.behat.context.ui.admin.managing_currency" class="%sylius.behat.context.ui.admin.managing_currency.class%" scope="scenario">
<service id="sylius.behat.context.ui.admin.managing_currencies" class="%sylius.behat.context.ui.admin.managing_currencies.class%" scope="scenario">
<argument type="service" id="sylius.behat.page.admin.currency.index" />
<argument type="service" id="sylius.behat.page.admin.currency.create" />
<argument type="service" id="sylius.behat.page.admin.currency.update" />

View file

@ -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"

View file

@ -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

View file

@ -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);