-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[API][Order] Fixed wrong where condition when looking for order #11895
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 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
Next
Next commit
[API][Order] Fixed wrong where condition when looking for order
- Loading branch information
commit c0e5939388b0b5a8614852aa37c4f474f05118b7
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
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -14,6 +14,7 @@ | |||||||
namespace spec\Sylius\Bundle\ApiBundle\Doctrine\QueryItemExtension; | ||||||||
|
||||||||
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface; | ||||||||
use Doctrine\ORM\Query\Expr; | ||||||||
use Doctrine\ORM\QueryBuilder; | ||||||||
use PhpSpec\ObjectBehavior; | ||||||||
use Sylius\Bundle\ApiBundle\Context\UserContextInterface; | ||||||||
|
@@ -35,7 +36,8 @@ function let(UserContextInterface $userContext): void | |||||||
function it_applies_conditions_to_delete_order_with_state_cart_and_with_null_user_and_customer_if_present_user_and_customer_are_null( | ||||||||
UserContextInterface $userContext, | ||||||||
QueryBuilder $queryBuilder, | ||||||||
QueryNameGeneratorInterface $queryNameGenerator | ||||||||
QueryNameGeneratorInterface $queryNameGenerator, | ||||||||
Expr $expr | ||||||||
): void { | ||||||||
$queryBuilder->getRootAliases()->willReturn(['o']); | ||||||||
|
||||||||
|
@@ -54,13 +56,18 @@ function it_applies_conditions_to_delete_order_with_state_cart_and_with_null_use | |||||||
; | ||||||||
|
||||||||
$queryBuilder | ||||||||
->andWhere('user IS NULL') | ||||||||
->expr() | ||||||||
->shouldBeCalled() | ||||||||
->willReturn($queryBuilder) | ||||||||
->willReturn($expr); | ||||||||
|
||||||||
$expr | ||||||||
->orX('user IS NULL', sprintf('%s.customer IS NULL', 'o')) | ||||||||
->shouldBeCalled() | ||||||||
->willReturn(sprintf('user IS NULL OR %s.customer IS NULL', 'o')) | ||||||||
; | ||||||||
|
||||||||
$queryBuilder | ||||||||
->orWhere(sprintf('%s.customer IS NULL', 'o')) | ||||||||
->andWhere(sprintf('user IS NULL OR %s.customer IS NULL', 'o')) | ||||||||
->shouldBeCalled() | ||||||||
->willReturn($queryBuilder) | ||||||||
; | ||||||||
|
@@ -90,7 +97,8 @@ function it_applies_conditions_to_delete_order_with_state_cart_and_with_null_use | |||||||
function it_applies_conditions_to_patch_order_with_state_cart_and_with_null_user_and_customer_if_present_user_and_customer_are_null( | ||||||||
UserContextInterface $userContext, | ||||||||
QueryBuilder $queryBuilder, | ||||||||
QueryNameGeneratorInterface $queryNameGenerator | ||||||||
QueryNameGeneratorInterface $queryNameGenerator, | ||||||||
Expr $expr | ||||||||
): void { | ||||||||
$queryBuilder->getRootAliases()->willReturn(['o']); | ||||||||
|
||||||||
|
@@ -109,13 +117,18 @@ function it_applies_conditions_to_patch_order_with_state_cart_and_with_null_user | |||||||
; | ||||||||
|
||||||||
$queryBuilder | ||||||||
->andWhere('user IS NULL') | ||||||||
->expr() | ||||||||
->shouldBeCalled() | ||||||||
->willReturn($queryBuilder) | ||||||||
->willReturn($expr); | ||||||||
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.
Suggested change
|
||||||||
|
||||||||
$expr | ||||||||
->orX('user IS NULL', sprintf('%s.customer IS NULL', 'o')) | ||||||||
->shouldBeCalled() | ||||||||
->willReturn(sprintf('user IS NULL OR %s.customer IS NULL', 'o')) | ||||||||
; | ||||||||
|
||||||||
$queryBuilder | ||||||||
->orWhere(sprintf('%s.customer IS NULL', 'o')) | ||||||||
->andWhere(sprintf('user IS NULL OR %s.customer IS NULL', 'o')) | ||||||||
->shouldBeCalled() | ||||||||
->willReturn($queryBuilder) | ||||||||
; | ||||||||
|
@@ -145,7 +158,8 @@ function it_applies_conditions_to_patch_order_with_state_cart_and_with_null_user | |||||||
function it_applies_conditions_to_put_order_with_state_cart_and_with_null_user_and_customer_if_present_user_and_customer_are_null( | ||||||||
UserContextInterface $userContext, | ||||||||
QueryBuilder $queryBuilder, | ||||||||
QueryNameGeneratorInterface $queryNameGenerator | ||||||||
QueryNameGeneratorInterface $queryNameGenerator, | ||||||||
Expr $expr | ||||||||
): void { | ||||||||
$queryBuilder->getRootAliases()->willReturn(['o']); | ||||||||
|
||||||||
|
@@ -164,13 +178,18 @@ function it_applies_conditions_to_put_order_with_state_cart_and_with_null_user_a | |||||||
; | ||||||||
|
||||||||
$queryBuilder | ||||||||
->andWhere('user IS NULL') | ||||||||
->expr() | ||||||||
->shouldBeCalled() | ||||||||
->willReturn($queryBuilder) | ||||||||
->willReturn($expr); | ||||||||
|
||||||||
$expr | ||||||||
->orX('user IS NULL', sprintf('%s.customer IS NULL', 'o')) | ||||||||
->shouldBeCalled() | ||||||||
->willReturn(sprintf('user IS NULL OR %s.customer IS NULL', 'o')) | ||||||||
; | ||||||||
|
||||||||
$queryBuilder | ||||||||
->orWhere(sprintf('%s.customer IS NULL', 'o')) | ||||||||
->andWhere(sprintf('user IS NULL OR %s.customer IS NULL', 'o')) | ||||||||
->shouldBeCalled() | ||||||||
->willReturn($queryBuilder) | ||||||||
; | ||||||||
|
@@ -217,6 +236,7 @@ function it_applies_conditions_to_put_order_with_state_cart_and_with_null_user_a | |||||||
->shouldBeCalled() | ||||||||
->willReturn($queryBuilder) | ||||||||
; | ||||||||
|
||||||||
$queryBuilder | ||||||||
->setParameter('customer', 1) | ||||||||
->shouldBeCalled() | ||||||||
|
@@ -313,6 +333,7 @@ function it_applies_conditions_to_delete_order_with_state_cart_and_with_null_use | |||||||
->shouldBeCalled() | ||||||||
->willReturn($queryBuilder) | ||||||||
; | ||||||||
|
||||||||
$queryBuilder | ||||||||
->setParameter('customer', 1) | ||||||||
->shouldBeCalled() | ||||||||
|
@@ -361,6 +382,7 @@ function it_applies_conditions_to_delete_order_with_state_cart_by_authorized_sho | |||||||
->shouldBeCalled() | ||||||||
->willReturn($queryBuilder) | ||||||||
; | ||||||||
|
||||||||
$queryBuilder | ||||||||
->setParameter('customer', 1) | ||||||||
->shouldBeCalled() | ||||||||
|
@@ -409,6 +431,7 @@ function it_applies_conditions_to_patch_order_with_state_cart_by_authorized_shop | |||||||
->shouldBeCalled() | ||||||||
->willReturn($queryBuilder) | ||||||||
; | ||||||||
|
||||||||
$queryBuilder | ||||||||
->setParameter('customer', 1) | ||||||||
->shouldBeCalled() | ||||||||
|
@@ -457,6 +480,7 @@ function it_applies_conditions_to_put_order_with_state_cart_by_authorized_shop_u | |||||||
->shouldBeCalled() | ||||||||
->willReturn($queryBuilder) | ||||||||
; | ||||||||
|
||||||||
$queryBuilder | ||||||||
->setParameter('customer', 1) | ||||||||
->shouldBeCalled() | ||||||||
|
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.