Skip to content
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

Fixes to endpoints and contract tests of CP #13003

Merged
merged 1 commit into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<collectionOperation name="admin_post">
<attribute name="method">POST</attribute>
<attribute name="normalization_context">
<attribute name="groups">admin:catalog_promotion:create</attribute>
<attribute name="groups">admin:catalog_promotion:read</attribute>
</attribute>
<attribute name="denormalization_context">
<attribute name="groups">admin:catalog_promotion:create</attribute>
Expand All @@ -50,7 +50,7 @@
<itemOperation name="admin_put">
<attribute name="method">PUT</attribute>
<attribute name="normalization_context">
<attribute name="groups">admin:catalog_promotion:update</attribute>
<attribute name="groups">admin:catalog_promotion:read</attribute>
</attribute>
<attribute name="denormalization_context">
<attribute name="groups">admin:catalog_promotion:update</attribute>
Expand Down
14 changes: 5 additions & 9 deletions tests/Api/Admin/CatalogPromotionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function it_allows_admin_to_get_catalog_promotions(): void

$response = $this->client->getResponse();

$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);
}

/** @test */
Expand All @@ -47,11 +47,6 @@ public function it_allows_admin_to_get_catalog_promotion(): void
$catalogPromotion = $this->loadFixturesAndGetCatalogPromotion();
$header = $this->getLoggedHeader();

$token = $this->logInAdminUser('api@example.com');
$authorizationHeader = self::$container->getParameter('sylius.api.authorization_header');
$header['HTTP_' . $authorizationHeader] = 'Bearer ' . $token;
$header = array_merge($header, self::CONTENT_TYPE_HEADER);

$this->client->request(
'GET',
sprintf('/api/v2/admin/catalog-promotions/%s', $catalogPromotion->getCode()),
Expand All @@ -62,7 +57,7 @@ public function it_allows_admin_to_get_catalog_promotion(): void

$response = $this->client->getResponse();

$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);
}

/** @test */
Expand All @@ -82,7 +77,7 @@ public function it_allows_admin_to_create_a_catalog_promotion(): void

$response = $this->client->getResponse();

$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);
}

/** @test */
Expand All @@ -102,7 +97,7 @@ public function it_allows_admin_to_update_catalog_promotion(): void

$response = $this->client->getResponse();

$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);
}

/** @test */
Expand Down Expand Up @@ -139,6 +134,7 @@ private function getLoggedHeader(): array
$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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"@context": "\/api\/v2\/contexts\/CatalogPromotion",
"@id": "\/api\/v2\/admin\/catalog-promotions\/mugs_discount",
"@type": "CatalogPromotion",
"id": "@integer@",
"id": @integer@,
"name": "Mugs discount",
"code": "mugs_discount"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"@id": "\/api\/v2\/admin\/catalog-promotions\/mugs_discount",
"@type": "CatalogPromotion",
"id": "@integer@",
"id": @integer@,
"name": "Mugs discount",
"code": "mugs_discount"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"@context": "\/api\/v2\/contexts\/CatalogPromotion",
"@id": "\/api\/v2\/admin\/catalog-promotions\/new_code",
"@type": "CatalogPromotion",
"id": "@integer@",
"id": @integer@,
"name": "new_promotion",
"code": "new_code"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"@context": "\/api\/v2\/contexts\/CatalogPromotion",
"@id": "\/api\/v2\/admin\/catalog-promotions\/new_code",
"@type": "CatalogPromotion",
"id": "@integer@",
"id": @integer@,
"name": "new_promotion",
"code": "new_code"
}