[Core][Channel] Add contact phone number to channel

This commit is contained in:
Tobias Wojtylak 2020-10-20 20:40:05 +02:00
parent 1a3cd66eb9
commit 2f0ce21297
19 changed files with 95 additions and 1 deletions

View file

@ -30,6 +30,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 set its contact email as "contact@avengers-gear.com"
And I set its contact phone number as "11331122"
And I define its color as "blue"
And I choose "Euro" as the base currency
And I choose "English (United States)" as a default locale

View file

@ -34,7 +34,7 @@ Feature: Channel validation
Then I should be notified that base currency is required
And channel with code "MOBILE" should not be added
@ui
@ui @oi
Scenario: Trying to add a new channel without default locale
Given I want to create a new channel
When I specify its code as "MOBILE"

View file

@ -100,6 +100,14 @@ final class ManagingChannelsContext implements Context
$this->client->addRequestData('contactEmail', $contactEmail);
}
/**
* @When I set its contact phone number as :contactPhoneNumber
*/
public function iSetItsContactPhoneNumberAs(string $contactPhoneNumber): void
{
$this->client->addRequestData('contactPhoneNumber', $contactPhoneNumber);
}
/**
* @When I choose :country and :otherCountry as operating countries
*/

View file

@ -195,6 +195,14 @@ final class ManagingChannelsContext implements Context
$this->createPage->setContactEmail($contactEmail);
}
/**
* @When I set its contact phone number as :contactPhoneNumber
*/
public function iSetItsContactPhoneNumberAs(string $contactPhoneNumber): void
{
$this->createPage->setContactPhoneNumber($contactPhoneNumber);
}
/**
* @When I define its color as :color
*/

View file

