9 use Magento\Customer\Test\Fixture\Address;
11 use Magento\Customer\Test\Page\Adminhtml\CustomerIndex;
12 use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit;
13 use Magento\Mtf\Constraint\AbstractConstraint;
29 private $customerSkippedFields = [
32 'password_confirmation',
44 private $localeMap = [
53 private $localeFormat =
'm/d/Y';
67 CustomerIndex $pageCustomerIndex,
68 CustomerIndexEdit $pageCustomerIndexEdit,
72 $this->localeFormat =
'' !== $locale && isset($this->localeMap[$locale])
73 ? $this->localeMap[$locale]
74 : $this->localeFormat;
82 $data[
'addresses'] = [];
84 if (isset(
$data[
'customer'][
'dob'])) {
85 $data[
'customer'][
'dob'] = date($this->localeFormat, strtotime(
$data[
'customer'][
'dob']));
87 $filter[
'email'] =
$data[
'customer'][
'email'];
89 $pageCustomerIndex->open();
90 $pageCustomerIndex->getCustomerGridBlock()->searchAndOpen($filter);
92 $dataForm = $pageCustomerIndexEdit->getCustomerForm()->getDataCustomer(
$customer,
$address);
93 $dataDiff = $this->verify(
$data, $dataForm);
94 \PHPUnit\Framework\Assert::assertTrue(
96 'Customer data on edit page(backend) not equals to passed from fixture.' 97 .
"\nFailed values: " . implode(
', ', $dataDiff)
99 $this->assertCustomerGroupName(
$customer, $dataForm);
109 private function verify(array $dataFixture, array $dataForm)
113 $customerDiff = array_diff_assoc($dataFixture[
'customer'], $dataForm[
'customer']);
115 if (in_array(
$name, $this->customerSkippedFields)) {
118 if (isset($dataForm[
'customer'][
$name])) {
119 $result[] =
"\ncustomer {$name}: \"{$dataForm['customer'][$name]}\" instead of \"{$value}\"";
121 $result[] =
"\ncustomer {$name}: Field is absent. Expected value \"{$value}\"";
124 foreach ($dataFixture[
'addresses'] as $key =>
$address) {
125 $addressDiff = array_diff(
$address, $dataForm[
'addresses'][$key]);
127 if (isset($dataForm[
'addresses'][$key][
$name])) {
128 $result[] =
"\naddress #{$key} {$name}: \"{$dataForm['addresses'][$key][$name]}" 129 .
"\" instead of \"{$value}\"";
131 $result[] =
"\naddress #{$key} {$name}: Field absent. Expected value \"{$value}\"";
146 private function assertCustomerGroupName(Customer
$customer, array $formData)
148 $customerGroupName =
$customer->getGroupId();
150 if ($customerGroupName) {
151 \PHPUnit\Framework\Assert::assertNotEmpty(
152 $formData[
'customer'][
'group_id'],
153 'Customer Group value is empty.' 156 if (!empty($formData[
'customer'][
'group_id'])) {
157 \PHPUnit\Framework\Assert::assertContains(
159 $formData[
'customer'][
'group_id'],
160 'Customer Group name is incorrect.' 173 return 'Displayed customer data on edit page(backend) equals to passed from fixture.';
if(!isset($_GET['name'])) $name