/**
  * Assert that displayed segment data on edit page is equals passed from fixture.
  *
  * @param CustomerSegment $customerSegment
  * @param CustomerSegmentIndex $customerSegmentIndex
  * @param CustomerSegmentNew $customerSegmentNew
  * @return void
  */
 public function processAssert(CustomerSegment $customerSegment, CustomerSegmentIndex $customerSegmentIndex, CustomerSegmentNew $customerSegmentNew)
 {
     $customerSegmentIndex->open();
     $customerSegmentIndex->getGrid()->searchAndOpen(['grid_segment_name' => $customerSegment->getName()]);
     $formData = $customerSegmentNew->getCustomerSegmentForm()->getData();
     $dataDiff = $this->verifyData($customerSegment->getData(), $formData, false, false);
     \PHPUnit_Framework_Assert::assertEmpty($dataDiff, "Customer Segments data not equals to passed from fixture.\n Log:\n" . implode(";\n", $dataDiff));
 }
 /**
  * Assert that grid on 'Matched Customer' tab contains customer according to conditions.
  *
  * @param Customer $customer
  * @param CustomerSegment $customerSegment
  * @param CustomerSegmentIndex $customerSegmentIndex
  * @param CustomerSegmentNew $customerSegmentNew
  * @return void
  */
 public function processAssert(Customer $customer, CustomerSegment $customerSegment, CustomerSegmentIndex $customerSegmentIndex, CustomerSegmentNew $customerSegmentNew)
 {
     $customerSegmentIndex->open();
     /** @var CustomerSegmentForm $formTabs */
     $formTabs = $customerSegmentNew->getCustomerSegmentForm();
     $customerSegmentIndex->getGrid()->searchAndOpen(['grid_segment_name' => $customerSegment->getName()]);
     $customerSegmentGrid = $formTabs->getMatchedCustomers()->getCustomersGrid();
     $formTabs->openTab('matched_customers');
     \PHPUnit_Framework_Assert::assertTrue($customerSegmentGrid->isRowVisible(['grid_email' => $customer->getEmail()]), 'Customer is absent in grid.');
     $customerSegmentGrid->resetFilter();
     $totalOnTab = $formTabs->getNumberOfCustomersOnTabs();
     $totalInGrid = $customerSegmentGrid->getTotalRecords();
     \PHPUnit_Framework_Assert::assertEquals($totalInGrid, $totalOnTab, 'Wrong count of records is displayed.');
 }
 /**
  * Run create customer segment test.
  *
  * @param Customer $customer
  * @param CustomerSegment $customerSegment
  * @param CustomerSegment $customerSegmentConditions
  * @param array $salesRule
  * @param Browser $browser
  * @return void
  */
 public function test(Customer $customer, CustomerSegment $customerSegment, CustomerSegment $customerSegmentConditions, array $salesRule, Browser $browser)
 {
     // Preconditions
     $customer->persist();
     $replacement = $this->prepareReplacement($customer);
     // Steps
     $this->customerSegmentIndex->open();
     $this->customerSegmentIndex->getPageActionsBlock()->addNew();
     $this->customerSegmentNew->getCustomerSegmentForm()->fill($customerSegment);
     $this->customerSegmentNew->getPageMainActions()->saveAndContinue();
     // Retrieve customer segment id
     preg_match('@id/(\\d+)/@', $browser->getUrl(), $matches);
     $customerSegmentId = $matches[1];
     $this->customerSegmentEdit->getCustomerSegmentForm()->openTab('conditions');
     $this->customerSegmentEdit->getCustomerSegmentForm()->fillForm($customerSegmentConditions, null, $replacement);
     $this->customerSegmentEdit->getPageMainActions()->save();
     $this->createCartPriceRule($salesRule, $customerSegmentId);
 }