mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Cover the max code length validation in the Locale bundle
This commit is contained in:
parent
d51ef9fc38
commit
7eba860463
4 changed files with 38 additions and 3 deletions
|
|
@ -15,6 +15,13 @@ Feature: Locale validation
|
|||
And I try to add it
|
||||
Then I should be notified that a code is required
|
||||
|
||||
@api @no-ui
|
||||
Scenario: Trying to add a locale with too long code
|
||||
Given I want to create a new locale
|
||||
When I set its code to 256 characters long string
|
||||
And I try to add it
|
||||
Then I should be notified that the code is too long
|
||||
|
||||
@api @no-ui
|
||||
Scenario: Trying to add a locale with an invalid code
|
||||
When I want to create a new locale
|
||||
|
|
|
|||
|
|
@ -46,6 +46,14 @@ final class ManagingLocalesContext implements Context
|
|||
$this->client->addRequestData('code', $localeCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I set its code to :amount characters long string
|
||||
*/
|
||||
public function iSetItsCodeToCharactersLongString(int $amount): void
|
||||
{
|
||||
$this->iChoose(sprintf('PL-%s', str_repeat('A', $amount - 3)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I (try to) add it
|
||||
*/
|
||||
|
|
@ -125,6 +133,18 @@ final class ManagingLocalesContext implements Context
|
|||
Assert::same($this->responseChecker->getError($response), 'code: This value is not a valid locale code.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should be notified that the code is too long
|
||||
*/
|
||||
public function iShouldBeNotifiedThatTheCodeIsTooLong(): void
|
||||
{
|
||||
$response = $this->client->getLastResponse();
|
||||
Assert::contains(
|
||||
$this->responseChecker->getError($response),
|
||||
'Locale code cannot be longer than',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should be informed that locale :localeCode has been deleted
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -23,9 +23,16 @@
|
|||
<option name="message">sylius.locale.code.not_blank</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
<constraint name="Locale">
|
||||
<option name="message">sylius.locale.code.locale</option>
|
||||
<option name="groups">sylius</option>
|
||||
<constraint name="Sequentially">
|
||||
<constraint name="Length">
|
||||
<option name="max">10</option>
|
||||
<option name="maxMessage">sylius.locale.code.max_length</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
<constraint name="Locale">
|
||||
<option name="message">sylius.locale.code.locale</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
sylius:
|
||||
locale:
|
||||
code:
|
||||
max_length: Locale code cannot be longer than {{ limit }} characters.
|
||||
not_blank: Please choose locale code.
|
||||
locale: This value is not a valid locale code.
|
||||
unique: Locale code must be unique.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue