-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API] [Product] [ProductTranslation] Add api configuration and test for adding product and product translations #11213
Conversation
Tomanhez
commented
Mar 11, 2020
Q | A |
---|---|
Branch? | api |
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
License | MIT |
dc1326f
to
bdade86
Compare
$data = ['translations' => [$language => ['locale' => $language]]]; | ||
$data['translations'][$language]['name'] = $name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$data = ['translations' => [$language => ['locale' => $language]]]; | |
$data['translations'][$language]['name'] = $name; | |
$data = [ | |
'translations' => [ | |
$language => [ | |
'locale' => $language, | |
'name' => $name, | |
], | |
], | |
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if 'locale' => $language
will be omitted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not working
*/ | ||
public function iSetItsSlugTo(?string $slug = null, $language = 'en_US'): void | ||
{ | ||
$data = ['translations' => [$language => ['slug' => $slug]]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this configuration different than the configuration for the name field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/ProductTranslation.xml
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Resources/config/serializer/ProductTranslation.xml
Outdated
Show resolved
Hide resolved
443576b
to
50628ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I would wait for #11210 before merging
$data = [ | ||
'translations' => [ | ||
$localeCode => [ | ||
'slug' => $slug, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work now:
'slug' => $slug, | |
'locale' => $localeCode, | |
'slug' => $slug, |
*/ | ||
public function theProductShouldAppearInTheShop(string $productName): void | ||
{ | ||
$this->client->index(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->client->index(); | |
$response = $this->client->index(); |
Assert::true( | ||
$this | ||
->responseChecker | ||
->hasItemWithTranslation($this->client->getLastResponse(),'en_US', 'name', $productName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
->hasItemWithTranslation($this->client->getLastResponse(),'en_US', 'name', $productName) | |
->hasItemWithTranslation($response, 'en_US', 'name', $productName) |
$this | ||
->responseChecker | ||
->hasItemWithTranslation($this->client->getLastResponse(),'en_US', 'name', $productName) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing exception message
*/ | ||
public function iShouldBeNotifiedThatItHasBeenSuccessfullyCreated(): void | ||
{ | ||
Assert::true($this->responseChecker->isCreationSuccessful($this->client->getLastResponse())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing exception message
Thank you, Tomasz! 🥇 |
Part of #11250 |