Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertHttpsHeaderOptionsAvailable.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Constraint\AbstractConstraint;
10 use Magento\Backend\Test\Page\Adminhtml\SystemConfigEdit;
12 
16 class AssertHttpsHeaderOptionsAvailable extends AbstractConstraint
17 {
26  public function processAssert(
27  SystemConfigEdit $systemConfigEdit,
28  ConfigData $hsts,
29  ConfigData $upgradeInsecure
30  ) {
31  $this->verifyConfiguration($systemConfigEdit, $hsts);
32  $this->verifyConfiguration($systemConfigEdit, $upgradeInsecure);
33  }
34 
40  public function toString()
41  {
42  return 'HTTPS headers configuration verification successfully.';
43  }
44 
52  private function verifyConfiguration(SystemConfigEdit $systemConfigEdit, ConfigData $config)
53  {
54  $section = $config->getSection();
55  $keys = array_keys($section);
56  foreach ($keys as $key) {
57  $parts = explode('/', $key, 3);
58  $tabName = $parts[0];
59  $groupName = $parts[1];
60  $fieldName = $parts[2];
61  try {
62  $group = $systemConfigEdit->getForm()->getGroup($tabName, $groupName);
63  $group->setValue($tabName, $groupName, $fieldName, 'Yes');
64  $group->setValue($tabName, $groupName, $fieldName, 'No');
65  \PHPUnit\Framework\Assert::assertTrue(
66  true,
67  $fieldName . " configuration is enabled with options Yes & No."
68  );
69  } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
70  \PHPUnit\Framework\Assert::assertFalse(
71  true,
72  $fieldName . " configuration is not enabled with options Yes & No."
73  );
74  }
75  }
76  }
77 }
$config
Definition: fraud_order.php:17
processAssert(SystemConfigEdit $systemConfigEdit, ConfigData $hsts, ConfigData $upgradeInsecure)
$group
Definition: sections.phtml:16