Skip to content

Commit

Permalink
Tests fixes and nullable fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Zales0123 committed Jan 9, 2019
1 parent 1185ef8 commit 0848c16
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190109091323 extends AbstractMigration
final class Version20190109095211 extends AbstractMigration
{
public function up(Schema $schema) : void
{
// 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('CREATE TABLE sylius_shop_billing_data (id INT AUTO_INCREMENT NOT NULL, company VARCHAR(255) NOT NULL, taxId VARCHAR(255) NOT NULL, countryCode VARCHAR(255) NOT NULL, street VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL, postcode VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE UTF8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE sylius_shop_billing_data (id INT AUTO_INCREMENT NOT NULL, company VARCHAR(255) DEFAULT NULL, taxId VARCHAR(255) DEFAULT NULL, countryCode VARCHAR(255) DEFAULT NULL, street VARCHAR(255) DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, postcode VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE UTF8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE sylius_channel ADD shop_billing_data_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE sylius_channel ADD CONSTRAINT FK_16C8119EB5282EDF FOREIGN KEY (shop_billing_data_id) REFERENCES sylius_shop_billing_data (id) ON DELETE CASCADE');
$this->addSql('CREATE UNIQUE INDEX UNIQ_16C8119EB5282EDF ON sylius_channel (shop_billing_data_id)');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Feature: Adding a new channel with shop billing data
Background:
Given the store has currency "Euro"
And the store has locale "English (United States)"
And the store operates in "United States"
And I am logged in as an administrator

@ui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public function hasBillingAddress(string $street, string $postcode, string $city
protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
'city' => '#sylius_channel_billingData_city',
'company' => '#sylius_channel_billingData_company',
'country_code' => '#sylius_channel_billingData_countryCode',
'postcode' => '#sylius_channel_billingData_postcode',
'street' => '#sylius_channel_billingData_street',
'tax_id' => '#sylius_channel_billingData_taxId',
'city' => '#sylius_channel_shopBillingData_city',
'company' => '#sylius_channel_shopBillingData_company',
'country_code' => '#sylius_channel_shopBillingData_countryCode',
'postcode' => '#sylius_channel_shopBillingData_postcode',
'street' => '#sylius_channel_shopBillingData_street',
'tax_id' => '#sylius_channel_shopBillingData_taxId',
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ default:
contexts_services:
- sylius.behat.context.hook.doctrine_orm

- sylius.behat.context.transform.address
- sylius.behat.context.transform.channel
- sylius.behat.context.transform.country
- sylius.behat.context.transform.currency
- sylius.behat.context.transform.locale
- sylius.behat.context.transform.shared_storage
- sylius.behat.context.transform.zone

- sylius.behat.context.setup.channel
- sylius.behat.context.setup.currency
- sylius.behat.context.setup.geographical
- sylius.behat.context.setup.locale
- sylius.behat.context.setup.payment
- sylius.behat.context.setup.admin_security
Expand Down
14 changes: 13 additions & 1 deletion src/Sylius/Bundle/CoreBundle/Form/Type/ShopBillingDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@

final class ShopBillingDataType extends AbstractType
{
/** @var string */
private $dataClass;

public function __construct(string $dataClass)
{
$this->dataClass = $dataClass;
}

public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
Expand All @@ -27,21 +35,25 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('countryCode', CountryCodeChoiceType::class, [
'label' => 'sylius.form.channel.billing_data.country',
'enabled' => true,
'required' => false,
])
->add('street', TextType::class, [
'label' => 'sylius.form.channel.billing_data.street',
'required' => false,
])
->add('city', TextType::class, [
'label' => 'sylius.form.channel.billing_data.city',
'required' => false,
])
->add('postcode', TextType::class, [
'label' => 'sylius.form.channel.billing_data.postcode',
'required' => false,
])
;
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefault('data_class', ShopBillingData::class);
$resolver->setDefault('data_class', $this->dataClass);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<generator/>
</id>

<field name="company" />
<field name="taxId" />
<field name="countryCode" />
<field name="street" />
<field name="city" />
<field name="postcode" />
<field name="company" nullable="true" />
<field name="taxId" nullable="true" />
<field name="countryCode" nullable="true" />
<field name="street" nullable="true" />
<field name="city" nullable="true" />
<field name="postcode" nullable="true" />
</entity>
</doctrine-mapping>
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<parameter key="sylius.form.type.product_image.validation_groups" type="collection">
<parameter>sylius</parameter>
</parameter>
<parameter key="sylius.model.shop_billing_data.class">Sylius\Component\Core\Model\ShopBillingData</parameter>
</parameters>

<services>
Expand Down Expand Up @@ -242,6 +243,7 @@
</service>

<service id="sylius.form.type.shop_billing_data" class="Sylius\Bundle\CoreBundle\Form\Type\ShopBillingDataType">
<argument>%sylius.model.shop_billing_data.class%</argument>
<tag name="form.type" />
</service>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
"skippingShippingStepAllowed": {},
"skippingPaymentStepAllowed": {},
"accountVerificationRequired": {},
"shopBillingData": {
"children": {
"taxId": {},
"company": {},
"countryCode": {},
"street": {},
"city": {},
"postcode": {}
}
},
"code": {
"errors": [
"Please enter channel code."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
"skippingShippingStepAllowed": {},
"skippingPaymentStepAllowed": {},
"accountVerificationRequired": {},
"shopBillingData": {
"children": {
"taxId": {},
"company": {},
"countryCode": {},
"street": {},
"city": {},
"postcode": {}
}
},
"code": {},
"baseCurrency": {}
}
Expand Down

0 comments on commit 0848c16

Please sign in to comment.