@ -38,6 +38,11 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
$this->getDocument()->fillField('Contact email', $contactEmail);
}
public function setContactPhoneNumber(string $contactPhoneNumber): void
{
$this->getDocument()->fillField('Contact phone number', $contactPhoneNumber);
}
public function defineColor(string $color): void
{
$this->getDocument()->fillField('Color', $color);

View file

@ -31,6 +31,8 @@ interface CreatePageInterface extends BaseCreatePageInterface
public function setContactEmail(string $contactEmail): void;
public function setContactPhoneNumber(string $contactPhoneNumber): void;
public function defineColor(string $color): void;
public function chooseLocale(string $language): void;

View file

@ -28,6 +28,7 @@
{{ form_errors(form.hostname) }}
</div>
{{ form_row(form.contactEmail) }}
{{ form_row(form.contactPhoneNumber) }}
{{ form_row(form.description, {'attr': {'rows' : '3'}}) }}
</div>
<div class="ui attached segment">

View file

@ -61,6 +61,7 @@
<property name="countries" writable="true" readable="true" />
<property name="themeName" writable="true" readable="true" />
<property name="contactEmail" writable="true" readable="true" />
<property name="contactPhoneNumber" writable="true" readable="true" />
<property name="skippingShippingStepAllowed" writable="true" readable="true" />
<property name="skippingPaymentStepAllowed" writable="true" readable="true" />
<property name="accountVerificationRequired" writable="true" readable="true" />

View file

@ -72,6 +72,10 @@
<group>channel:read</group>
<group>channel:create</group>
</attribute>
<attribute name="contactPhoneNumber">
<group>channel:read</group>
<group>channel:create</group>
</attribute>
<attribute name="skippingShippingStepAllowed">
<group>channel:read</group>
<group>channel:create</group>

View file

@ -28,6 +28,7 @@ use Sylius\Component\Core\Model\Scope;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
final class ChannelTypeExtension extends AbstractTypeExtension
@ -75,6 +76,10 @@ final class ChannelTypeExtension extends AbstractTypeExtension
'label' => 'sylius.form.channel.contact_email',
'required' => false,
])
->add('contactPhoneNumber', TextType::class, [
'required' => false,
'label' => 'sylius.form.channel.contact_phone_number',
])
->add('skippingShippingStepAllowed', CheckboxType::class, [
'label' => 'sylius.form.channel.skipping_shipping_step_allowed',
'required' => false,

View file

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20201017150005 extends AbstractMigration
{
public function getDescription() : string
{
return 'Add contact phone number to channel';
}
public function up(Schema $schema) : void
{
$this->addSql('ALTER TABLE sylius_channel ADD contact_phone_number VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema) : void
{
$this->addSql('ALTER TABLE sylius_channel DROP contact_phone_number');
}
}

View file

@ -20,6 +20,7 @@
<field name="themeName" column="theme_name" type="string" nullable="true" />
<field name="taxCalculationStrategy" column="tax_calculation_strategy" type="string" />
<field name="contactEmail" column="contact_email" type="string" nullable="true" />
<field name="contactPhoneNumber" column="contact_phone_number" type="string" nullable="true" />
<field name="skippingShippingStepAllowed" column="skipping_shipping_step_allowed" type="boolean" />
<field name="skippingPaymentStepAllowed" column="skipping_payment_step_allowed" type="boolean" />
<field name="accountVerificationRequired" column="account_verification_required" type="boolean" />

View file

@ -32,6 +32,7 @@ sylius:
street: Street
tax_id: Tax ID
contact_email: Contact email
contact_phone_number: Contact phone number
countries: Countries
currencies: Currencies
currency_base: Base currency

View file

@ -62,6 +62,9 @@ class Channel extends BaseChannel implements ChannelInterface
/** @var string */
protected $contactEmail;
/** @var string|null */
protected $contactPhoneNumber;
/** @var bool */
protected $skippingShippingStepAllowed = false;
@ -221,6 +224,16 @@ class Channel extends BaseChannel implements ChannelInterface
$this->contactEmail = $contactEmail;
}
public function getContactPhoneNumber(): ?string
{
return $this->contactPhoneNumber;
}
public function setContactPhoneNumber(?string $contactPhoneNumber): void
{
$this->contactPhoneNumber = $contactPhoneNumber;
}
public function isSkippingShippingStepAllowed(): bool
{
return $this->skippingShippingStepAllowed;

View file

@ -51,6 +51,10 @@ interface ChannelInterface extends
public function setContactEmail(?string $contactEmail): void;
public function getContactPhoneNumber(): ?string;
public function setContactPhoneNumber(?string $contactPhoneNumber): void;
public function isSkippingShippingStepAllowed(): bool;
public function setSkippingShippingStepAllowed(bool $skippingShippingStepAllowed): void;

View file

@ -138,6 +138,17 @@ final class ChannelSpec extends ObjectBehavior
$this->getContactEmail()->shouldReturn('contact@example.com');
}
function it_has_no_contact_phone_number_by_default(): void
{
$this->getContactPhoneNumber()->shouldReturn(null);
}
function its_contact_phone_number_is_mutable(): void
{
$this->setContactPhoneNumber('113321122');
$this->getContactPhoneNumber()->shouldReturn('113321122');
}
function it_can_allow_to_skip_shipping_step_if_only_a_single_shipping_method_is_resolved(): void
{
$this->setSkippingShippingStepAllowed(true);

View file

@ -162,6 +162,7 @@ EOT;
"menuTaxon": "mugs",
"color": "ClassicBlue",
"contactEmail": "admin@quickmart.eu",
"contactPhoneNumber": "11331122",
"skippingShippingStepAllowed": true,
"skippingPaymentStepAllowed": true,
"accountVerificationRequired": false

View file

@ -32,6 +32,7 @@
},
"themeName": {},
"contactEmail": {},
"contactPhoneNumber": {},
"skippingShippingStepAllowed": {},
"skippingPaymentStepAllowed": {},
"accountVerificationRequired": {},

View file

@ -24,6 +24,7 @@
},
"themeName": {},
"contactEmail": {},
"contactPhoneNumber": {},
"skippingShippingStepAllowed": {},
"skippingPaymentStepAllowed": {},
"accountVerificationRequired": {},