-
Notifications
You must be signed in to change notification settings - Fork 89
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
Double cart fix #401
Merged
Merged
Double cart fix #401
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,16 @@ | |
namespace Tests\Sylius\ShopApiPlugin\Controller\Cart; | ||
|
||
use League\Tactician\CommandBus; | ||
use Sylius\Component\Core\Repository\OrderRepositoryInterface; | ||
use Sylius\ShopApiPlugin\Command\PickupCart; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Tests\Sylius\ShopApiPlugin\Controller\JsonApiTestCase; | ||
use Tests\Sylius\ShopApiPlugin\Controller\Utils\ShopUserLoginTrait; | ||
|
||
final class CartPickupApiTest extends JsonApiTestCase | ||
{ | ||
use ShopUserLoginTrait; | ||
|
||
/** | ||
* @test | ||
*/ | ||
|
@@ -23,23 +27,52 @@ public function it_creates_a_new_cart(): void | |
$response = $this->client->getResponse(); | ||
|
||
$this->assertResponse($response, 'cart/empty_response', Response::HTTP_CREATED); | ||
|
||
$orderRepository = $this->get('sylius.repository.order'); | ||
$count = $orderRepository->count([]); | ||
|
||
$this->assertSame(1, $count, 'Only one cart should be created'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_only_creates_one_cart_if_user_is_logged_in(): void | ||
{ | ||
$this->loadFixturesFromFiles(['shop.yml', 'customer.yml']); | ||
|
||
$this->logInUser('oliver@queen.com', '123password'); | ||
|
||
$this->client->request('POST', '/shop-api/WEB_GB/carts', [], [], static::CONTENT_TYPE_HEADER); | ||
$response = $this->client->getResponse(); | ||
$this->assertResponseCode($response, Response::HTTP_CREATED); | ||
|
||
/** @var OrderRepositoryInterface $orderRepository */ | ||
$orderRepository = $this->get('sylius.repository.order'); | ||
$orders = $orderRepository->findAll(); | ||
|
||
$this->assertCount(1, $orders, 'Only one cart should be created'); | ||
} | ||
|
||
/** | ||
* @deprecated | ||
* @test | ||
*/ | ||
public function it_creates_a_new_cart_using_deprecated_api(): void | ||
{ | ||
$this->loadFixturesFromFiles(['shop.yml']); | ||
|
||
$this->client->request('POST', '/shop-api/WEB_GB/carts/SDAOSLEFNWU35H3QLI5325', [], [], self::CONTENT_TYPE_HEADER); | ||
$this->client->request( | ||
'POST', '/shop-api/WEB_GB/carts/SDAOSLEFNWU35H3QLI5325', [], [], self::CONTENT_TYPE_HEADER | ||
); | ||
|
||
$response = $this->client->getResponse(); | ||
|
||
$this->assertResponse($response, 'cart/deprecated_empty_response', Response::HTTP_CREATED); | ||
} | ||
|
||
/** | ||
* @deprecated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💖 |
||
* @test | ||
*/ | ||
public function it_does_not_allow_to_create_a_new_cart_if_token_is_already_used(): void | ||
|
@@ -66,7 +99,9 @@ public function it_does_not_allow_to_create_a_new_cart_in_non_existent_channel() | |
{ | ||
$this->loadFixturesFromFiles(['shop.yml']); | ||
|
||
$this->client->request('POST', '/shop-api/SPACE_KLINGON/carts/SDAOSLEFNWU35H3QLI5325', [], [], self::CONTENT_TYPE_HEADER); | ||
$this->client->request( | ||
'POST', '/shop-api/SPACE_KLINGON/carts/SDAOSLEFNWU35H3QLI5325', [], [], self::CONTENT_TYPE_HEADER | ||
); | ||
|
||
$response = $this->client->getResponse(); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 happens if a project use in the same project shop bundle and shop api? This create cart context is removed for both context, isnt'it?
This how I understand your comment Sylius/Sylius#10192 (comment)
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.
If you want to use the shop front-end and the API as well those will collide. Or so we think. I have not tested it.
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.
But we also have a ticket for removing the shop from the API package as a dependency (#264)
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.
@tophsic that's correct, right now ShopApi will collide with default shop implementation