How Do I Verify That A Customer Can See That An Order Has Shipped?

This is a complicated activity to do since it requires

  1. Add to cart
  2. Checkout
  3. Admin Login
  4. Admin navigation to the order
  5. Shipping the order
  6. Logging in as the customer
  7. Navigating to the order
  8. Extracting the order information.
  9. Asserting the order has been shipped

It’s complicated, but it is also probably not too much of a stretch to say that is a legitimate user story.

Let’s see how it looks in code:

<?php


use Magium\Magento\AbstractMagentoTestCase;
use Magium\Magento\Actions\Admin\Login\Login;
use Magium\Magento\Actions\Cart\AddItemToCart;
use Magium\Magento\Actions\Checkout\CustomerCheckout;
use Magium\Magento\Extractors\Checkout\OrderId;
use Magium\Magento\Extractors\Customer\Order\ItemList;
use Magium\Magento\Navigators\Admin\Order;
use Magium\Magento\Navigators\Customer\AccountHome;
use Magium\Magento\Navigators\Customer\NavigateToOrder;

class ShipAnOrderTest extends AbstractMagentoTestCase
{

    public function testShippingAndOrder()
    {
        $this->commandOpen($this->getTheme()->getBaseUrl());
        $this->getAction(AddItemToCart::ACTION)->addSimpleProductToCartFromCategoryPage();
        $this->setPaymentMethod('CashOnDelivery');
        $this->getAction(CustomerCheckout::ACTION)->execute();

        $this->getAction(Login::ACTION)->login();
        $this->getNavigator(Order::NAVIGATOR)->navigateTo($this->getExtractor(OrderId::EXTRACTOR)->getOrderId());

        $this->byText('{{Ship}}')->click();
        $this->byText('{{Submit Shipment}}')->click();

        $this->commandOpen($this->getTheme()->getBaseUrl());
        $this->getNavigator(AccountHome::NAVIGATOR)->navigateTo();
        $this->getNavigator(NavigateToOrder::NAVIGATOR)->navigateTo($this->getExtractor(OrderId::EXTRACTOR)->getOrderId());

        $extractor = $this->getExtractor(ItemList::EXTRACTOR);
        /* @var $extractor \Magium\Magento\Extractors\Customer\Order\ItemList */
        $extractor->extract();
        $products = $extractor->getItems();
        self::assertEquals(1, $products[0]->getQtyShipped());
    }

}

(source)
Given the complexity of the story, that’s not that bad.