/**
  * Assert customer availability in Customer Grid.
  *
  * @param Customer $customer
  * @param CustomerIndex $pageCustomerIndex
  * @param Customer $initialCustomer [optional]
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function processAssert(Customer $customer, CustomerIndex $pageCustomerIndex, Customer $initialCustomer = null)
 {
     $data = $this->prepareData($customer, $initialCustomer);
     $filter = ['name' => $data[0], 'email' => $data[1]['email']];
     $pageCustomerIndex->open();
     \PHPUnit_Framework_Assert::assertTrue($pageCustomerIndex->getCustomerGridBlock()->isRowVisible($filter), 'Customer with ' . 'name \'' . $filter['name'] . '\', ' . 'email \'' . $filter['email'] . '\' ' . 'is absent in Customer grid.');
 }
 /**
  * Assert that customer balance history is changed.
  *
  * @param CustomerIndex $customerIndex
  * @param Customer $customer
  * @param CustomerBalance $customerBalance
  * @param CustomerEdit $customerEdit
  * @return void
  */
 public function processAssert(CustomerIndex $customerIndex, Customer $customer, CustomerBalance $customerBalance, CustomerEdit $customerEdit)
 {
     $customerIndex->open();
     $filter = ['email' => $customer->getEmail()];
     $customerIndex->getCustomerGridBlock()->searchAndOpen($filter);
     $customerForm = $customerEdit->getCustomerBalanceForm();
     $customerForm->openTab('store_credit');
     \PHPUnit_Framework_Assert::assertTrue($customerEdit->getBalanceHistoryGrid()->verifyCustomerBalanceGrid($customerBalance), '"Balance History" grid not contains correct information.');
 }
 /**
  * Assert that products added to wishlist are present on Customers account on backend.
  *
  * @param CustomerIndex $customerIndex
  * @param Customer $customer
  * @param CustomerEdit $customerEdit
  * @param InjectableFixture $product
  * @return void
  */
 public function processAssert(CustomerIndex $customerIndex, Customer $customer, CustomerEdit $customerEdit, InjectableFixture $product)
 {
     $customerIndex->open();
     $customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]);
     $customerEdit->getCustomerForm()->openTab('wishlist');
     /** @var Grid $wishlistGrid */
     $wishlistGrid = $customerEdit->getCustomerForm()->getTabElement('wishlist')->getSearchGridBlock();
     \PHPUnit_Framework_Assert::assertTrue($wishlistGrid->isRowVisible(['product_name' => $product->getName()], true, false), $product->getName() . " is not visible in customer wishlist on backend.");
 }
 /**
  * Assert that customer balance amount is changed.
  *
  * @param CustomerIndex $customerIndex
  * @param Customer $customer
  * @param CustomerBalance $customerBalance
  * @param CustomerEdit $customerEdit
  * @return void
  */
 public function processAssert(CustomerIndex $customerIndex, Customer $customer, CustomerBalance $customerBalance, CustomerEdit $customerEdit)
 {
     $customerIndex->open();
     $filter = ['email' => $customer->getEmail()];
     $customerIndex->getCustomerGridBlock()->searchAndOpen($filter);
     $customerForm = $customerEdit->getCustomerBalanceForm();
     $customerForm->openTab('store_credit');
     \PHPUnit_Framework_Assert::assertTrue($customerForm->getStoreCreditTab()->isStoreCreditBalanceVisible($customerBalance->getAmountDelta()), '"Store Credit Balance" grid not displays total amount of store credit balance.');
 }
 /**
  * Creation customer from backend.
  *
  * @param Customer $customer
  * @param Address $address
  * @return void
  */
 public function test(Customer $customer, Address $address)
 {
     // Prepare data
     $address = $address->hasData() ? $address : null;
     // Steps
     $this->pageCustomerIndex->open();
     $this->pageCustomerIndex->getPageActionsBlock()->addNew();
     $this->pageCustomerIndexNew->getCustomerForm()->fillCustomer($customer, $address);
     $this->pageCustomerIndexNew->getPageActionsBlock()->save();
 }
 /**
  * Assert that displayed customer data on edit page(backend) equals passed from fixture.
  *
  * @param Customer $customer
  * @param CustomerIndex $pageCustomerIndex
  * @param CustomerEdit $pageCustomerEdit
  * @param Address $address [optional]
  * @param Customer $initialCustomer [optional]
  * @return void
  */
 public function processAssert(Customer $customer, CustomerIndex $pageCustomerIndex, CustomerEdit $pageCustomerEdit, Address $address = null, Customer $initialCustomer = null)
 {
     $filter = [];
     $data = $this->prepareData($customer, $initialCustomer, $address);
     $filter['email'] = $data['customer']['email'];
     $pageCustomerIndex->open();
     $pageCustomerIndex->getCustomerGridBlock()->searchAndOpen($filter);
     $dataForm = $pageCustomerEdit->getCustomerForm()->getDataCustomer($customer, $address);
     $dataDiff = $this->verify($data, $dataForm);
     \PHPUnit_Framework_Assert::assertTrue(empty($dataDiff), 'Customer data on edit page(backend) not equals to passed from fixture.' . "\nFailed values: " . implode(', ', $dataDiff));
 }
 /**
  * Assert that success message is displayed after customer save.
  *
  * @param CustomerIndex $pageCustomerIndex
  * @return void
  */
 public function processAssert(CustomerIndex $pageCustomerIndex)
 {
     \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_MESSAGE, $pageCustomerIndex->getMessagesBlock()->getSuccessMessages());
 }