mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Core] Renamed 'defaultCurrency' to 'baseCurrency' on Channel model
This commit is contained in:
parent
944ae39662
commit
473cda7ec2
30 changed files with 94 additions and 52 deletions
42
app/migrations/Version20161117163856.php
Normal file
42
app/migrations/Version20161117163856.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Sylius\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
class Version20161117163856 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE sylius_channel DROP FOREIGN KEY FK_16C8119EECD792C0');
|
||||
$this->addSql('DROP INDEX IDX_16C8119EECD792C0 ON sylius_channel');
|
||||
$this->addSql('ALTER TABLE sylius_channel CHANGE default_currency_id base_currency_id INT NOT NULL');
|
||||
$this->addSql('ALTER TABLE sylius_channel ADD CONSTRAINT FK_16C8119E3101778E FOREIGN KEY (base_currency_id) REFERENCES sylius_currency (id)');
|
||||
$this->addSql('CREATE INDEX IDX_16C8119E3101778E ON sylius_channel (base_currency_id)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE sylius_channel DROP FOREIGN KEY FK_16C8119E3101778E');
|
||||
$this->addSql('DROP INDEX IDX_16C8119E3101778E ON sylius_channel');
|
||||
$this->addSql('ALTER TABLE sylius_channel CHANGE base_currency_id default_currency_id INT NOT NULL');
|
||||
$this->addSql('ALTER TABLE sylius_channel ADD CONSTRAINT FK_16C8119EECD792C0 FOREIGN KEY (default_currency_id) REFERENCES sylius_currency (id)');
|
||||
$this->addSql('CREATE INDEX IDX_16C8119EECD792C0 ON sylius_channel (default_currency_id)');
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ Feature: Adding a new channel
|
|||
Given I want to create 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 "Euro" as the base 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
|
||||
|
|
@ -28,7 +28,7 @@ Feature: Adding a new channel
|
|||
And I describe it as "Main distribution channel for mobile apps"
|
||||
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 "Euro" as the base 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
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ Feature: Channel validation
|
|||
And channel with code "MOBILE" should not be added
|
||||
|
||||
@ui
|
||||
Scenario: Trying to add a new channel without default currency
|
||||
Scenario: Trying to add a new channel without base currency
|
||||
Given I want to create a new channel
|
||||
When I specify its code as "MOBILE"
|
||||
But I do not choose default currency
|
||||
But I do not choose base currency
|
||||
And I try to add it
|
||||
Then I should be notified that default currency is required
|
||||
Then I should be notified that base currency is required
|
||||
And channel with code "MOBILE" should not be added
|
||||
|
||||
@ui
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ Feature: Not being able to add a disabled channel when no other exist
|
|||
Given I want to create 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 "Euro" as the base currency
|
||||
And I choose "English (United States)" as a default locale
|
||||
And I disable it
|
||||
And I add it
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ Feature: Selecting default tax zone for a channel
|
|||
When I specify its code as "MOBILE"
|
||||
And I name it "Mobile store"
|
||||
And I select the "United States" as default tax zone
|
||||
And I choose "USD" as a default currency
|
||||
And I choose "USD" as the base 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
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ Feature: Selecting available locales for a channel
|
|||
When I specify its code as "MOBILE"
|
||||
And I name it "Mobile channel"
|
||||
And I make it available in "English (United States)"
|
||||
And I choose "Euro" as a default currency
|
||||
And I choose "Euro" as the base 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
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ Feature: Selecting tax calculation strategy 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 choose "Euro" as a default currency
|
||||
And I choose "Euro" as the base 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
|
||||
|
|
@ -26,7 +26,7 @@ Feature: Selecting tax calculation strategy for a channel
|
|||
When I specify its code as "MOBILE"
|
||||
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 "Euro" as the base 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
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ final class CurrencyContext implements Context
|
|||
$currency = $this->provideCurrency($currencyCode);
|
||||
|
||||
$channel->addCurrency($currency);
|
||||
$channel->setDefaultCurrency($currency);
|
||||
$channel->setBaseCurrency($currency);
|
||||
|
||||
$this->channelManager->flush();
|
||||
|
||||
|
|
|
|||
|
|
@ -102,12 +102,12 @@ final class ManagingChannelsContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @When I choose :currency as a default currency
|
||||
* @When I do not choose default currency
|
||||
* @When I choose :currency as the base currency
|
||||
* @When I do not choose base currency
|
||||
*/
|
||||
public function iChooseAsADefaultCurrency($currency = null)
|
||||
public function iChooseAsABaseCurrency($currency = null)
|
||||
{
|
||||
$this->createPage->chooseDefaultCurrency($currency);
|
||||
$this->createPage->chooseBaseCurrency($currency);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -81,11 +81,11 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function chooseDefaultCurrency($currency)
|
||||
public function chooseBaseCurrency($currency)
|
||||
{
|
||||
if (null !== $currency) {
|
||||
$this->getElement('currencies')->selectOption($currency);
|
||||
$this->getElement('default_currency')->selectOption($currency);
|
||||
$this->getElement('base_currency')->selectOption($currency);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
return array_merge(parent::getDefinedElements(), [
|
||||
'code' => '#sylius_channel_code',
|
||||
'currencies' => '#sylius_channel_currencies',
|
||||
'default_currency' => '#sylius_channel_defaultCurrency',
|
||||
'base_currency' => '#sylius_channel_baseCurrency',
|
||||
'default_locale' => '#sylius_channel_defaultLocale',
|
||||
'enabled' => '#sylius_channel_enabled',
|
||||
'locales' => '#sylius_channel_locales',
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ interface CreatePageInterface extends BaseCreatePageInterface
|
|||
/**
|
||||
* @param string $currency
|
||||
*/
|
||||
public function chooseDefaultCurrency($currency);
|
||||
public function chooseBaseCurrency($currency);
|
||||
|
||||
/**
|
||||
* @param string $taxCalculationStrategy
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
{{ form_row(form.locales) }}
|
||||
{{ form_row(form.defaultLocale) }}
|
||||
{{ form_row(form.currencies) }}
|
||||
{{ form_row(form.defaultCurrency) }}
|
||||
{{ form_row(form.baseCurrency) }}
|
||||
{{ form_row(form.defaultTaxZone) }}
|
||||
{{ form_row(form.taxCalculationStrategy) }}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ EOT
|
|||
|
||||
$channel->addCurrency($this->currency);
|
||||
$channel->addLocale($this->locale);
|
||||
$channel->setDefaultCurrency($this->currency);
|
||||
$channel->setBaseCurrency($this->currency);
|
||||
$channel->setDefaultLocale($this->locale);
|
||||
|
||||
$channelManager->flush();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ final class ChannelFixture extends AbstractResourceFixture
|
|||
->booleanNode('enabled')->end()
|
||||
->scalarNode('default_locale')->cannotBeEmpty()->end()
|
||||
->arrayNode('locales')->prototype('scalar')->end()->end()
|
||||
->scalarNode('default_currency')->cannotBeEmpty()->end()
|
||||
->scalarNode('base_currency')->cannotBeEmpty()->end()
|
||||
->arrayNode('currencies')->prototype('scalar')->end()->end()
|
||||
->scalarNode('theme_name')->end()
|
||||
;
|
||||
|
|
|
|||
|
|
@ -82,11 +82,11 @@ final class ChannelExampleFactory implements ExampleFactoryInterface
|
|||
->setDefault('locales', LazyOption::all($localeRepository))
|
||||
->setAllowedTypes('locales', 'array')
|
||||
->setNormalizer('locales', LazyOption::findBy($localeRepository, 'code'))
|
||||
->setDefault('default_currency', function (Options $options) {
|
||||
->setDefault('base_currency', function (Options $options) {
|
||||
return $this->faker->randomElement($options['currencies']);
|
||||
})
|
||||
->setAllowedTypes('default_currency', ['string', CurrencyInterface::class])
|
||||
->setNormalizer('default_currency', LazyOption::findOneBy($currencyRepository, 'code'))
|
||||
->setAllowedTypes('base_currency', ['string', CurrencyInterface::class])
|
||||
->setNormalizer('base_currency', LazyOption::findOneBy($currencyRepository, 'code'))
|
||||
->setDefault('currencies', LazyOption::all($currencyRepository))
|
||||
->setAllowedTypes('currencies', 'array')
|
||||
->setNormalizer('currencies', LazyOption::findBy($currencyRepository, 'code'))
|
||||
|
|
@ -115,7 +115,7 @@ final class ChannelExampleFactory implements ExampleFactoryInterface
|
|||
$channel->addLocale($locale);
|
||||
}
|
||||
|
||||
$channel->setDefaultCurrency($options['default_currency']);
|
||||
$channel->setBaseCurrency($options['base_currency']);
|
||||
foreach ($options['currencies'] as $currency) {
|
||||
$channel->addCurrency($currency);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ class ChannelType extends BaseChannelType
|
|||
'required' => true,
|
||||
'multiple' => true,
|
||||
])
|
||||
->add('defaultCurrency', 'sylius_currency_choice', [
|
||||
'label' => 'sylius.form.channel.currency_default',
|
||||
->add('baseCurrency', 'sylius_currency_choice', [
|
||||
'label' => 'sylius.form.channel.currency_base',
|
||||
'required' => true,
|
||||
])
|
||||
->add('defaultTaxZone', 'sylius_zone_choice', [
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
<many-to-one field="defaultLocale" target-entity="Sylius\Component\Locale\Model\LocaleInterface">
|
||||
<join-column name="default_locale_id" referenced-column-name="id" nullable="false" />
|
||||
</many-to-one>
|
||||
<many-to-one field="defaultCurrency" target-entity="Sylius\Component\Currency\Model\CurrencyInterface">
|
||||
<join-column name="default_currency_id" referenced-column-name="id" nullable="false" />
|
||||
<many-to-one field="baseCurrency" target-entity="Sylius\Component\Currency\Model\CurrencyInterface">
|
||||
<join-column name="base_currency_id" referenced-column-name="id" nullable="false" />
|
||||
</many-to-one>
|
||||
<many-to-one field="defaultTaxZone" target-entity="Sylius\Component\Addressing\Model\ZoneInterface">
|
||||
<join-column name="default_tax_zone_id" referenced-column-name="id" nullable="true" on-delete="SET NULL" />
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
<constraint name="Sylius\Bundle\CoreBundle\Validator\Constraints\HasEnabledEntity">
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
<property name="defaultCurrency">
|
||||
<property name="baseCurrency">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.channel.default_currency.not_blank</option>
|
||||
<option name="message">sylius.channel.base_currency.not_blank</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ sylius:
|
|||
taxonomies: Taxonomies
|
||||
locale_default: Default locale
|
||||
locales: Locales
|
||||
currency_default: Default currency
|
||||
currency_base: Base currency
|
||||
currencies: Currencies
|
||||
shipping_methods: Shipping Methods
|
||||
payment_methods: Payment Methods
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
sylius:
|
||||
channel:
|
||||
default_currency:
|
||||
not_blank: Please enter channel default currency.
|
||||
base_currency:
|
||||
not_blank: Please enter channel base currency.
|
||||
default_locale:
|
||||
not_blank: Please enter channel default locale.
|
||||
checkout:
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class Channel extends BaseChannel implements ChannelInterface
|
|||
/**
|
||||
* @var CurrencyInterface
|
||||
*/
|
||||
protected $defaultCurrency;
|
||||
protected $baseCurrency;
|
||||
|
||||
/**
|
||||
* @var LocaleInterface
|
||||
|
|
@ -69,17 +69,17 @@ class Channel extends BaseChannel implements ChannelInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultCurrency()
|
||||
public function getBaseCurrency()
|
||||
{
|
||||
return $this->defaultCurrency;
|
||||
return $this->baseCurrency;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDefaultCurrency(CurrencyInterface $defaultCurrency)
|
||||
public function setBaseCurrency(CurrencyInterface $baseCurrency)
|
||||
{
|
||||
$this->defaultCurrency = $defaultCurrency;
|
||||
$this->baseCurrency = $baseCurrency;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@ interface ChannelInterface extends
|
|||
/**
|
||||
* @return CurrencyInterface
|
||||
*/
|
||||
public function getDefaultCurrency();
|
||||
public function getBaseCurrency();
|
||||
|
||||
/**
|
||||
* @param CurrencyInterface $currency
|
||||
*/
|
||||
public function setDefaultCurrency(CurrencyInterface $currency);
|
||||
public function setBaseCurrency(CurrencyInterface $currency);
|
||||
|
||||
/**
|
||||
* @return ZoneInterface
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ final class ChannelBasedCurrencyProvider implements CurrencyProviderInterface
|
|||
/** @var ChannelInterface $channel */
|
||||
$channel = $this->channelContext->getChannel();
|
||||
|
||||
return $channel->getDefaultCurrency()->getCode();
|
||||
return $channel->getBaseCurrency()->getCode();
|
||||
} catch (ChannelNotFoundException $exception) {
|
||||
throw new CurrencyNotFoundException(null, $exception);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ final class DefaultChannelFactory implements DefaultChannelFactoryInterface
|
|||
$channel->setTaxCalculationStrategy('order_items_based');
|
||||
|
||||
$channel->addCurrency($currency);
|
||||
$channel->setDefaultCurrency($currency);
|
||||
$channel->setBaseCurrency($currency);
|
||||
|
||||
$channel->addLocale($locale);
|
||||
$channel->setDefaultLocale($locale);
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ final class DefaultUnitedStatesChannelFactory implements DefaultChannelFactoryIn
|
|||
|
||||
$channel = $this->createChannel($code ?: self::DEFAULT_CHANNEL_CODE, $name ?: self::DEFAULT_CHANNEL_NAME);
|
||||
$channel->addCurrency($currency);
|
||||
$channel->setDefaultCurrency($currency);
|
||||
$channel->setBaseCurrency($currency);
|
||||
$channel->addLocale($locale);
|
||||
$channel->setDefaultLocale($locale);
|
||||
$channel->setTaxCalculationStrategy('order_items_based');
|
||||
|
|
|
|||
|
|
@ -62,14 +62,14 @@ final class ChannelBasedCurrencyProviderSpec extends ObjectBehavior
|
|||
$this->getAvailableCurrenciesCodes()->shouldReturn(['BTC']);
|
||||
}
|
||||
|
||||
function it_returns_channels_default_currency(
|
||||
function it_returns_channels_base_currency(
|
||||
ChannelContextInterface $channelContext,
|
||||
ChannelInterface $channel,
|
||||
CurrencyInterface $currency
|
||||
) {
|
||||
$channelContext->getChannel()->willReturn($channel);
|
||||
|
||||
$channel->getDefaultCurrency()->willReturn($currency);
|
||||
$channel->getBaseCurrency()->willReturn($currency);
|
||||
|
||||
$currency->getCode()->willReturn('BTC');
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ final class DefaultChannelFactorySpec extends ObjectBehavior
|
|||
$channel->setTaxCalculationStrategy('order_items_based')->shouldBeCalled();
|
||||
|
||||
$channel->addCurrency($currency)->shouldBeCalled();
|
||||
$channel->setDefaultCurrency($currency)->shouldBeCalled();
|
||||
$channel->setBaseCurrency($currency)->shouldBeCalled();
|
||||
$channel->addLocale($locale)->shouldBeCalled();
|
||||
$channel->setDefaultLocale($locale)->shouldBeCalled();
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ final class DefaultUnitedStatesChannelFactorySpec extends ObjectBehavior
|
|||
$this->shouldImplement(DefaultChannelFactoryInterface::class);
|
||||
}
|
||||
|
||||
function it_creates_a_default_united_states_channel_with_country_zone_and_usd_as_default_currency(
|
||||
function it_creates_a_default_united_states_channel_with_country_zone_and_usd_as_base_currency(
|
||||
RepositoryInterface $channelRepository,
|
||||
RepositoryInterface $countryRepository,
|
||||
RepositoryInterface $currencyRepository,
|
||||
|
|
@ -116,7 +116,7 @@ final class DefaultUnitedStatesChannelFactorySpec extends ObjectBehavior
|
|||
$currency->setCode('USD')->shouldBeCalled();
|
||||
$currency->setExchangeRate(1.00)->shouldBeCalled();
|
||||
|
||||
$channel->setDefaultCurrency($currency)->shouldBeCalled();
|
||||
$channel->setBaseCurrency($currency)->shouldBeCalled();
|
||||
$channel->addCurrency($currency)->shouldBeCalled();
|
||||
$channel->setDefaultLocale($locale)->shouldBeCalled();
|
||||
$channel->addLocale($locale)->shouldBeCalled();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Sylius\Component\Core\Model\Channel:
|
|||
name: "Web Channel"
|
||||
hostname: "localhost"
|
||||
description: "Lorem ipsum"
|
||||
defaultCurrency: "@currency"
|
||||
baseCurrency: "@currency"
|
||||
defaultLocale: "@locale"
|
||||
color: "black"
|
||||
enabled: true
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ Sylius\Component\Core\Model\Channel:
|
|||
name: "Channel"
|
||||
hostname: "localhost"
|
||||
description: "Lorem ipsum"
|
||||
defaultCurrency: "@currency"
|
||||
baseCurrency: "@currency"
|
||||
defaultLocale: "@locale"
|
||||
color: "black"
|
||||
enabled: true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue