Skip to content

Commit

Permalink
bug #10639 [Admin] Fix sorting on customer orders list (lchrusciel)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.6 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.6
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | Fixes #10637
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.4 or 1.5 branch (the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set
-->

Commits
-------

1da4f34 [Admin] Fix sorting on customer orders list
  • Loading branch information
Zales0123 committed Aug 28, 2019
2 parents 02d9674 + 1da4f34 commit e7ca3bd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
Expand Up @@ -23,3 +23,11 @@ Feature: Browsing orders of a customer
Then I should see a single order in the list
And I should see the order with number "#00000007" in the list
And I should not see the order with number "#00000008" in the list

@ui
Scenario: Browsing orders of a specific customer in the list
When I browse orders of a customer "logan@wolverine.com"
And I sort them by channel
Then I should see a single order in the list
And I should see the order with number "#00000007" in the list
And I should not see the order with number "#00000008" in the list
12 changes: 10 additions & 2 deletions src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php
Expand Up @@ -360,16 +360,24 @@ public function iChooseCreateAccountOption()
/**
* @When I browse orders of a customer :customer
*/
public function iBrowseOrdersOfACustomer(CustomerInterface $customer)
public function iBrowseOrdersOfACustomer(CustomerInterface $customer): void
{
$this->ordersIndexPage->open(['id' => $customer->getId()]);
}

/**
* @When I sort them by :sortBy
*/
public function iSortThemByChannel(string $sortBy): void
{
$this->ordersIndexPage->sort(ucfirst($sortBy));
}

/**
* @Then the customer :customer should have an account created
* @Then /^(this customer) should have an account created$/
*/
public function theyShouldHaveAnAccountCreated(CustomerInterface $customer)
public function theyShouldHaveAnAccountCreated(CustomerInterface $customer): void
{
Assert::notNull(
$customer->getUser()->getPassword(),
Expand Down
5 changes: 5 additions & 0 deletions src/Sylius/Behat/Page/Admin/Crud/IndexPage.php
Expand Up @@ -139,6 +139,11 @@ public function bulkDelete(): void
$this->getElement('confirmation_button')->click();
}

public function sort(string $order): void
{
$this->getDocument()->clickLink($order);
}

public function getRouteName(): string
{
return $this->routeName;
Expand Down
2 changes: 2 additions & 0 deletions src/Sylius/Behat/Page/Admin/Crud/IndexPageInterface.php
Expand Up @@ -37,4 +37,6 @@ public function countItems(): int;
public function filter(): void;

public function bulkDelete(): void;

public function sort(string $order): void;
}
Expand Up @@ -61,11 +61,9 @@ public function createListQueryBuilder(): QueryBuilder
*/
public function createByCustomerIdQueryBuilder($customerId): QueryBuilder
{
return $this->createQueryBuilder('o')
return $this->createListQueryBuilder()
->andWhere('o.customer = :customerId')
->andWhere('o.state != :state')
->setParameter('customerId', $customerId)
->setParameter('state', OrderInterface::STATE_CART)
;
}

Expand Down

0 comments on commit e7ca3bd

Please sign in to comment.