Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CheckPayflowLinkConfigStep.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Backend\Test\Page\Adminhtml\SystemConfigEditSectionPayment;
10 use Magento\Mtf\TestStep\TestStepInterface;
15 
19 class CheckPayflowLinkConfigStep implements TestStepInterface
20 {
26  private $systemConfigEditSectionPayment;
27 
31  private $assertFieldsAreDisabled;
32 
36  private $assertFieldsArePresent;
37 
41  private $assertFieldsAreActive;
42 
46  private $assertFieldsAreEnabled;
47 
53  private $countryCode;
54 
60  private $sections;
61 
65  private $payflowLinkConfigBlock;
66 
76  public function __construct(
77  SystemConfigEditSectionPayment $systemConfigEditSectionPayment,
78  AssertFieldsAreDisabled $assertFieldsAreDisabled,
79  AssertFieldsArePresent $assertFieldsArePresent,
80  AssertFieldsAreActive $assertFieldsAreActive,
81  AssertFieldsAreEnabled $assertFieldsAreEnabled,
82  $countryCode,
83  array $sections
84  ) {
85  $this->systemConfigEditSectionPayment = $systemConfigEditSectionPayment;
86  $this->assertFieldsAreDisabled = $assertFieldsAreDisabled;
87  $this->assertFieldsArePresent = $assertFieldsArePresent;
88  $this->assertFieldsAreActive = $assertFieldsAreActive;
89  $this->assertFieldsAreEnabled = $assertFieldsAreEnabled;
90  $this->countryCode = $countryCode;
91  $this->sections = $sections;
92  $this->payflowLinkConfigBlock = $this->systemConfigEditSectionPayment->getPayflowLinkConfigBlock();
93  }
94 
100  public function run()
101  {
102  $this->systemConfigEditSectionPayment->getPaymentsConfigBlock()->expandPaymentSections($this->sections);
103  $this->enablePayflowLink();
104  $this->disablePayflowLink();
105  }
106 
112  private function enablePayflowLink()
113  {
114  $this->payflowLinkConfigBlock->clickConfigureButton();
115  $this->payflowLinkConfigBlock->clearCredentials();
116  $enablers = $this->payflowLinkConfigBlock->getEnablerFields();
117  $this->assertFieldsAreDisabled->processAssert(
118  $this->systemConfigEditSectionPayment,
119  $enablers
120  );
121  $this->payflowLinkConfigBlock->specifyCredentials();
122  $this->assertFieldsAreActive->processAssert(
123  $this->systemConfigEditSectionPayment,
124  [$enablers['Enable Payflow Link']]
125  );
126  $this->assertFieldsAreDisabled->processAssert(
127  $this->systemConfigEditSectionPayment,
128  [$enablers['Enable Express Checkout'], $enablers['Enable PayPal Credit']]
129  );
130  $this->payflowLinkConfigBlock->enablePayflowLink();
131  $this->assertFieldsAreActive->processAssert(
132  $this->systemConfigEditSectionPayment,
133  $enablers
134  );
135  $this->assertFieldsAreEnabled->processAssert(
136  $this->systemConfigEditSectionPayment,
137  $enablers
138  );
139  $this->systemConfigEditSectionPayment->getPageActions()->save();
140  $this->systemConfigEditSectionPayment->getMessagesBlock()->waitSuccessMessage();
141  }
142 
148  private function disablePayflowLink()
149  {
150  $enablers = $this->payflowLinkConfigBlock->getEnablerFields();
151  $this->payflowLinkConfigBlock->clickConfigureButton();
152  $this->assertFieldsAreActive->processAssert($this->systemConfigEditSectionPayment, $enablers);
153  $this->assertFieldsAreEnabled->processAssert(
154  $this->systemConfigEditSectionPayment,
155  $enablers
156  );
157  $this->payflowLinkConfigBlock->disablePayflowLink();
158  $this->assertFieldsAreDisabled->processAssert(
159  $this->systemConfigEditSectionPayment,
160  [$enablers['Enable Express Checkout'], $enablers['Enable PayPal Credit']]
161  );
162  $this->systemConfigEditSectionPayment->getPageActions()->save();
163  $this->systemConfigEditSectionPayment->getMessagesBlock()->waitSuccessMessage();
164  }
165 }