/** * Verify that customer address is equals data on form * * @param Address $address * @param AddressEditForm $form * @return bool */ protected function verifyCustomerAddress(Address $address, AddressEditForm $form) { $dataAddress = $address->getData(); $preparedDataAddress = []; foreach ($dataAddress['fields'] as $key => $field) { $preparedDataAddress[$key] = $field['value']; } $dataDiff = array_diff($preparedDataAddress, $form->getData($address)); $this->assertTrue(empty($dataDiff), 'Customer addresses data on edit page(backend) not equals to passed from fixture.'); }
/** * Purge fields from pattern which are not present in fixture. * * @return string */ protected function preparePattern() { $outputPattern = $this->getPattern(); preg_match_all('@\\{\\{depend\\}\\}(.*?)\\{\\{.depend\\}\\}@siu', $outputPattern, $matches); foreach ($matches[1] as $key => $dependPart) { preg_match_all('@\\{\\{(\\w+)\\}\\}@', $dependPart, $depends); foreach ($depends[1] as $depend) { if ($this->address->getData(trim($depend)) === null) { $outputPattern = str_replace($matches[0][$key], "", $outputPattern); } } } return $outputPattern; }
/** * Assert that displayed customer data on edit page(backend) equals passed from fixture. * * @param Customer $customer * @param CustomerIndex $pageCustomerIndex * @param CustomerIndexEdit $pageCustomerIndexEdit * @param Address $address[optional] * @return void */ public function processAssert(Customer $customer, CustomerIndex $pageCustomerIndex, CustomerIndexEdit $pageCustomerIndexEdit, Address $address = null) { $data = []; $filter = []; $data['customer'] = $customer->getData(); if ($address) { $data['addresses'][1] = $address->hasData() ? $address->getData() : []; } else { $data['addresses'] = []; } $filter['email'] = $data['customer']['email']; $pageCustomerIndex->open(); $pageCustomerIndex->getCustomerGridBlock()->searchAndOpen($filter); $dataForm = $pageCustomerIndexEdit->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)); }
/** * Fill shipping and tax form. * * @param Address $address * @return void */ public function fillEstimateShippingAndTax(Address $address) { $this->openEstimateShippingAndTax(); $data = $address->getData(); $mapping = $this->dataMapping(array_intersect_key($data, array_flip($this->estimationFields))); // sort array according to $this->estimationFields elements order uksort($mapping, function ($a, $b) { $a = array_search($a, $this->estimationFields); $b = array_search($b, $this->estimationFields); switch (true) { case false !== $a && false !== $b: return $a - $b; case false !== $a: return -1; case false !== $b: return 1; default: return 0; } }); // Test environment may become unstable when form fields are filled in a default manner. // Imitating behavior closer to the real user. foreach ($mapping as $field) { $this->_fill([$field], $this->_rootElement); $this->waitForUpdatedShippingMethods(); } }
/** * Fill shipping and tax form. * * @param Address $address * @return void */ public function fillEstimateShippingAndTax(Address $address) { $this->openEstimateShippingAndTax(); $data = $address->getData(); $mapping = $this->dataMapping(array_intersect_key($data, array_flip($this->estimationFields))); $this->_fill($mapping, $this->_rootElement); $this->clickGetQuote(); }
/** * Fill shipping and tax form. * * @param Address $address * @return void */ public function fillEstimateShippingAndTax(Address $address) { $this->openEstimateShippingAndTax(); $data = $address->getData(); $mapping = $this->dataMapping(array_intersect_key($data, array_flip($this->estimationFields))); // Test environment may become unstable when form fields are filled in a default manner. // Imitating behavior closer to the real user. foreach ($mapping as $field) { $this->_fill([$field], $this->_rootElement); $this->waitForUpdatedShippingMethods(); } }