/**
  * Runs Delete Customer Backend Entity test
  *
  * @param CustomerInjectable $customer
  * @return void
  */
 public function testDeleteCustomerBackendEntity(CustomerInjectable $customer)
 {
     // Preconditions:
     $customer->persist();
     // Steps:
     $filter = ['email' => $customer->getEmail()];
     $this->customerIndexPage->open();
     $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter);
     $this->customerIndexEditPage->getPageActionsBlock()->delete();
 }
 /**
  * Run update customer test.
  *
  * @param Customer $initialCustomer
  * @param Customer $customer
  * @param Address $address [optional]
  * @return void
  */
 public function testUpdateCustomerBackendEntity(Customer $initialCustomer, Customer $customer, Address $address = null)
 {
     // Precondition
     $initialCustomer->persist();
     // Steps
     $filter = ['email' => $initialCustomer->getEmail()];
     $this->customerIndexPage->open();
     $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter);
     $this->customerIndexEditPage->getCustomerForm()->updateCustomer($customer, $address);
     $this->customerIndexEditPage->getPageActionsBlock()->save();
 }
 /**
  * @param CustomerInjectable $initialCustomer
  * @param CustomerInjectable $customer
  * @param AddressInjectable $address
  */
 public function testUpdateCustomerBackendEntity(CustomerInjectable $initialCustomer, CustomerInjectable $customer, AddressInjectable $address)
 {
     // Prepare data
     $address = $address->hasData() ? $address : null;
     // Preconditions:
     $initialCustomer->persist();
     // Steps
     $filter = ['email' => $initialCustomer->getEmail()];
     $this->customerIndexPage->open();
     $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter);
     $this->customerIndexEditPage->getCustomerForm()->updateCustomer($customer, $address);
     $this->customerIndexEditPage->getPageActionsBlock()->save();
 }
 /**
  * Move last ordered products on order page.
  *
  * @param OrderInjectable $order
  * @return array
  */
 public function test(OrderInjectable $order)
 {
     // Preconditions:
     $order->persist();
     $customer = $order->getDataFieldConfig('customer_id')['source']->getCustomer();
     // Steps:
     $this->customerIndex->open();
     $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]);
     $this->customerIndexEdit->getPageActionsBlock()->createOrder();
     $this->orderCreateIndex->getStoreBlock()->selectStoreView();
     $products = $order->getEntityId()['products'];
     $activitiesBlock = $this->orderCreateIndex->getCustomerActivitiesBlock();
     $activitiesBlock->getLastOrderedItemsBlock()->addProductsToOrder($products);
     $activitiesBlock->updateChanges();
     return ['products' => $products];
 }
 /**
  * Run update customer test.
  *
  * @param Customer $initialCustomer
  * @param Customer $customer
  * @param Address|null $address
  * @param int|null $addressIndexToDelete
  * @throws \Exception
  * @return array
  */
 public function testUpdateCustomerBackendEntity(Customer $initialCustomer, Customer $customer, Address $address = null, $addressIndexToDelete = null)
 {
     // Precondition
     $initialCustomer->persist();
     $addressToDelete = null;
     if ($addressIndexToDelete !== null) {
         $addressToDelete = $initialCustomer->getDataFieldConfig('address')['source']->getAddresses()[$addressIndexToDelete];
     }
     // Steps
     $filter = ['email' => $initialCustomer->getEmail()];
     $this->customerIndexPage->open();
     $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter);
     $this->customerIndexEditPage->getCustomerForm()->updateCustomer($customer, $address, $addressToDelete);
     $this->customerIndexEditPage->getPageActionsBlock()->save();
     return ['customer' => $this->prepareCustomer($customer, $initialCustomer, $address, $addressToDelete), 'addressToDelete' => $addressToDelete];
 }
 /**
  * Create order from customer page (cartActions).
  *
  * @param Customer $customer
  * @param string $product
  * @return array
  */
 public function test(Customer $customer, $product)
 {
     //Preconditions
     // Create product
     $product = $this->objectManager->create('\\Magento\\Catalog\\Test\\TestStep\\CreateProductStep', ['product' => $product])->run()['product'];
     // Login under customer
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $this->catalogProductView->getViewBlock()->addToCart($product);
     //Steps
     $this->customerIndex->open();
     $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]);
     $this->customerIndexEdit->getPageActionsBlock()->createOrder();
     $this->orderCreateIndex->getStoreBlock()->selectStoreView();
     $this->orderCreateIndex->getCustomerActivitiesBlock()->getShoppingCartItemsBlock()->addProductsToOrder([$product]);
     $this->orderCreateIndex->getCustomerActivitiesBlock()->updateChanges();
     return ['products' => [$product]];
 }
 /**
  * Move compare products on order page.
  *
  * @param Customer $customer
  * @param string $products
  * @return array
  */
 public function test(Customer $customer, $products)
 {
     // Preconditions
     // Create products
     $products = $this->objectManager->create('\\Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => $products])->run()['products'];
     // Add products to compare
     foreach ($products as $itemProduct) {
         $this->browser->open($_ENV['app_frontend_url'] . $itemProduct->getUrlKey() . '.html');
         $this->catalogProductView->getViewBlock()->clickAddToCompare();
     }
     // Steps
     $this->customerIndex->open();
     $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]);
     $this->customerIndexEdit->getPageActionsBlock()->createOrder();
     $this->orderCreateIndex->getStoreBlock()->selectStoreView();
     $activitiesBlock = $this->orderCreateIndex->getCustomerActivitiesBlock();
     $activitiesBlock->getProductsInComparisonBlock()->addProductsToOrder($products);
     $activitiesBlock->updateChanges();
     return ['products' => $products, 'productsIsConfigured' => false];
 }
 /**
  * Move recently compared products on order page.
  *
  * @param Customer $customer
  * @param string $products
  * @return array
  */
 public function test(Customer $customer, $products)
 {
     // Preconditions
     // Create product
     $products = $this->objectManager->create('\\Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => $products])->run()['products'];
     // Login under customer
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     foreach ($products as $itemProduct) {
         $this->browser->open($_ENV['app_frontend_url'] . $itemProduct->getUrlKey() . '.html');
         $this->catalogProductView->getViewBlock()->clickAddToCompare();
     }
     $this->cmsIndex->getLinksBlock()->openLink("Compare Products");
     $this->catalogProductCompare->getCompareProductsBlock()->removeAllProducts();
     // Steps:
     $this->customerIndex->open();
     $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]);
     $this->customerIndexEdit->getPageActionsBlock()->createOrder();
     $this->orderCreateIndex->getStoreBlock()->selectStoreView();
     $activitiesBlock = $this->orderCreateIndex->getCustomerActivitiesBlock();
     $activitiesBlock->getRecentlyComparedProductsBlock()->addProductsToOrder($products);
     $activitiesBlock->updateChanges();
     return ['products' => $products, 'productsIsConfigured' => false];
 }
 /**
  * Create new order from customer step
  *
  * @return void
  */
 public function run()
 {
     $this->customerIndexEdit->getPageActionsBlock()->createOrder();
 }
 /**
  * Asserts that "Back" button works on customer edit page (returns to customers grid).
  *
  * @param CustomerIndexEdit $customerEditPage
  * @param CustomerIndex $customerGridPage
  * @return void
  */
 public function processAssert(CustomerIndexEdit $customerEditPage, CustomerIndex $customerGridPage)
 {
     $customerEditPage->getPageActionsBlock()->back();
     \PHPUnit_Framework_Assert::assertTrue($customerGridPage->getCustomerGridBlock()->isVisible(), 'Clicking on "Back" button does not redirect to customers grid.');
 }