mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[Behat][Admin][Country] Validation of saving duplicated province names
This commit is contained in:
parent
a8d28988c5
commit
86807fb177
4 changed files with 53 additions and 40 deletions
|
|
@ -1,28 +0,0 @@
|
|||
@managing_countries
|
||||
Feature: Province unique code validation
|
||||
In order to uniquely identify provinces
|
||||
As an Administrator
|
||||
I want to be prevented from adding two provinces with the same code
|
||||
|
||||
Background:
|
||||
Given the store has country "United Kingdom"
|
||||
And this country has the "Northern Ireland" province with "GB-NIR" code
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @javascript @api
|
||||
Scenario: Trying to add a new province with taken code
|
||||
When I want to add a new country
|
||||
And I choose "Gibraltar"
|
||||
And I add the "Scotland" province with "GB-NIR" code
|
||||
And I try to add it
|
||||
Then I should be notified that province code must be unique
|
||||
|
||||
@ui @javascript @api
|
||||
Scenario: Trying to add new provinces with duplicated codes
|
||||
When I want to edit this country
|
||||
And I add the "Scotland" province with "GB-SCO" code
|
||||
And I add the "Not Scotland" province with "GB-SCO" code
|
||||
And I try to save changes
|
||||
Then I should be notified that all province codes within this country need to be unique
|
||||
And province with name "Scotland" should not be added in this country
|
||||
And province with name "Not Scotland" should not be added in this country
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
@managing_countries
|
||||
Feature: Province unique fields validation
|
||||
In order to uniquely identify provinces
|
||||
As an Administrator
|
||||
I want to be prevented from adding two provinces with the same code or name
|
||||
|
||||
Background:
|
||||
Given the store has country "United Kingdom"
|
||||
And this country has the "Northern Ireland" province with "GB-NIR" code
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @javascript @api
|
||||
Scenario: Trying to add a new province with a taken code
|
||||
When I want to add a new country
|
||||
And I choose "Gibraltar"
|
||||
And I add the "Scotland" province with "GB-NIR" code
|
||||
And I try to add it
|
||||
Then I should be notified that province code must be unique
|
||||
|
||||
@ui @javascript @api
|
||||
Scenario: Trying to add a new province with a taken name
|
||||
When I want to edit this country
|
||||
And I add the "Northern Ireland" province with "GB-NI" code
|
||||
And I try to save changes
|
||||
Then I should be notified that province name must be unique
|
||||
|
||||
@ui @javascript @api
|
||||
Scenario: Trying to add new provinces with duplicated codes
|
||||
When I want to edit this country
|
||||
And I add the "Scotland" province with "GB-SCO" code
|
||||
And I add the "Not Scotland" province with "GB-SCO" code
|
||||
And I try to save changes
|
||||
Then I should be notified that all province codes and names within this country need to be unique
|
||||
|
||||
@ui @javascript @api
|
||||
Scenario: Trying to add new provinces with duplicated names
|
||||
When I want to edit this country
|
||||
And I add the "Scotland" province with "GB-SC" code
|
||||
And I add the "Scotland" province with "GB-SCO" code
|
||||
And I try to save changes
|
||||
Then I should be notified that all province codes and names within this country need to be unique
|
||||
|
|
@ -313,24 +313,24 @@ final class ManagingCountriesContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then I should be notified that province code must be unique
|
||||
* @Then /^I should be notified that province (code|name) must be unique$/
|
||||
*/
|
||||
public function iShouldBeNotifiedThatProvinceCodeMustBeUnique(): void
|
||||
public function iShouldBeNotifiedThatProvinceCodeMustBeUnique(string $field): void
|
||||
{
|
||||
Assert::regex(
|
||||
$this->responseChecker->getError($this->client->getLastResponse()),
|
||||
'/provinces\[[\d+]\]\.code: Province code must be unique\./',
|
||||
sprintf('/provinces\[[\d+]\]\.%1$s: Province %1$s must be unique\./', $field),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should be notified that all province codes within this country need to be unique
|
||||
* @Then I should be notified that all province codes and names within this country need to be unique
|
||||
*/
|
||||
public function iShouldBeNotifiedThatAllProvinceCodesWithinThisCountryNeedToBeUnique(): void
|
||||
public function iShouldBeNotifiedThatAllProvinceCodesAndNamesWithinThisCountryNeedToBeUnique(): void
|
||||
{
|
||||
Assert::contains(
|
||||
$this->responseChecker->getError($this->client->getLastResponse()),
|
||||
'provinces: All provinces within this country need to have unique codes.',
|
||||
'provinces: All provinces within this country need to have unique codes and names.',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -266,20 +266,20 @@ final class ManagingCountriesContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then I should be notified that province code must be unique
|
||||
* @Then /^I should be notified that province (code|name) must be unique$/
|
||||
*/
|
||||
public function iShouldBeNotifiedThatProvinceCodeMustBeUnique(): void
|
||||
public function iShouldBeNotifiedThatProvinceCodeMustBeUnique(string $field): void
|
||||
{
|
||||
Assert::same($this->updatePage->getValidationMessage('code'), 'Province code must be unique.');
|
||||
Assert::same($this->updatePage->getValidationMessage($field), sprintf('Province %s must be unique.', $field));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should be notified that all province codes within this country need to be unique
|
||||
* @Then I should be notified that all province codes and names within this country need to be unique
|
||||
*/
|
||||
public function iShouldBeNotifiedThatAllProvinceCodesWithinThisCountryNeedToBeUnique(): void
|
||||
public function iShouldBeNotifiedThatAllProvinceCodesAndNamesWithinThisCountryNeedToBeUnique(): void
|
||||
{
|
||||
Assert::inArray(
|
||||
'All provinces within this country need to have unique codes.',
|
||||
'All provinces within this country need to have unique codes and names.',
|
||||
$this->updatePage->getFormValidationErrors(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue