From 58805d6e3e4dbd0207ce103b4b7a8b8a9f0d4181 Mon Sep 17 00:00:00 2001 From: Grzegorz Sadowski Date: Fri, 19 Jul 2019 09:07:11 +0200 Subject: [PATCH] [Customer] Remove channel code from customer routes --- UPGRADE.md | 16 ++++++--- doc/swagger.yml | 19 +++++----- .../Customer/RegisterCustomerAction.php | 17 +++++++-- .../RequestPasswordResettingAction.php | 16 +++++++-- .../ResendVerificationTokenAction.php | 17 +++++++-- .../Customer/RegisterCustomerRequest.php | 4 +-- .../ResendVerificationTokenRequest.php | 4 +-- src/Resources/config/routing.yml | 4 +-- .../config/services/actions/customer.xml | 3 ++ .../Customer/CustomerLoginApiTest.php | 2 +- .../Customer/CustomerRegisterApiTest.php | 31 +++------------- ...ustomerRequestPasswordResettingApiTest.php | 17 +-------- ...CustomerResendVerificationTokenApiTest.php | 25 +++---------- .../Customer/CustomerResetPasswordApiTest.php | 36 ++----------------- .../CustomerUpdateCustomerApiTest.php | 29 ++------------- .../Customer/CustomerVerifyApiTest.php | 35 ++---------------- .../LoggedInCustomerDetailsActionTest.php | 31 +--------------- tests/DataFixtures/ORM/channel.yml | 2 +- .../ResendVerificationTokenRequestTest.php | 12 +++++-- 19 files changed, 98 insertions(+), 222 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 8f3498fe5..d4e862275 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -25,11 +25,17 @@ * The channel code has been removed from routes: - | Old Route | New route | - |:--------------------------------------|:---------------------------------------| - | `{channelCode}/address-book/*` | `address-book/*` | - | `{channelCode}/checkout/*` | `checkout/*` | - | `{channelCode}/orders/*` | `orders/*` | + | Old Route | New route | + |:-----------------------------------------|:------------------------------------| + | `{channelCode}/address-book/*` | `address-book/*` | + | `{channelCode}/checkout/*` | `checkout/*` | + | `{channelCode}/me` | `me` | + | `{channelCode}/orders/*` | `orders/*` | + | `{channelCode}/password-reset/*` | `password-reset/*` | + | `{channelCode}/register` | `orders/*` | + | `{channelCode}/request-password-reset` | `request-password-reset` | + | `{channelCode}/resend-verification-link` | `resend-verification-link` | + | `{channelCode}/verify-account` | `verify-account` | # UPGRADE FROM 1.0.0-beta.17 to 1.0.0-beta.18 diff --git a/doc/swagger.yml b/doc/swagger.yml index bb1a6590a..e3c8075b2 100644 --- a/doc/swagger.yml +++ b/doc/swagger.yml @@ -683,9 +683,8 @@ paths: description: "Requested taxon with children." schema: $ref: "#/definitions/TaxonDetails" - /{channelCode}/request-password-reset: - parameters: - - $ref: "#/parameters/ChannelCode" + + /request-password-reset: put: tags: - "users" @@ -703,9 +702,9 @@ paths: description: "Reset password request has been sent." 500: description: "User with provided email has not been found." - /{channelCode}/password-reset/{token}: + + /password-reset/{token}: parameters: - - $ref: "#/parameters/ChannelCode" - in: "path" name: "token" description: "Password reset token." @@ -728,9 +727,8 @@ paths: description: "Update password request success." 400: description: "Token not found." - /{channelCode}/register: - parameters: - - $ref: "#/parameters/ChannelCode" + + /register: post: tags: - "users" @@ -793,9 +791,8 @@ paths: description: "Order with given tokenValue not found" security: - bearerAuth: [] - /{channelCode}/me: - parameters: - - $ref: "#/parameters/ChannelCode" + + /me: get: tags: - "users" diff --git a/src/Controller/Customer/RegisterCustomerAction.php b/src/Controller/Customer/RegisterCustomerAction.php index 0066f1eeb..e5a5cc246 100644 --- a/src/Controller/Customer/RegisterCustomerAction.php +++ b/src/Controller/Customer/RegisterCustomerAction.php @@ -6,6 +6,7 @@ use FOS\RestBundle\View\View; use FOS\RestBundle\View\ViewHandlerInterface; +use Sylius\Component\Channel\Context\ChannelContextInterface; use Sylius\ShopApiPlugin\Factory\ValidationErrorViewFactoryInterface; use Sylius\ShopApiPlugin\Request\Customer\RegisterCustomerRequest; use Symfony\Component\HttpFoundation\Request; @@ -27,26 +28,36 @@ final class RegisterCustomerAction /** @var ValidationErrorViewFactoryInterface */ private $validationErrorViewFactory; + /** @var ChannelContextInterface */ + private $channelContext; + public function __construct( ViewHandlerInterface $viewHandler, MessageBusInterface $bus, ValidatorInterface $validator, - ValidationErrorViewFactoryInterface $validationErrorViewFactory + ValidationErrorViewFactoryInterface $validationErrorViewFactory, + ChannelContextInterface $channelContext ) { $this->viewHandler = $viewHandler; $this->bus = $bus; $this->validator = $validator; $this->validationErrorViewFactory = $validationErrorViewFactory; + $this->channelContext = $channelContext; } public function __invoke(Request $request): Response { - $registerCustomerRequest = new RegisterCustomerRequest($request); + $channel = $this->channelContext->getChannel(); + + $registerCustomerRequest = new RegisterCustomerRequest($request, $channel->getCode()); $validationResults = $this->validator->validate($registerCustomerRequest); if (0 !== count($validationResults)) { - return $this->viewHandler->handle(View::create($this->validationErrorViewFactory->create($validationResults), Response::HTTP_BAD_REQUEST)); + return $this->viewHandler->handle(View::create( + $this->validationErrorViewFactory->create($validationResults), + Response::HTTP_BAD_REQUEST + )); } $this->bus->dispatch($registerCustomerRequest->getCommand()); diff --git a/src/Controller/Customer/RequestPasswordResettingAction.php b/src/Controller/Customer/RequestPasswordResettingAction.php index 2d14dfffd..70257a311 100644 --- a/src/Controller/Customer/RequestPasswordResettingAction.php +++ b/src/Controller/Customer/RequestPasswordResettingAction.php @@ -6,6 +6,7 @@ use FOS\RestBundle\View\View; use FOS\RestBundle\View\ViewHandlerInterface; +use Sylius\Component\Channel\Context\ChannelContextInterface; use Sylius\ShopApiPlugin\Command\Customer\GenerateResetPasswordToken; use Sylius\ShopApiPlugin\Command\Customer\SendResetPasswordToken; use Symfony\Component\HttpFoundation\Request; @@ -20,16 +21,25 @@ final class RequestPasswordResettingAction /** @var MessageBusInterface */ private $bus; - public function __construct(ViewHandlerInterface $viewHandler, MessageBusInterface $bus) - { + /** @var ChannelContextInterface */ + private $channelContext; + + public function __construct( + ViewHandlerInterface $viewHandler, + MessageBusInterface $bus, + ChannelContextInterface $channelContext + ) { $this->viewHandler = $viewHandler; $this->bus = $bus; + $this->channelContext = $channelContext; } public function __invoke(Request $request): Response { + $channel = $this->channelContext->getChannel(); + $this->bus->dispatch(new GenerateResetPasswordToken($request->request->get('email'))); - $this->bus->dispatch(new SendResetPasswordToken($request->request->get('email'), $request->attributes->get('channelCode'))); + $this->bus->dispatch(new SendResetPasswordToken($request->request->get('email'), $channel->getCode())); return $this->viewHandler->handle(View::create(null, Response::HTTP_NO_CONTENT)); } diff --git a/src/Controller/Customer/ResendVerificationTokenAction.php b/src/Controller/Customer/ResendVerificationTokenAction.php index 9eca2fdd9..91c9c4907 100644 --- a/src/Controller/Customer/ResendVerificationTokenAction.php +++ b/src/Controller/Customer/ResendVerificationTokenAction.php @@ -6,6 +6,7 @@ use FOS\RestBundle\View\View; use FOS\RestBundle\View\ViewHandlerInterface; +use Sylius\Component\Channel\Context\ChannelContextInterface; use Sylius\ShopApiPlugin\Factory\ValidationErrorViewFactoryInterface; use Sylius\ShopApiPlugin\Request\Customer\ResendVerificationTokenRequest; use Symfony\Component\HttpFoundation\Request; @@ -27,26 +28,36 @@ final class ResendVerificationTokenAction /** @var ValidationErrorViewFactoryInterface */ private $validationErrorViewFactory; + /** @var ChannelContextInterface */ + private $channelContext; + public function __construct( ViewHandlerInterface $viewHandler, MessageBusInterface $bus, ValidatorInterface $validator, - ValidationErrorViewFactoryInterface $validationErrorViewFactory + ValidationErrorViewFactoryInterface $validationErrorViewFactory, + ChannelContextInterface $channelContext ) { $this->viewHandler = $viewHandler; $this->bus = $bus; $this->validator = $validator; $this->validationErrorViewFactory = $validationErrorViewFactory; + $this->channelContext = $channelContext; } public function __invoke(Request $request): Response { - $resendVerificationTokenRequest = new ResendVerificationTokenRequest($request); + $channel = $this->channelContext->getChannel(); + + $resendVerificationTokenRequest = new ResendVerificationTokenRequest($request, $channel->getCode()); $validationResults = $this->validator->validate($resendVerificationTokenRequest); if (0 !== count($validationResults)) { - return $this->viewHandler->handle(View::create($this->validationErrorViewFactory->create($validationResults), Response::HTTP_BAD_REQUEST)); + return $this->viewHandler->handle(View::create( + $this->validationErrorViewFactory->create($validationResults), + Response::HTTP_BAD_REQUEST + )); } $this->bus->dispatch($resendVerificationTokenRequest->getCommand()); diff --git a/src/Request/Customer/RegisterCustomerRequest.php b/src/Request/Customer/RegisterCustomerRequest.php index f574090fd..1840a2dd7 100644 --- a/src/Request/Customer/RegisterCustomerRequest.php +++ b/src/Request/Customer/RegisterCustomerRequest.php @@ -24,9 +24,9 @@ class RegisterCustomerRequest /** @var string */ protected $channelCode; - public function __construct(Request $request) + public function __construct(Request $request, string $channelCode) { - $this->channelCode = $request->attributes->get('channelCode'); + $this->channelCode = $channelCode; $this->email = $request->request->get('email'); $this->plainPassword = $request->request->get('plainPassword'); diff --git a/src/Request/Customer/ResendVerificationTokenRequest.php b/src/Request/Customer/ResendVerificationTokenRequest.php index 0d2390293..2d26de0f7 100644 --- a/src/Request/Customer/ResendVerificationTokenRequest.php +++ b/src/Request/Customer/ResendVerificationTokenRequest.php @@ -15,10 +15,10 @@ class ResendVerificationTokenRequest /** @var string */ protected $channelCode; - public function __construct(Request $request) + public function __construct(Request $request, string $channelCode) { $this->email = $request->request->get('email'); - $this->channelCode = $request->attributes->get('channelCode'); + $this->channelCode = $channelCode; } public function getCommand(): SendVerificationToken diff --git a/src/Resources/config/routing.yml b/src/Resources/config/routing.yml index 215eb8bf9..32575eccb 100644 --- a/src/Resources/config/routing.yml +++ b/src/Resources/config/routing.yml @@ -16,7 +16,7 @@ sylius_shop_api_taxon: sylius_shop_api_register: resource: "@ShopApiPlugin/Resources/config/routing/register.yml" - prefix: /shop-api/{channelCode} + prefix: /shop-api sylius_shop_api_checkout: resource: "@ShopApiPlugin/Resources/config/routing/checkout.yml" @@ -24,7 +24,7 @@ sylius_shop_api_checkout: sylius_shop_api_customer: resource: "@ShopApiPlugin/Resources/config/routing/customer.yml" - prefix: /shop-api/{channelCode} + prefix: /shop-api sylius_shop_api_product_list: resource: "@ShopApiPlugin/Resources/config/routing/productList.yml" diff --git a/src/Resources/config/services/actions/customer.xml b/src/Resources/config/services/actions/customer.xml index 4a0d385f7..2378d0686 100644 --- a/src/Resources/config/services/actions/customer.xml +++ b/src/Resources/config/services/actions/customer.xml @@ -11,6 +11,7 @@ + + + client->request('POST', '/shop-api/WEB_GB/register', [], [], self::CONTENT_TYPE_HEADER, $data); + $this->client->request('POST', '/shop-api/register', [], [], self::CONTENT_TYPE_HEADER, $data); $data = <<client->request('POST', '/shop-api/WEB_GB/register', [], [], self::CONTENT_TYPE_HEADER, $data); + $this->client->request('POST', '/shop-api/register', [], [], self::CONTENT_TYPE_HEADER, $data); $response = $this->client->getResponse(); $this->assertResponseCode($response, Response::HTTP_NO_CONTENT); @@ -67,7 +67,7 @@ public function it_allows_to_register_in_shop_and_automatically_enables_user_if_ } EOT; - $this->client->request('POST', '/shop-api/WEB_DE/register', [], [], self::CONTENT_TYPE_HEADER, $data); + $this->client->request('POST', 'http://web-de.com/shop-api/register', [], [], self::CONTENT_TYPE_HEADER, $data); $response = $this->client->getResponse(); $this->assertResponseCode($response, Response::HTTP_NO_CONTENT); @@ -108,7 +108,7 @@ public function it_does_not_allow_to_register_in_shop_if_email_is_already_taken( } EOT; - $this->client->request('POST', '/shop-api/WEB_GB/register', [], [], self::CONTENT_TYPE_HEADER, $data); + $this->client->request('POST', '/shop-api/register', [], [], self::CONTENT_TYPE_HEADER, $data); $response = $this->client->getResponse(); @@ -131,36 +131,13 @@ public function it_does_not_allow_to_register_in_shop_without_passing_required_d } EOT; - $this->client->request('POST', '/shop-api/WEB_GB/register', [], [], self::CONTENT_TYPE_HEADER, $data); + $this->client->request('POST', '/shop-api/register', [], [], self::CONTENT_TYPE_HEADER, $data); $response = $this->client->getResponse(); $this->assertResponse($response, 'customer/validation_registration_data_response', Response::HTTP_BAD_REQUEST); } - /** - * @test - */ - public function it_does_not_allow_to_register_in_non_existent_channel(): void - { - $this->loadFixturesFromFiles(['channel.yml']); - - $data = -<<client->request('POST', '/shop-api/SPACE_KLINGON/register', [], [], self::CONTENT_TYPE_HEADER, $data); - - $response = $this->client->getResponse(); - - $this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND); - } - protected function getContainer(): ContainerInterface { return static::$sharedKernel->getContainer(); diff --git a/tests/Controller/Customer/CustomerRequestPasswordResettingApiTest.php b/tests/Controller/Customer/CustomerRequestPasswordResettingApiTest.php index ddbec63d2..7dd6486ab 100644 --- a/tests/Controller/Customer/CustomerRequestPasswordResettingApiTest.php +++ b/tests/Controller/Customer/CustomerRequestPasswordResettingApiTest.php @@ -23,7 +23,7 @@ public function it_allows_to_reset_user_password(): void $data = '{"email": "oliver@queen.com"}'; - $this->client->request('PUT', '/shop-api/WEB_GB/request-password-reset', [], [], self::CONTENT_TYPE_HEADER, $data); + $this->client->request('PUT', '/shop-api/request-password-reset', [], [], self::CONTENT_TYPE_HEADER, $data); $response = $this->client->getResponse(); $this->assertResponseCode($response, Response::HTTP_NO_CONTENT); @@ -34,21 +34,6 @@ public function it_allows_to_reset_user_password(): void $this->assertTrue($emailChecker->hasRecipient('oliver@queen.com')); } - /** - * @test - */ - public function it_does_not_allow_to_reset_user_password_in_non_existent_channel(): void - { - $this->loadFixturesFromFiles(['channel.yml', 'customer.yml']); - - $data = '{"email": "oliver@queen.com"}'; - - $this->client->request('PUT', '/shop-api/SPACE_KLINGON/request-password-reset', [], [], self::CONTENT_TYPE_HEADER, $data); - - $response = $this->client->getResponse(); - $this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND); - } - protected function getContainer(): ContainerInterface { return static::$sharedKernel->getContainer(); diff --git a/tests/Controller/Customer/CustomerResendVerificationTokenApiTest.php b/tests/Controller/Customer/CustomerResendVerificationTokenApiTest.php index d1599b7cd..25586554a 100644 --- a/tests/Controller/Customer/CustomerResendVerificationTokenApiTest.php +++ b/tests/Controller/Customer/CustomerResendVerificationTokenApiTest.php @@ -31,11 +31,11 @@ public function it_allows_to_resend_verification_token(): void } EOT; - $this->client->request('POST', '/shop-api/WEB_GB/register', [], [], self::CONTENT_TYPE_HEADER, $data); + $this->client->request('POST', '/shop-api/register', [], [], self::CONTENT_TYPE_HEADER, $data); $resendForEmail = '{"email": "vinny@fandf.com"}'; - $this->client->request('POST', '/shop-api/WEB_GB/resend-verification-link', [], [], self::CONTENT_TYPE_HEADER, $resendForEmail); + $this->client->request('POST', '/shop-api/resend-verification-link', [], [], self::CONTENT_TYPE_HEADER, $resendForEmail); $response = $this->client->getResponse(); $this->assertResponseCode($response, Response::HTTP_CREATED); @@ -53,7 +53,7 @@ public function it_does_not_allow_to_resend_verification_email_if_email_is_not_d { $this->loadFixturesFromFiles(['channel.yml']); - $this->client->request('POST', '/shop-api/WEB_GB/resend-verification-link', [], [], self::CONTENT_TYPE_HEADER); + $this->client->request('POST', '/shop-api/resend-verification-link', [], [], self::CONTENT_TYPE_HEADER); $response = $this->client->getResponse(); $this->assertResponse($response, 'customer/validation_email_not_defined_response', Response::HTTP_BAD_REQUEST); @@ -68,7 +68,7 @@ public function it_does_not_allow_to_resend_verification_email_if_email_is_not_m $resendForEmail = '{"email": "vinnyfandf.com"}'; - $this->client->request('POST', '/shop-api/WEB_GB/resend-verification-link', [], [], self::CONTENT_TYPE_HEADER, $resendForEmail); + $this->client->request('POST', '/shop-api/resend-verification-link', [], [], self::CONTENT_TYPE_HEADER, $resendForEmail); $response = $this->client->getResponse(); $this->assertResponse($response, 'customer/validation_email_not_valid_response', Response::HTTP_BAD_REQUEST); @@ -83,27 +83,12 @@ public function it_does_not_allow_to_resend_verification_email_if_customer_does_ $resendForEmail = '{"email": "vinny@fandf.com"}'; - $this->client->request('POST', '/shop-api/WEB_GB/resend-verification-link', [], [], self::CONTENT_TYPE_HEADER, $resendForEmail); + $this->client->request('POST', '/shop-api/resend-verification-link', [], [], self::CONTENT_TYPE_HEADER, $resendForEmail); $response = $this->client->getResponse(); $this->assertResponse($response, 'customer/validation_email_not_found_response', Response::HTTP_BAD_REQUEST); } - /** - * @test - */ - public function it_does_not_allow_to_resend_verification_token_in_non_existent_channel(): void - { - $this->loadFixturesFromFiles(['channel.yml']); - - $resendForEmail = '{"email": "vinny@fandf.com"}'; - - $this->client->request('POST', '/shop-api/SPACE_KLINGON/resend-verification-link', [], [], self::CONTENT_TYPE_HEADER, $resendForEmail); - - $response = $this->client->getResponse(); - $this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND); - } - protected function getContainer(): ContainerInterface { return static::$sharedKernel->getContainer(); diff --git a/tests/Controller/Customer/CustomerResetPasswordApiTest.php b/tests/Controller/Customer/CustomerResetPasswordApiTest.php index 3a4fa40bf..a942f2bde 100644 --- a/tests/Controller/Customer/CustomerResetPasswordApiTest.php +++ b/tests/Controller/Customer/CustomerResetPasswordApiTest.php @@ -24,7 +24,7 @@ public function it_allows_to_reset_customer_password(): void $data = '{"email": "oliver@queen.com"}'; - $this->client->request('PUT', '/shop-api/WEB_GB/request-password-reset', [], [], self::CONTENT_TYPE_HEADER, $data); + $this->client->request('PUT', '/shop-api/request-password-reset', [], [], self::CONTENT_TYPE_HEADER, $data); /** @var UserRepositoryInterface $userRepository */ $userRepository = $this->get('sylius.repository.shop_user'); @@ -42,44 +42,12 @@ public function it_allows_to_reset_customer_password(): void } EOT; - $this->client->request('PUT', '/shop-api/WEB_GB/password-reset/' . $user->getPasswordResetToken(), [], [], self::CONTENT_TYPE_HEADER, $newPasswords); + $this->client->request('PUT', '/shop-api/password-reset/' . $user->getPasswordResetToken(), [], [], self::CONTENT_TYPE_HEADER, $newPasswords); $response = $this->client->getResponse(); $this->assertResponseCode($response, Response::HTTP_NO_CONTENT); } - /** - * @test - */ - public function it_does_not_allow_to_reset_customer_password_in_non_existent_channel(): void - { - $this->loadFixturesFromFiles(['channel.yml', 'customer.yml']); - - $data = '{"email": "oliver@queen.com"}'; - - $this->client->request('PUT', '/shop-api/WEB_GB/request-password-reset', [], [], self::CONTENT_TYPE_HEADER, $data); - - /** @var UserRepositoryInterface $userRepository */ - $userRepository = $this->get('sylius.repository.shop_user'); - /** @var ShopUserInterface $user */ - $user = $userRepository->findOneByEmail('oliver@queen.com'); - - $newPasswords = -<<client->request('PUT', '/shop-api/SPACE_KLINGON/password-reset/' . $user->getPasswordResetToken(), [], [], self::CONTENT_TYPE_HEADER, $newPasswords); - - $response = $this->client->getResponse(); - $this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND); - } - protected function getContainer(): ContainerInterface { return static::$sharedKernel->getContainer(); diff --git a/tests/Controller/Customer/CustomerUpdateCustomerApiTest.php b/tests/Controller/Customer/CustomerUpdateCustomerApiTest.php index f77ccdfaa..ff26994a9 100644 --- a/tests/Controller/Customer/CustomerUpdateCustomerApiTest.php +++ b/tests/Controller/Customer/CustomerUpdateCustomerApiTest.php @@ -38,7 +38,7 @@ public function it_updates_customer(): void "subscribedToNewsletter": true } EOT; - $this->client->request('PUT', '/shop-api/WEB_GB/me', [], [], self::CONTENT_TYPE_HEADER, $data); + $this->client->request('PUT', '/shop-api/me', [], [], self::CONTENT_TYPE_HEADER, $data); $response = $this->client->getResponse(); $this->assertResponse($response, 'customer/update_customer', Response::HTTP_OK); @@ -73,7 +73,7 @@ public function it_does_not_allow_to_update_customer_without_being_logged_in(): "subscribedToNewsletter": true } EOT; - $this->client->request('PUT', '/shop-api/WEB_GB/me', [], [], self::CONTENT_TYPE_HEADER, $data); + $this->client->request('PUT', '/shop-api/me', [], [], self::CONTENT_TYPE_HEADER, $data); $response = $this->client->getResponse(); $this->assertResponseCode($response, Response::HTTP_INTERNAL_SERVER_ERROR); } @@ -96,31 +96,8 @@ public function it_does_not_allow_to_update_customer_without_passing_required_da "phoneNumber": "" } EOT; - $this->client->request('PUT', '/shop-api/WEB_GB/me', [], [], self::CONTENT_TYPE_HEADER, $data); + $this->client->request('PUT', '/shop-api/me', [], [], self::CONTENT_TYPE_HEADER, $data); $response = $this->client->getResponse(); $this->assertResponse($response, 'customer/validation_empty_data', Response::HTTP_BAD_REQUEST); } - - /** - * @test - */ - public function it_does_not_allow_to_update_customer_in_non_existent_channel(): void - { - $this->loadFixturesFromFiles(['channel.yml', 'customer.yml']); - $this->logInUser('oliver@queen.com', '123password'); - - $data = -<<client->request('PUT', '/shop-api/SPACE_KLINGON/me', [], [], self::CONTENT_TYPE_HEADER, $data); - $response = $this->client->getResponse(); - $this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND); - } } diff --git a/tests/Controller/Customer/CustomerVerifyApiTest.php b/tests/Controller/Customer/CustomerVerifyApiTest.php index f75b65a85..7bdc89e14 100644 --- a/tests/Controller/Customer/CustomerVerifyApiTest.php +++ b/tests/Controller/Customer/CustomerVerifyApiTest.php @@ -31,7 +31,7 @@ public function it_allows_to_verify_customer(): void } EOT; - $this->client->request('POST', '/shop-api/WEB_GB/register', [], [], self::CONTENT_TYPE_HEADER, $data); + $this->client->request('POST', '/shop-api/register', [], [], self::CONTENT_TYPE_HEADER, $data); /** @var UserRepositoryInterface $userRepository */ $userRepository = $this->get('sylius.repository.shop_user'); @@ -39,43 +39,12 @@ public function it_allows_to_verify_customer(): void $parameters = ['token' => $user->getEmailVerificationToken()]; - $this->client->request('GET', '/shop-api/WEB_GB/verify-account', $parameters, [], ['ACCEPT' => 'application/json']); + $this->client->request('GET', '/shop-api/verify-account', $parameters, [], ['ACCEPT' => 'application/json']); $response = $this->client->getResponse(); $this->assertResponseCode($response, Response::HTTP_NO_CONTENT); } - /** - * @test - */ - public function it_does_not_allow_to_verify_customer_in_non_existent_channel(): void - { - $this->loadFixturesFromFiles(['channel.yml']); - - $data = -<<client->request('POST', '/shop-api/WEB_GB/register', [], [], self::CONTENT_TYPE_HEADER, $data); - - /** @var UserRepositoryInterface $userRepository */ - $userRepository = $this->get('sylius.repository.shop_user'); - $user = $userRepository->findOneByEmail('vinny@fandf.com'); - - $parameters = ['token' => $user->getEmailVerificationToken()]; - - $this->client->request('GET', '/shop-api/SPACE_KLINGON/verify-account', $parameters, [], self::CONTENT_TYPE_HEADER); - - $response = $this->client->getResponse(); - $this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND); - } - protected function getContainer(): ContainerInterface { return static::$sharedKernel->getContainer(); diff --git a/tests/Controller/Customer/LoggedInCustomerDetailsActionTest.php b/tests/Controller/Customer/LoggedInCustomerDetailsActionTest.php index df93b375e..b39b686fc 100644 --- a/tests/Controller/Customer/LoggedInCustomerDetailsActionTest.php +++ b/tests/Controller/Customer/LoggedInCustomerDetailsActionTest.php @@ -29,7 +29,7 @@ public function it_shows_currently_logged_in_customer_details(): void $response = json_decode($this->client->getResponse()->getContent(), true); $this->client->setServerParameter('HTTP_Authorization', sprintf('Bearer %s', $response['token'])); - $this->client->request('GET', '/shop-api/WEB_GB/me', [], [], [ + $this->client->request('GET', '/shop-api/me', [], [], [ 'CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json', ]); @@ -37,33 +37,4 @@ public function it_shows_currently_logged_in_customer_details(): void $response = $this->client->getResponse(); $this->assertResponse($response, 'customer/logged_in_customer_details_response', Response::HTTP_OK); } - - /** - * @test - */ - public function it_does_not_show_currently_logged_in_customer_details_in_non_existent_channel(): void - { - $this->loadFixturesFromFiles(['channel.yml', 'customer.yml']); - - $data = -<<client->request('POST', '/shop-api/login_check', [], [], self::CONTENT_TYPE_HEADER, $data); - - $response = json_decode($this->client->getResponse()->getContent(), true); - $this->client->setServerParameter('HTTP_Authorization', sprintf('Bearer %s', $response['token'])); - - $this->client->request('GET', '/shop-api/SPACE_KLINGON/me', [], [], [ - 'CONTENT_TYPE' => 'application/json', - 'ACCEPT' => 'application/json', - ]); - - $response = $this->client->getResponse(); - $this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND); - } } diff --git a/tests/DataFixtures/ORM/channel.yml b/tests/DataFixtures/ORM/channel.yml index e09b15bb4..656dcdfa1 100644 --- a/tests/DataFixtures/ORM/channel.yml +++ b/tests/DataFixtures/ORM/channel.yml @@ -14,7 +14,7 @@ Sylius\Component\Core\Model\Channel: de_web_channel: code: "WEB_DE" name: "Deutch Channel" - hostname: "localhost" + hostname: "web-de.com" description: "Lorem ipsum" baseCurrency: "@euro" defaultLocale: "@locale_de_de" diff --git a/tests/Request/ResendVerificationTokenRequestTest.php b/tests/Request/ResendVerificationTokenRequestTest.php index 6f021e72e..46a0da6ef 100644 --- a/tests/Request/ResendVerificationTokenRequestTest.php +++ b/tests/Request/ResendVerificationTokenRequestTest.php @@ -14,10 +14,16 @@ final class ResendVerificationTokenRequestTest extends TestCase /** * @test */ - public function it_creates_put_simple_item_to_cart_command() + public function it_creates_put_simple_item_to_cart_command(): void { - $putSimpleItemToCartRequest = new ResendVerificationTokenRequest(new Request([], ['email' => 'daffy@the-duck.com'], ['channelCode' => 'WEB_GB'])); + $putSimpleItemToCartRequest = new ResendVerificationTokenRequest( + new Request([], ['email' => 'daffy@the-duck.com']), + 'WEB_GB' + ); - $this->assertEquals($putSimpleItemToCartRequest->getCommand(), new SendVerificationToken('daffy@the-duck.com', 'WEB_GB')); + $this->assertEquals( + $putSimpleItemToCartRequest->getCommand(), + new SendVerificationToken('daffy@the-duck.com', 'WEB_GB') + ); } }