Skip to content

Commit

Permalink
[Admin][Customer] Implement scenario for browsing orders of a customer
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed Nov 14, 2016
1 parent 8632235 commit 7b5f4b9
Showing 5 changed files with 68 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -9,10 +9,10 @@ Feature: Browsing orders of a customer
And the store has a product "PHP T-Shirt"
And the store ships everywhere for free
And the store allows paying with "Cash on Delivery"
And there is a customer "logan@wolverine.com" that placed an order "#00000007"
And a customer "logan@wolverine.com" placed an order "#00000007"
And the customer bought a single "PHP T-Shirt"
And the customer chose "Free" shipping method to "United States" with "Cash on Delivery" payment
And there is a customer "eric@magneto.com" that placed an order "#00000008"
And a customer "eric@magneto.com" placed an order "#00000008"
And the customer bought a single "PHP T-Shirt"
And the customer chose "Free" shipping method to "United States" with "Cash on Delivery" payment
And I am logged in as an administrator
@@ -21,5 +21,5 @@ Feature: Browsing orders of a customer
Scenario: Browsing orders of a specific customer in the list
When I browse orders of a customer "logan@wolverine.com"
Then I should see a single order in the list
And I should see the order number "#00000007" in the list
And I should not see the order number "#00000008" 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
53 changes: 51 additions & 2 deletions src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php
Original file line number Diff line number Diff line change
@@ -18,8 +18,7 @@
use Sylius\Behat\Page\Admin\Customer\UpdatePageInterface;
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\Customer;
use Sylius\Component\Customer\Model\CustomerInterface;
use Sylius\Component\Core\Model\CustomerInterface;
use Webmozart\Assert\Assert;

/**
@@ -52,6 +51,11 @@ final class ManagingCustomersContext implements Context
*/
private $showPage;

/**
* @var IndexPageInterface
*/
private $ordersIndexPage;

/**
* @var CurrentPageResolverInterface
*/
@@ -63,6 +67,7 @@ final class ManagingCustomersContext implements Context
* @param IndexPageInterface $indexPage
* @param UpdatePageInterface $updatePage
* @param ShowPageInterface $showPage
* @param IndexPageInterface $ordersIndexPage
* @param CurrentPageResolverInterface $currentPageResolver
*/
public function __construct(
@@ -71,13 +76,15 @@ public function __construct(
IndexPageInterface $indexPage,
UpdatePageInterface $updatePage,
ShowPageInterface $showPage,
IndexPageInterface $ordersIndexPage,
CurrentPageResolverInterface $currentPageResolver
) {
$this->sharedStorage = $sharedStorage;
$this->createPage = $createPage;
$this->indexPage = $indexPage;
$this->updatePage = $updatePage;
$this->showPage = $showPage;
$this->ordersIndexPage = $ordersIndexPage;
$this->currentPageResolver = $currentPageResolver;
}

@@ -426,6 +433,14 @@ public function iChooseCreateAccountOption()
$this->createPage->selectCreateAccount();
}

/**
* @When I browse orders of a customer :customer
*/
public function iBrowseOrdersOfACustomer(CustomerInterface $customer)
{
$this->ordersIndexPage->open(['id' => $customer->getId()]);
}

/**
* @Then the customer :customer should have an account created
* @Then /^(this customer) should have an account created$/
@@ -600,4 +615,38 @@ public function iShouldSeeThatThisCustomerHasVerifiedTheEmail()
'There should be information that this customer has verified the email.'
);
}

/**
* @Then I should see a single order in the list
*/
public function iShouldSeeASingleOrderInTheList()
{
Assert::same(
1,
$this->ordersIndexPage->countItems(),
'Cannot find order in the list.'
);
}

/**
* @Then I should see the order with number :orderNumber in the list
*/
public function iShouldSeeASingleOrderFromCustomer($orderNumber)
{
Assert::true(
$this->indexPage->isSingleResourceOnPage(['number' => $orderNumber]),
sprintf('Cannot find order with number "%s" in the list.', $orderNumber)
);
}

/**
* @Then I should not see the order with number :orderNumber in the list
*/
public function iShouldNotSeeASingleOrderFromCustomer($orderNumber)
{
Assert::false(
$this->indexPage->isSingleResourceOnPage(['number' => $orderNumber]),
sprintf('Cannot find order with number "%s" in the list.', $orderNumber)
);
}
}
1 change: 1 addition & 0 deletions src/Sylius/Behat/Resources/config/services/contexts/ui.xml
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@
<argument type="service" id="sylius.behat.page.admin.customer.index" />
<argument type="service" id="sylius.behat.page.admin.customer.update" />
<argument type="service" id="sylius.behat.page.admin.customer.show" />
<argument type="service" id="sylius.behat.page.admin.customer.order_index" />
<argument type="service" id="sylius.behat.current_page_resolver" />
<tag name="fob.context_service" />
</service>
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
<parameters>
<parameter key="sylius.behat.page.admin.customer.create.class">Sylius\Behat\Page\Admin\Customer\CreatePage</parameter>
<parameter key="sylius.behat.page.admin.customer.index.class">Sylius\Behat\Page\Admin\Customer\IndexPage</parameter>
<parameter key="sylius.behat.page.admin.customer.order_index.class">%sylius.behat.page.admin.crud.index.class%</parameter>
<parameter key="sylius.behat.page.admin.customer.update.class">Sylius\Behat\Page\Admin\Customer\UpdatePage</parameter>
<parameter key="sylius.behat.page.admin.customer.show.class">Sylius\Behat\Page\Admin\Customer\ShowPage</parameter>
</parameters>
@@ -26,6 +27,9 @@
<service id="sylius.behat.page.admin.customer.index" class="%sylius.behat.page.admin.customer.index.class%" parent="sylius.behat.page.admin.crud.index" public="false">
<argument type="string">customer</argument>
</service>
<service id="sylius.behat.page.admin.customer.order_index" class="%sylius.behat.page.admin.customer.order_index.class%" parent="sylius.behat.page.admin.crud.index" public="false">
<argument type="string">customer_order</argument>
</service>
<service id="sylius.behat.page.admin.customer.update" class="%sylius.behat.page.admin.customer.update.class%" parent="sylius.behat.page.admin.crud.update" public="false">
<argument type="string">customer</argument>
</service>
Original file line number Diff line number Diff line change
@@ -10,13 +10,20 @@ default:
- sylius.behat.context.transform.address
- sylius.behat.context.transform.customer
- sylius.behat.context.transform.customer_group
- sylius.behat.context.transform.payment
- sylius.behat.context.transform.product
- sylius.behat.context.transform.shared_storage
- sylius.behat.context.transform.shipping_method

- sylius.behat.context.setup.address
- sylius.behat.context.setup.admin_security
- sylius.behat.context.setup.channel
- sylius.behat.context.setup.customer
- sylius.behat.context.setup.customer_group
- sylius.behat.context.setup.admin_security
- sylius.behat.context.setup.order
- sylius.behat.context.setup.payment
- sylius.behat.context.setup.product
- sylius.behat.context.setup.shipping
- sylius.behat.context.setup.user

- sylius.behat.context.ui.admin.dashboard

0 comments on commit 7b5f4b9

Please sign in to comment.