mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Merge branch '1.3' into 1.4
* 1.3: Move bundle registration from Kernel class to "bundles.php" Add missing Length constraint on product translation slug
This commit is contained in:
commit
2a343accab
6 changed files with 105 additions and 4 deletions
|
|
@ -69,4 +69,5 @@ return [
|
|||
Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
|
||||
Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
|
||||
FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true],
|
||||
Sylius\Behat\Application\SyliusTestPlugin\SyliusTestPlugin::class => ['test' => true, 'test_cached' => true],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -58,10 +58,6 @@ class Kernel extends BaseKernel
|
|||
yield new $class();
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($this->getEnvironment(), ['test', 'test_cached'])) {
|
||||
yield new \Sylius\Behat\Application\SyliusTestPlugin\SyliusTestPlugin();
|
||||
}
|
||||
}
|
||||
|
||||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@
|
|||
<option name="message">sylius.product.slug.not_blank</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="max">255</option>
|
||||
<option name="maxMessage">sylius.product.slug.max_length</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
</constraint-mapping>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ sylius:
|
|||
slug:
|
||||
not_blank: Please enter product slug.
|
||||
unique: Product slug must be unique.
|
||||
max_length: Product slug must not be longer than 1 character.|Product slug must not be longer than {{ limit }} characters.
|
||||
code:
|
||||
not_blank: Please enter product code.
|
||||
regex: Product code can only be comprised of letters, numbers, dashes and underscores.
|
||||
|
|
|
|||
|
|
@ -153,6 +153,35 @@ EOT;
|
|||
$this->assertResponse($response, 'product/create_response', Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_does_not_allow_to_create_product_with_too_long_translations()
|
||||
{
|
||||
$this->loadFixturesFromFile('authentication/api_administrator.yml');
|
||||
$this->loadFixturesFromFile('resources/locales.yml');
|
||||
|
||||
$longString = str_repeat('s', 256);
|
||||
|
||||
$data =
|
||||
<<<EOT
|
||||
{
|
||||
"code": "MUG_TH",
|
||||
"translations": {
|
||||
"en_US": {
|
||||
"name": "{$longString}",
|
||||
"slug": "{$longString}"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOT;
|
||||
|
||||
$this->client->request('POST', '/api/v1/products/', [], [], static::$authorizedHeaderWithContentType, $data);
|
||||
|
||||
$response = $this->client->getResponse();
|
||||
$this->assertResponse($response, 'product/create_with_long_translations_validation_fail_response', Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"code": 400,
|
||||
"message": "Validation Failed",
|
||||
"errors": {
|
||||
"children": {
|
||||
"enabled": {},
|
||||
"translations": {
|
||||
"children": {
|
||||
"en_US": {
|
||||
"children": {
|
||||
"name": {
|
||||
"errors": [
|
||||
"Product name must not be longer than 255 characters."
|
||||
]
|
||||
},
|
||||
"slug": {
|
||||
"errors": [
|
||||
"Product slug must not be longer than 255 characters."
|
||||
]
|
||||
},
|
||||
"description": {},
|
||||
"metaKeywords": {},
|
||||
"metaDescription": {},
|
||||
"shortDescription": {}
|
||||
}
|
||||
},
|
||||
"nl_NL": {
|
||||
"children": {
|
||||
"name": {},
|
||||
"slug": {},
|
||||
"description": {},
|
||||
"metaKeywords": {},
|
||||
"metaDescription": {},
|
||||
"shortDescription": {}
|
||||
}
|
||||
},
|
||||
"fr_FR": {
|
||||
"children": {
|
||||
"name": {},
|
||||
"slug": {},
|
||||
"description": {},
|
||||
"metaKeywords": {},
|
||||
"metaDescription": {},
|
||||
"shortDescription": {}
|
||||
}
|
||||
},
|
||||
"de_CH": {
|
||||
"children": {
|
||||
"name": {},
|
||||
"slug": {},
|
||||
"description": {},
|
||||
"metaKeywords": {},
|
||||
"metaDescription": {},
|
||||
"shortDescription": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"attributes": {},
|
||||
"associations": {},
|
||||
"channels": {},
|
||||
"mainTaxon": {},
|
||||
"images": {},
|
||||
"code": {},
|
||||
"options": {},
|
||||
"productTaxons": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue