Fix Customer validation issue and scenarios

This commit is contained in:
michalmarcinkowski 2016-06-02 17:58:34 +02:00
parent 21e7f0d951
commit 28d277b634
8 changed files with 44 additions and 103 deletions

View file

@ -10,15 +10,13 @@ Feature: Adding a new customer
@ui
Scenario: Adding a new customer
Given I want to create a new customer
When I specify their first name as "Luke"
And I specify their last name as "Skywalker"
And I specify their email as "l.skywalker@gmail.com"
When I specify their email as "l.skywalker@gmail.com"
And I add them
Then I should be notified that it has been successfully created
And the customer "l.skywalker@gmail.com" should appear in the store
@ui
Scenario: Adding a new customer with gender and birthday
Scenario: Adding a new customer with full details
Given I want to create a new customer
When I specify their first name as "Luke"
And I specify their last name as "Skywalker"

View file

@ -10,15 +10,13 @@ Feature: Adding a new customer account
@ui @javascript
Scenario: Adding a new customer with an account
Given I want to create a new customer account
When I specify their first name as "Luke"
And I specify their last name as "Skywalker"
And I specify their email as "l.skywalker@gmail.com"
When I specify their email as "l.skywalker@gmail.com"
And I choose create account option
And I specify its password as "psw123"
And I add them
Then I should be notified that it has been successfully created
And the customer "l.skywalker@gmail.com" should appear in the store
And the customer "l.skywalker@gmail.com" should have an account created
And this customer should have an account created
@ui @javascript
Scenario: Creating an account for existing customer

View file

@ -8,12 +8,10 @@ Feature: Customer uniqueness of email validation
Given I am logged in as an administrator
@ui
Scenario: Try to add a new customer with taken email
Scenario: Trying to add a new customer with taken email
Given the store has customer "f.baggins@example.com"
And I want to create a new customer
When I specify their first name as "Geralt"
And I specify their last name as "Riv"
And I specify their email as "f.baggins@example.com"
When I specify their email as "f.baggins@example.com"
And I try to add it
Then I should be notified that email must be unique
And there should still be only one customer with email "f.baggins@example.com"

View file

@ -2,29 +2,11 @@
Feature: Customer validation
In order to avoid making mistakes when managing customers
As an Administrator
I want to be prevented from adding it without specify required fields
I want to be prevented from adding it without specifying required fields
Background:
Given I am logged in as an administrator
@ui
Scenario: Trying to add a new customer without a first name
Given I want to create a new customer
When I specify their last name as "Skywalker"
And I specify their email as "l.skywalker@gmail.com"
And I try to add it
Then I should be notified that first name is required
And the customer with email "l.skywalker@gmail.com" should not appear in the store
@ui
Scenario: Trying to add a new customer without a last name
Given I want to create a new customer
When I specify their first name as "Luke"
And I specify their email as "l.skywalker@gmail.com"
And I try to add it
Then I should be notified that last name is required
And the customer with email "l.skywalker@gmail.com" should not appear in the store
@ui
Scenario: Trying to add a new customer without an email
Given I want to create a new customer
@ -32,48 +14,29 @@ Feature: Customer validation
And I specify their last name as "Skywalker"
And I try to add it
Then I should be notified that email is required
And the customer with email "l.skywalker@gmail.com" should not appear in the store
@ui
Scenario: Trying to remove first name from existing customer
Given the store has customer "l.skywalker@gmail.com" with first name "Luke"
And I want to edit the customer "l.skywalker@gmail.com"
When I remove its first name
And I try to save my changes
Then I should be notified that first name is required
And the customer "l.skywalker@gmail.com" should still have first name "Luke"
@ui
Scenario: Trying to specify too short first name for existing customer
Scenario: Trying to specify too short first name for an existing customer
Given the store has customer "l.skywalker@gmail.com"
And I want to edit the customer "l.skywalker@gmail.com"
And I want to edit this customer
When I specify their first name as "L"
And I try to save my changes
Then I should be notified that first name should be at least 2 characters long
And the customer "l.skywalker@gmail.com" should still have empty first name
And the customer "l.skywalker@gmail.com" should still have an empty first name
@ui
Scenario: Trying to specify too short last name for existing customer
Scenario: Trying to specify too short last name for an existing customer
Given the store has customer "l.skywalker@gmail.com" with first name "Luke"
And I want to edit the customer "l.skywalker@gmail.com"
And I want to edit this customer
When I specify their last name as "S"
And I try to save my changes
Then I should be notified that last name should be at least 2 characters long
And the customer "l.skywalker@gmail.com" should still have empty last name
And the customer "l.skywalker@gmail.com" should still have an empty last name
@ui
Scenario: Trying to remove last name from existing customer
Given the store has customer "l.skywalker@gmail.com" with last name "Skywalker"
Given I want to edit the customer "l.skywalker@gmail.com"
When I remove its last name
And I try to save my changes
Then I should be notified that last name is required
And the customer "l.skywalker@gmail.com" should still have last name "Skywalker"
@ui
Scenario: Trying to remove email from existing customer
Scenario: Trying to remove email from an existing customer
Given the store has customer "l.skywalker@gmail.com"
Given I want to edit the customer "l.skywalker@gmail.com"
And I want to edit this customer
When I remove its email
And I try to save my changes
Then I should be notified that email is required
@ -82,9 +45,7 @@ Feature: Customer validation
@ui
Scenario: Trying to create customer with wrong email format
Given I want to create a new customer
When I specify their first name as "Luke"
And I specify their last name as "Skywalker"
And I specify their email as "wrongemail"
When I specify their email as "wrongemail"
And I try to add it
Then I should be notified that email is not valid
And the customer with email "wrongemail" should not appear in the store

View file

@ -8,11 +8,22 @@ Feature: Editing a customer
Given I am logged in as an administrator
@ui
Scenario: Editing a customer
Scenario: Changing first and last name of an existing customer
Given the store has customer "Frodo Baggins" with email "f.baggins@example.com"
And I want to edit the customer "f.baggins@example.com"
And I want to edit this customer
When I specify his first name as "Jon"
And I specify his last name as "Snow"
And I save my changes
Then I should be notified that it has been successfully edited
And this customer with name "Jon Snow" should appear in the store
@ui
Scenario: Removing first and last name from an existing customer
Given the store has customer "Luke Skywalker" with email "l.skywalker@gmail.com"
And I want to edit this customer
When I remove its first name
And I remove its last name
And I save my changes
Then I should be notified that it has been successfully edited
And this customer should have an empty first name
And this customer should have an empty last name

View file

@ -126,6 +126,7 @@ final class ManagingCustomersContext implements Context
}
/**
* @Given /^I want to edit (this customer)$/
* @Given I want to edit the customer :customer
*/
public function iWantToEditThisCustomer(CustomerInterface $customer)
@ -194,7 +195,7 @@ final class ManagingCustomersContext implements Context
{
Assert::true(
$this->createPage->checkValidationMessageFor($elementName, sprintf('Please enter your %s.', $elementName)),
sprintf('Customer % should be required.', $elementName)
sprintf('Customer %s should be required.', $elementName)
);
}
@ -206,9 +207,9 @@ final class ManagingCustomersContext implements Context
Assert::true(
$this->updatePage->checkValidationMessageFor(
$elementName,
sprintf('%s must be %s', $elementName, $validationMessage)
sprintf('%s must be %s.', ucfirst($elementName), $validationMessage)
),
sprintf('Customer % should be %s.', $elementName, $validationMessage)
sprintf('Customer %s should be %s.', $elementName, $validationMessage)
);
}
@ -234,30 +235,17 @@ final class ManagingCustomersContext implements Context
}
/**
* @Then the customer :customer should still have first name :firstName
* @Then /^(this customer) should have an empty first name$/
* @Then the customer :customer should still have an empty first name
*/
public function theCustomerShouldStillHaveFirstName(CustomerInterface $customer, $firstName)
{
$this->updatePage->open(['id' => $customer->getId()]);
Assert::eq(
$firstName,
$this->updatePage->getFirstName(),
sprintf('Customer should have first name %s, but it does not.', $firstName)
);
}
/**
* @Then the customer :customer should still have empty first name
*/
public function theCustomerShouldStillHaveEmptyFirstName(CustomerInterface $customer)
public function theCustomerShouldStillHaveAnEmptyFirstName(CustomerInterface $customer)
{
$this->updatePage->open(['id' => $customer->getId()]);
Assert::eq(
'',
$this->updatePage->getFirstName(),
'Customer should have empty first name, but it does not.'
'Customer should have an empty first name, but it does not.'
);
}
@ -270,30 +258,17 @@ final class ManagingCustomersContext implements Context
}
/**
* @Then the customer :customer should still have last name :lastName
* @Then /^(this customer) should have an empty last name$/
* @Then the customer :customer should still have an empty last name
*/
public function theCustomerShouldStillHaveLastName(CustomerInterface $customer, $lastName)
{
$this->updatePage->open(['id' => $customer->getId()]);
Assert::eq(
$lastName,
$this->updatePage->getLastName(),
sprintf('Customer should have last name %s, but it does not.', $lastName)
);
}
/**
* @Then the customer :customer should still have empty last name
*/
public function theCustomerShouldStillHaveEmptyLastName(CustomerInterface $customer)
public function theCustomerShouldStillHaveAnEmptyLastName(CustomerInterface $customer)
{
$this->updatePage->open(['id' => $customer->getId()]);
Assert::eq(
'',
$this->updatePage->getLastName(),
'Customer should have empty last name, but it does not.'
'Customer should have an empty last name, but it does not.'
);
}

View file

@ -133,7 +133,7 @@ class Configuration implements ConfigurationInterface
->children()
->arrayNode('default')
->prototype('scalar')->end()
->defaultValue(['sylius', 'sylius_customer_profile'])
->defaultValue(['sylius'])
->end()
->arrayNode('profile')
->prototype('scalar')->end()

View file

@ -37,7 +37,7 @@
<option name="minMessage">sylius.customer.first_name.min</option>
<option name="max">255</option>
<option name="maxMessage">sylius.customer.first_name.max</option>
<option name="groups">sylius_customer_profile</option>
<option name="groups">sylius</option>
</constraint>
</property>
<property name="lastName">
@ -50,7 +50,7 @@
<option name="minMessage">sylius.customer.last_name.min</option>
<option name="max">255</option>
<option name="maxMessage">sylius.customer.last_name.max</option>
<option name="groups">sylius_customer_profile</option>
<option name="groups">sylius</option>
</constraint>
</property>
<property name="gender">