/** * 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.'); }
/** * Get data for replace in variations. * * @param CatalogProductSimple $product * @param CatalogProductSimple $promotedProduct * @param CustomerSegment|null $customerSegment * @return array */ protected function getReplaceData(CatalogProductSimple $product, CatalogProductSimple $promotedProduct, CustomerSegment $customerSegment = null) { $customerSegmentName = $customerSegment instanceof CustomerSegment ? $customerSegment->getName() : ''; return ['rule_information' => ['customer_segment_ids' => ['%customer_segment%' => $customerSegmentName]], 'products_to_match' => ['conditions_serialized' => ['%category_1%' => $this->getProductCategory($product)->getId()]], 'products_to_display' => ['actions_serialized' => ['%category_2%' => $this->getProductCategory($promotedProduct)->getId()]]]; }
/** * Get customer segment id from response. * * @param CustomerSegment $customerSegment * @return int|null */ protected function getCustomerSegmentId(CustomerSegment $customerSegment) { $filter = ['grid_segment_name' => $customerSegment->getName()]; $url = $_ENV['app_backend_url'] . 'customersegment/grid/filter/' . $this->encodeFilter($filter); $curl = new BackendDecorator(new CurlTransport(), $this->_configuration); $curl->write(CurlInterface::GET, $url, '1.0'); $response = $curl->read(); $curl->close(); preg_match('/edit\\/id\\/([0-9]+)/', $response, $match); return empty($match[1]) ? null : $match[1]; }