[Customer] Add group field to customer create and edit page

This commit is contained in:
Grzegorz Sadowski 2016-10-06 15:26:57 +02:00
parent 2f888dbf92
commit 42e7d6807f
9 changed files with 53 additions and 2 deletions

View file

@ -16,7 +16,7 @@ Feature: Adding a new customer
Then I should be notified that it has been successfully created
And the customer "l.skywalker@gmail.com" should appear in the store
@ui @todo
@ui
Scenario: Adding a new customer with full details
Given I want to create a new customer
When I specify their first name as "Luke"

View file

@ -37,7 +37,7 @@ Feature: Editing a customer
Then I should be notified that it has been successfully edited
And this customer should be subscribed to the newsletter
@ui @todo
@ui
Scenario: Selecting a group for an existing customer
Given the store has a customer group "Retail"
And the store has customer "Mike Ross" with email "ross@teammike.com"

View file

@ -136,6 +136,14 @@ final class ManagingCustomersContext implements Context
$this->createPage->chooseGender($gender);
}
/**
* @When I select :group as their group
*/
public function iSelectGroup($group)
{
$this->createPage->chooseGroup($group);
}
/**
* @When I specify its birthday as :birthday
*/
@ -551,4 +559,18 @@ final class ManagingCustomersContext implements Context
sprintf('Cannot find shipping address with province %s', $provinceName)
);
}
/**
* @Then /^(this customer) should have "([^"]+)" as their group$/
*/
public function thisCustomerShouldHaveAsTheirGroup(CustomerInterface $customer, $groupName)
{
$this->updatePage->open(['id' => $customer->getId()]);
Assert::same(
$groupName,
$this->updatePage->getGroupName(),
sprintf('Customer should have %s as group, but it does not', $groupName)
);
}
}

View file

@ -66,6 +66,14 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
$this->getDocument()->selectFieldOption('Gender', $gender);
}
/**
* {@inheritdoc}
*/
public function chooseGroup($group)
{
$this->getDocument()->selectFieldOption('Group', $group);
}
/**
* {@inheritdoc}
*/

View file

@ -48,5 +48,10 @@ interface CreatePageInterface extends BaseCreatePageInterface
*/
public function chooseGender($gender);
/**
* @param string $group
*/
public function chooseGroup($group);
public function selectCreateAccount();
}

View file

@ -101,6 +101,14 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
return $this->getDocument()->hasCheckedField('Subscribe to the newsletter');
}
/**
* {@inheritdoc}
*/
public function getGroupName()
{
return $this->getElement('group')->getText();
}
/**
* {@inheritdoc}
*/
@ -118,6 +126,7 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
'email' => '#sylius_customer_email',
'enabled' => '#sylius_customer_user_enabled',
'first_name' => '#sylius_customer_firstName',
'group' => '#sylius_customer_group',
'last_name' => '#sylius_customer_lastName',
'password' => '#sylius_customer_user_password',
]);

View file

@ -67,4 +67,9 @@ interface UpdatePageInterface extends BaseUpdatePageInterface
* @return bool
*/
public function isSubscribedToTheNewsletter();
/**
* @return string
*/
public function getGroupName();
}

View file

@ -13,6 +13,7 @@ default:
- sylius.behat.context.setup.channel
- sylius.behat.context.setup.customer
- sylius.behat.context.setup.customer_group
- sylius.behat.context.setup.admin_security
- sylius.behat.context.setup.user

View file

@ -8,6 +8,7 @@
{{ form_row(form.lastName) }}
</div>
{{ form_row(form.email) }}
{{ form_row(form.group) }}
</div>
<div class="ui segment">
<h4 class="ui dividing header">{{ 'sylius.ui.extra_information'|trans }}</h4>