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

[Order] Remove channel code from order routes #465

Merged
merged 1 commit into from
Jul 17, 2019
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
3 changes: 2 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
| `taxon-products-by-slug/{taxonSlug}` | `taxon-products/by-slug/{taxonSlug}` |
| `product/by-slug/{slug}/reviews` | `products/by-slug/{slug}/reviews` |

* The channel code has been removed from checkout routes:
* The channel code has been removed from routes:

| Old Route | New route |
|:--------------------------------------|:---------------------------------------|
| `{channelCode}/checkout/*` | `checkout/*` |
| `{channelCode}/orders/*` | `orders/*` |

# UPGRADE FROM 1.0.0-beta.17 to 1.0.0-beta.18

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ sylius_shop_api_address_book:

sylius_shop_api_order:
resource: "@ShopApiPlugin/Resources/config/routing/order.yml"
prefix: /shop-api/{channelCode}
prefix: /shop-api
32 changes: 8 additions & 24 deletions tests/Controller/Order/OrderShowApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public function it_shows_details_of_placed_order_of_logged_in_customer(): void

$this->placeOrderForCustomerWithEmail($email, $token);

$this->client->request('GET', '/shop-api/WEB_GB/orders/' . $token, [], [], self::CONTENT_TYPE_HEADER);
$response = $this->client->getResponse();

$response = $this->showOrder($token);
$this->assertResponse($response, 'order/order_details_response', Response::HTTP_OK);
}

Expand All @@ -44,9 +42,7 @@ public function it_shows_details_of_placed_order_of_guest_customer(): void

$this->placeOrderForCustomerWithEmail($email, $token);

$this->client->request('GET', '/shop-api/WEB_GB/orders/' . $token, [], [], self::CONTENT_TYPE_HEADER);
$response = $this->client->getResponse();

$response = $this->showOrder($token);
$this->assertResponse($response, 'order/order_details_response_guest', Response::HTTP_OK);
}

Expand All @@ -58,9 +54,7 @@ public function it_returns_a_not_found_exception_if_there_is_no_placed_order_wit
$this->loadFixturesFromFiles(['channel.yml', 'customer.yml']);
$this->logInUser('oliver@queen.com', '123password');

$this->client->request('GET', '/shop-api/WEB_GB/orders/NOT_EXISTING_TOKEN', [], [], self::CONTENT_TYPE_HEADER);
$response = $this->client->getResponse();

$response = $this->showOrder('NOT_EXISTING_TOKEN');
$this->assertResponse($response, 'order/order_not_found_response', Response::HTTP_NOT_FOUND);
}

Expand All @@ -71,9 +65,7 @@ public function it_returns_a_not_found_exception_if_there_is_no_placed_order_wit
{
$this->loadFixturesFromFiles(['channel.yml']);

$this->client->request('GET', '/shop-api/WEB_GB/orders/NOT_EXISTING_TOKEN', [], [], self::CONTENT_TYPE_HEADER);
$response = $this->client->getResponse();

$response = $this->showOrder('NOT_EXISTING_TOKEN');
$this->assertResponse($response, 'order/order_not_found_response_guest', Response::HTTP_NOT_FOUND);
}

Expand All @@ -93,22 +85,14 @@ public function it_returns_a_not_found_exception_if_placed_order_with_given_toke
//logout
$this->client->setServerParameter('HTTP_Authorization', null);

$this->client->request('GET', '/shop-api/WEB_GB/orders/' . $token, [], [], self::CONTENT_TYPE_HEADER);
$response = $this->client->getResponse();

$response = $this->showOrder($token);
$this->assertResponse($response, 'order/order_placed_by_registered_customer', Response::HTTP_NOT_FOUND);
}

/**
* @test
*/
public function it_does_not_show_order_details_in_non_existent_channel(): void
private function showOrder(string $token): Response
{
$this->loadFixturesFromFiles(['channel.yml']);

$this->client->request('GET', '/shop-api/SPACE_KLINGON/orders/ORDER_TOKEN', [], [], self::CONTENT_TYPE_HEADER);
$response = $this->client->getResponse();
$this->client->request('GET', sprintf('/shop-api/orders/%s', $token), [], [], self::CONTENT_TYPE_HEADER);

$this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND);
return $this->client->getResponse();
}
}
20 changes: 5 additions & 15 deletions tests/Controller/Order/OrdersListApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public function it_lists_only_placed_orders_of_logged_in_customer(): void

$this->placeOrderForCustomerWithEmail($email, $token);

$this->client->request('GET', '/shop-api/WEB_GB/orders', [], [], self::CONTENT_TYPE_HEADER);
$response = $this->client->getResponse();

$response = $this->listOrders();
$this->assertResponse($response, 'order/orders_list_response', Response::HTTP_OK);
}

Expand All @@ -40,22 +38,14 @@ public function it_returns_an_unauthorized_exception_if_there_is_no_logged_in_us
{
$this->loadFixturesFromFile('channel.yml');

$this->client->request('GET', '/shop-api/WEB_GB/orders', [], [], self::CONTENT_TYPE_HEADER);
$response = $this->client->getResponse();

$response = $this->listOrders();
$this->assertResponseCode($response, Response::HTTP_UNAUTHORIZED);
}

/**
* @test
*/
public function it_does_not_show_orders_list_in_non_existent_channel(): void
private function listOrders(): Response
{
$this->loadFixturesFromFile('channel.yml');

$this->client->request('GET', '/shop-api/SPACE_KLINGON/orders', [], [], self::CONTENT_TYPE_HEADER);
$response = $this->client->getResponse();
$this->client->request('GET', '/shop-api/orders', [], [], self::CONTENT_TYPE_HEADER);

$this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND);
return $this->client->getResponse();
}
}