Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CheckBraintreeConfigStep.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 CheckBraintreeConfigStep 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 $braintreeConfigBlock;
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->braintreeConfigBlock = $this->systemConfigEditSectionPayment->getBraintreeConfigBlock();
93  }
94 
100  public function run()
101  {
102  $this->systemConfigEditSectionPayment->getPaymentsConfigBlock()->expandPaymentSections($this->sections);
103  $this->enableBraintree();
104  $this->disableBraintree();
105  }
106 
112  private function enableBraintree()
113  {
114  $this->braintreeConfigBlock->clickConfigureButton();
115  $this->braintreeConfigBlock->clearCredentials();
116  $enablers = $this->braintreeConfigBlock->getEnablerFields();
117  $this->assertFieldsAreDisabled->processAssert($this->systemConfigEditSectionPayment, $enablers);
118  $this->braintreeConfigBlock->specifyCredentials();
119  $this->assertFieldsAreActive->processAssert($this->systemConfigEditSectionPayment, $enablers);
120  $this->braintreeConfigBlock->enableBraintree();
121  $this->assertFieldsAreActive->processAssert($this->systemConfigEditSectionPayment, $enablers);
122  $this->systemConfigEditSectionPayment->getPageActions()->save();
123  $this->systemConfigEditSectionPayment->getMessagesBlock()->waitSuccessMessage();
124  }
125 
131  private function disableBraintree()
132  {
133  $enablers = $this->braintreeConfigBlock->getEnablerFields();
134  $this->braintreeConfigBlock->clickConfigureButton();
135  $this->assertFieldsAreActive->processAssert($this->systemConfigEditSectionPayment, $enablers);
136  $this->assertFieldsAreEnabled->processAssert(
137  $this->systemConfigEditSectionPayment,
138  [$enablers['Enable this Solution']]
139  );
140  $this->braintreeConfigBlock->disableBraintree();
141  $this->assertFieldsAreActive->processAssert($this->systemConfigEditSectionPayment, $enablers);
142  $this->systemConfigEditSectionPayment->getPageActions()->save();
143  $this->systemConfigEditSectionPayment->getMessagesBlock()->waitSuccessMessage();
144  }
145 }
__construct(SystemConfigEditSectionPayment $systemConfigEditSectionPayment, AssertFieldsAreDisabled $assertFieldsAreDisabled, AssertFieldsArePresent $assertFieldsArePresent, AssertFieldsAreActive $assertFieldsAreActive, AssertFieldsAreEnabled $assertFieldsAreEnabled, $countryCode, array $sections)