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
Get, Update, Post and delete catalog promotions #12994
Get, Update, Post and delete catalog promotions #12994
Conversation
dbf1c91
to
80231af
Compare
80231af
to
8186723
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.
IMO, in this PR you should add also behat scenarios for updating and deleting catalog promotion
src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/CatalogPromotion.xml
Show resolved
Hide resolved
524246b
to
089e60a
Compare
b8062d5
to
5128035
Compare
5128035
to
9044d8f
Compare
Behat tests for this feature will be added in next PR 🎉 |
<attribute name="normalization_context"> | ||
<attribute name="groups">admin:catalog_promotion:update</attribute> | ||
</attribute> |
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.
<attribute name="normalization_context"> | |
<attribute name="groups">admin:catalog_promotion:update</attribute> | |
</attribute> | |
<attribute name="normalization_context"> | |
<attribute name="groups">admin:catalog_promotion:read</attribute> | |
</attribute> |
@@ -30,12 +30,38 @@ | |||
|
|||
<collectionOperation name="admin_post"> | |||
<attribute name="method">POST</attribute> | |||
<attribute name="normalization_context"> | |||
<attribute name="groups">admin:catalog_promotion:create</attribute> |
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.
<attribute name="groups">admin:catalog_promotion:create</attribute> | |
<attribute name="groups">admin:catalog_promotion:read</attribute> |
|
||
$response = $this->client->getResponse(); | ||
|
||
$this->assertResponse($response, 'admin/catalog_promotion/get_catalog_promotions_admin_response', Response::HTTP_OK); |
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->assertResponse($response, 'admin/catalog_promotion/get_catalog_promotions_admin_response', Response::HTTP_OK); | |
$this->assertResponse($response, 'admin/catalog_promotion/get_catalog_promotions_response', Response::HTTP_OK); |
[], | ||
[], | ||
$header | ||
); | ||
|
||
$response = $this->client->getResponse(); | ||
|
||
$this->assertResponse($response, 'admin/get_catalog_promotions_response', Response::HTTP_OK); | ||
$this->assertResponse($response, 'admin/catalog_promotion/get_catalog_promotion_admin_response', Response::HTTP_OK); |
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->assertResponse($response, 'admin/catalog_promotion/get_catalog_promotion_admin_response', Response::HTTP_OK); | |
$this->assertResponse($response, 'admin/catalog_promotion/get_catalog_promotion_response', Response::HTTP_OK); |
|
||
$response = $this->client->getResponse(); | ||
|
||
$this->assertResponse($response, 'admin/catalog_promotion/post_catalog_promotion_admin_response', Response::HTTP_CREATED); |
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->assertResponse($response, 'admin/catalog_promotion/post_catalog_promotion_admin_response', Response::HTTP_CREATED); | |
$this->assertResponse($response, 'admin/catalog_promotion/post_catalog_promotion_response', Response::HTTP_CREATED); |
|
||
$response = $this->client->getResponse(); | ||
|
||
$this->assertResponse($response, 'admin/catalog_promotion/put_catalog_promotion_admin_response', Response::HTTP_OK); |
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->assertResponse($response, 'admin/catalog_promotion/put_catalog_promotion_admin_response', Response::HTTP_OK); | |
$this->assertResponse($response, 'admin/catalog_promotion/put_catalog_promotion_response', Response::HTTP_OK); |
$token = $this->logInAdminUser('api@example.com'); | ||
$authorizationHeader = self::$container->getParameter('sylius.api.authorization_header'); | ||
$header['HTTP_' . $authorizationHeader] = 'Bearer ' . $token; | ||
return array_merge($header, self::CONTENT_TYPE_HEADER); |
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.
return array_merge($header, self::CONTENT_TYPE_HEADER); | |
return array_merge($header, self::CONTENT_TYPE_HEADER); |
@@ -6,7 +6,7 @@ | |||
{ | |||
"@id": "\/api\/v2\/admin\/catalog-promotions\/mugs_discount", | |||
"@type": "CatalogPromotion", | |||
"id": @integer@, | |||
"id": "@integer@", |
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 did you change that? IMO here and in other responses there should be:
"id": "@integer@", | |
"id": @integer@, |
Thank you, @arti0090! 🥇 |
This PR was merged into the 1.11-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | License | MIT minor fixes of #12994 Commits ------- 54328e9 Fixes to endpoints and contract tests of CP
… (arti0090) This PR was merged into the 1.11-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | no | New feature? | yes (behat for feature) | BC breaks? | no | Deprecations? | no | License | MIT Promised behats for #12994 Commits ------- 3e37138 Add delete behat with factory c690e3b Delete covered in behat be54912 Edit covered in behats 4e67186 Revert behat of delete 2912c4f Changing services and tests
extends #12986