Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCustomerGroupForm.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Customer\Test\Page\Adminhtml\CustomerGroupIndex;
11 use Magento\Customer\Test\Page\Adminhtml\CustomerGroupNew;
12 use Magento\Mtf\Constraint\AbstractConstraint;
13 
17 class AssertCustomerGroupForm extends AbstractConstraint
18 {
19  /* tags */
20  const SEVERITY = 'low';
21  /* end tags */
22 
28  protected $skippedFields = [
29  'customer_group_id',
30  ];
31 
41  public function processAssert(
42  CustomerGroupIndex $customerGroupIndex,
43  CustomerGroupNew $customerGroupNew,
44  CustomerGroup $customerGroup,
45  CustomerGroup $customerGroupOriginal = null
46  ) {
47  $data = ($customerGroupOriginal !== null)
48  ? array_merge($customerGroupOriginal->getData(), $customerGroup->getData())
49  : $customerGroup->getData();
50  $filter = [
51  'code' => $data['customer_group_code'],
52  ];
53 
54  $customerGroupIndex->open();
55  $customerGroupIndex->getCustomerGroupGrid()->searchAndOpen($filter);
56  $formData = $customerGroupNew->getPageMainForm()->getData();
57  $dataDiff = $this->verifyForm($formData, $data);
58  \PHPUnit\Framework\Assert::assertTrue(
59  empty($dataDiff),
60  'Customer Group form was filled incorrectly.'
61  . "\nLog:\n" . implode(";\n", $dataDiff)
62  );
63  }
64 
72  protected function verifyForm(array $formData, array $fixtureData)
73  {
74  $errorMessages = [];
75 
76  foreach ($fixtureData as $key => $value) {
77  if (in_array($key, $this->skippedFields)) {
78  continue;
79  }
80  if ($value !== $formData[$key]) {
81  $errorMessages[] = "Data in " . $key . " field is not equal."
82  . "\nExpected: " . $value
83  . "\nActual: " . $formData[$key];
84  }
85  }
86 
87  return $errorMessages;
88  }
89 
95  public function toString()
96  {
97  return 'Customer Group form was filled correctly.';
98  }
99 }
processAssert(CustomerGroupIndex $customerGroupIndex, CustomerGroupNew $customerGroupNew, CustomerGroup $customerGroup, CustomerGroup $customerGroupOriginal=null)
$value
Definition: gender.phtml:16