/**
  * Assert that deleted customers address is not displayed on backend during order creation.
  *
  * @param SalesOrderIndex $orderIndex
  * @param SalesOrderCreateIndex $orderCreateIndex
  * @param Address $deletedAddress
  * @param Customer $customer
  * @return void
  */
 public function processAssert(SalesOrderIndex $orderIndex, SalesOrderCreateIndex $orderCreateIndex, Address $deletedAddress, Customer $customer)
 {
     $orderIndex->open()->getPageActionsBlock()->addNew();
     $orderCreateIndex->getCustomerGrid()->selectCustomer($customer);
     $orderCreateIndex->getStoreBlock()->selectStoreView();
     \PHPUnit_Framework_Assert::assertNotContains($this->prepareAddress($deletedAddress), $orderCreateIndex->getCreateBlock()->getBillingAddressForm()->getExistingAddresses(), 'Deleted address is present on backend during order creation');
 }
 /**
  * Assert that requested quantity is not available error message is displayed after adding products to order by sku.
  *
  * @param SalesOrderCreateIndex $salesOrderCreateIndex
  * @param array $requiredAttentionProducts
  * @return void
  */
 public function processAssert(SalesOrderCreateIndex $salesOrderCreateIndex, array $requiredAttentionProducts)
 {
     foreach ($requiredAttentionProducts as $product) {
         $productName = $product->getName();
         \PHPUnit_Framework_Assert::assertEquals(sprintf(self::ERROR_QUANTITY_MESSAGE, $productName), $salesOrderCreateIndex->getAdvancedOrderCreateBlock()->getItemsBlock()->getItemProduct($productName)->getNoticeMessage());
     }
 }
 /**
  * Fill Sales Data.
  *
  * @return array
  */
 public function run()
 {
     $this->salesOrderCreateIndex->getCreateBlock()->submitOrder();
     $this->salesOrderView->getMessagesBlock()->waitSuccessMessage();
     $orderId = $this->salesOrderView->getTitleBlock()->getOrderId();
     $order = $this->fixtureFactory->createByCode('order', ['data' => ['id' => $orderId, 'customer_id' => ['customer' => $this->customer], 'entity_id' => ['products' => $this->products], 'billing_address_id' => ['billingAddress' => $this->billingAddress]]]);
     return ['orderId' => $orderId, 'order' => $order];
 }
 /**
  * Apply sales rule during backend order creation.
  *
  * @return void
  */
 public function run()
 {
     if ($this->salesRule !== null) {
         if ($this->salesRule->hasData('coupon_code')) {
             $this->orderCreateIndex->getCreateBlock()->getCouponsBlock()->applyCouponsCode($this->salesRule);
         }
     }
 }
 /**
  * Apply gift card during order creation on backend.
  *
  * @return void
  */
 public function run()
 {
     $giftCardAccountBlock = $this->orderCreateIndex->getGiftCardAccountForm();
     foreach ($this->giftCardAccounts as $giftCardAccount) {
         if ($giftCardAccount !== null) {
             $giftCardAccountBlock->applyGiftCardAccount($giftCardAccount);
         }
     }
 }
 /**
  * Assert that products are visible in items order block.
  *
  * @param SalesOrderCreateIndex $orderCreatePage
  * @param array $products
  * @return void
  */
 public function processAssert(SalesOrderCreateIndex $orderCreatePage, array $products)
 {
     $productsVisibility = [];
     foreach ($products as $product) {
         $productName = $product->getName();
         if (!$orderCreatePage->getCreateBlock()->getItemsBlock()->getItemProduct($productName)->isVisible()) {
             $productsVisibility[] = "'{$productName}' is not visible in items order block.";
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($productsVisibility, $productsVisibility);
 }
 /**
  * Add products to order during creating backend order.
  *
  * @return void
  */
 public function run()
 {
     $createBlock = $this->salesOrderCreateIndex->getCreateBlock();
     $createBlock->getItemsBlock()->clickAddProducts();
     $productsGrid = $createBlock->getSearchBlock()->getSearchGrid();
     foreach ($this->products as $product) {
         $productsGrid->searchAndSelect(['sku' => $product->getSku()]);
     }
     $createBlock->getSearchBlock()->addSelectedProductsToOrder();
     $createBlock->getTemplateBlock()->waitLoader();
 }
 /**
  * Fill Sales Data.
  *
  * @return array
  */
 public function run()
 {
     $this->salesOrderCreateIndex->getCreateBlock()->submitOrder();
     $this->salesOrderView->getMessagesBlock()->waitSuccessMessage();
     $orderId = $this->salesOrderView->getTitleBlock()->getOrderId();
     $order = $this->createOrderFixture($orderId);
     return ['orderId' => $orderId, 'order' => $order];
 }
 /**
  * Add products by SKU on backend.
  *
  * @param Customer $customer
  * @param array $orderOptions
  * @param string $cartBlock
  * @param string|null $products
  * @return array
  */
 public function test(Customer $customer, array $orderOptions, $cartBlock, $products = null)
 {
     // Preconditions
     $products = $this->createProducts($products);
     $orderOptions = $this->prepareOrderOptions($products, $orderOptions);
     // Steps
     $this->orderIndex->open();
     $this->orderIndex->getPageActionsBlock()->addNew();
     $this->orderCreateIndex->getCustomerGrid()->selectCustomer($customer);
     $this->orderCreateIndex->getStoreBlock()->selectStoreView();
     $orderCreateBlock = $this->orderCreateIndex->getAdvancedOrderCreateBlock();
     $orderCreateBlock->getItemsBlock()->clickAddProductsBySku();
     $orderCreateBlock->getAddToOrderBySkuBlock()->getOrderBySkuForm()->fillForm($orderOptions);
     $this->orderCreateIndex->getAdvancedOrderCreateBlock()->getAddToOrderBySkuBlock()->addToCart();
     $filteredProducts = $this->filterProducts($products, $cartBlock);
     return ['products' => isset($filteredProducts['cart']) ? $filteredProducts['cart'] : [], 'requiredAttentionProducts' => isset($filteredProducts['required_attention']) ? $filteredProducts['required_attention'] : []];
 }
 /**
  * Move products from shopping cart sidebar on create order page.
  *
  * @return void
  */
 public function run()
 {
     $this->orderCreateIndex->getCustomerActivitiesBlock()->getShoppingCartItemsBlock()->addToOrder($this->products);
     $this->orderCreateIndex->getCustomerActivitiesBlock()->updateChanges();
 }
 /**
  * Fill Shipping Data.
  *
  * @return array
  */
 public function run()
 {
     if ($this->shipping['shipping_service'] != '-') {
         $this->salesOrderCreateIndex->getCreateBlock()->getShippingBlock()->selectShippingMethod($this->shipping);
     }
 }
 /**
  * Select Store on create order page.
  *
  * @return void
  */
 public function run()
 {
     $this->orderCreateIndex->getStoreBlock()->selectStoreView($this->store);
 }
 /**
  * Select Customer for Order.
  *
  * @return void
  */
 public function run()
 {
     $this->orderCreateIndex->getCustomerGrid()->selectCustomer($this->customer);
 }
 /**
  * Select store credit.
  *
  * @return void
  */
 public function run()
 {
     if (isset($this->payment['use_customer_balance'])) {
         $this->salesOrderCreateIndex->getStoreCreditBlock()->fillStoreCredit($this->payment['use_customer_balance']);
     }
 }
 /**
  * Assert that requested qty does not meet the increments error message is displayed after adding products by sku.
  *
  * @param SalesOrderCreateIndex $salesOrderCreateIndex
  * @param array $requiredAttentionProducts
  * @return void
  */
 public function processAssert(SalesOrderCreateIndex $salesOrderCreateIndex, array $requiredAttentionProducts)
 {
     foreach ($requiredAttentionProducts as $product) {
         \PHPUnit_Framework_Assert::assertEquals(sprintf(self::QTY_INCREMENTS_ERROR_MESSAGE, $product->getStockData()['qty_increments']), $salesOrderCreateIndex->getAdvancedOrderCreateBlock()->getItemsBlock()->getItemProduct($product->getName())->getErrorMessage());
     }
 }
 /**
  * Assert product was added to Items Ordered grid in customer account on Order creation page backend.
  *
  * @param SalesOrderCreateIndex $orderCreatePage
  * @param array $products
  * @param bool $productsIsConfigured
  * @return void
  */
 public function processAssert(SalesOrderCreateIndex $orderCreatePage, array $products, $productsIsConfigured = true)
 {
     $this->productsIsConfigured = $productsIsConfigured;
     $data = $this->prepareData($products, $orderCreatePage->getCreateBlock()->getItemsBlock());
     \PHPUnit_Framework_Assert::assertEquals($data['fixtureData'], $data['pageData'], 'Product data on order create page not equals to passed from fixture.');
 }
 /**
  * Fill Billing address.
  *
  * @return Address
  */
 public function run()
 {
     $this->salesOrderCreateIndex->getCreateBlock()->getBillingAddressForm()->fill($this->billingAddress);
     return ['billingAddress' => $this->billingAddress];
 }
 /**
  * Fill product data.
  *
  * @return void
  */
 public function run()
 {
     $this->salesOrderCreateIndex->getCreateBlock()->getItemsBlock()->updateProductsData($this->products);
 }
 /**
  * Assert that items ordered block is empty.
  *
  * @param SalesOrderCreateIndex $orderCreatePage
  * @return void
  */
 public function processAssert(SalesOrderCreateIndex $orderCreatePage)
 {
     \PHPUnit_Framework_Assert::assertTrue($orderCreatePage->getCreateBlock()->getItemsBlock()->isEmptyBlockVisible(), "Items ordered block is not empty");
 }
 /**
  * Assert that product requires attention error message is displayed after adding products by sku to order.
  *
  * @param SalesOrderCreateIndex $salesOrderCreateIndex
  * @param array $requiredAttentionProducts
  * @return void
  */
 public function processAssert(SalesOrderCreateIndex $salesOrderCreateIndex, array $requiredAttentionProducts)
 {
     \PHPUnit_Framework_Assert::assertEquals(sprintf(self::ERROR_MESSAGE, count($requiredAttentionProducts)), $salesOrderCreateIndex->getAdvancedOrderCreateBlock()->getRequireAttentionBlock()->getErrorMessage());
 }
 /**
  * Assert that entered qty is not valid notice message is displayed after adding products to order by sku.
  *
  * @param SalesOrderCreateIndex $salesOrderCreateIndex
  * @param array $requiredAttentionProducts
  * @return void
  */
 public function processAssert(SalesOrderCreateIndex $salesOrderCreateIndex, array $requiredAttentionProducts)
 {
     foreach ($requiredAttentionProducts as $product) {
         \PHPUnit_Framework_Assert::assertEquals(self::NOTICE_MESSAGE, $salesOrderCreateIndex->getAdvancedOrderCreateBlock()->getRequireAttentionBlock()->getFailedItemBlock($product)->getNoticeMessage());
     }
 }
 /**
  * Fill Payment data.
  *
  * @return void
  */
 public function run()
 {
     $this->salesOrderCreateIndex->getCreateBlock()->getPaymentBlock()->selectPaymentMethod($this->payment);
 }