Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AcceptTransactionOnAuthorizenetStep.php
Go to the documentation of this file.
1 <?php
7 
8 use Magento\Authorizenet\Test\Fixture\AuthorizenetSandboxCustomer;
9 use Magento\Authorizenet\Test\Fixture\TransactionSearch;
10 use Magento\Authorizenet\Test\Page\Sandbox\Main;
11 use Magento\Mtf\Client\BrowserInterface;
12 use Magento\Mtf\TestStep\TestStepInterface;
15 use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
16 use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
17 
21 class AcceptTransactionOnAuthorizenetStep implements TestStepInterface
22 {
28  private $sandboxCustomer;
29 
35  private $main;
36 
42  private $salesOrderView;
43 
49  private $salesOrder;
50 
56  private $orderId;
57 
63  private $assertInvoiceStatusInOrdersGrid;
64 
70  private $orderBeforeAccept;
71 
77  private $assertOrderButtonsAvailable;
78 
84  private $browser;
85 
91  private $frame = 'frameset > frame';
92 
98  private $transactionSearch;
99 
114  public function __construct(
115  AuthorizenetSandboxCustomer $sandboxCustomer,
116  TransactionSearch $transactionSearch,
117  Main $main,
118  SalesOrderView $salesOrderView,
119  OrderIndex $salesOrder,
120  AssertInvoiceStatusInOrdersGrid $assertInvoiceStatusInOrdersGrid,
121  AssertOrderButtonsAvailable $assertOrderButtonsAvailable,
122  BrowserInterface $browser,
123  array $orderBeforeAccept,
124  $orderId
125  ) {
126  $this->sandboxCustomer = $sandboxCustomer;
127  $this->transactionSearch = $transactionSearch;
128  $this->main = $main;
129  $this->salesOrderView = $salesOrderView;
130  $this->salesOrder = $salesOrder;
131  $this->assertInvoiceStatusInOrdersGrid = $assertInvoiceStatusInOrdersGrid;
132  $this->assertOrderButtonsAvailable = $assertOrderButtonsAvailable;
133  $this->browser = $browser;
134  $this->orderBeforeAccept = $orderBeforeAccept;
135  $this->orderId = $orderId;
136  }
137 
144  public function run()
145  {
146  $this->assertInvoiceStatusInOrdersGrid->processAssert(
147  $this->salesOrderView,
148  $this->orderBeforeAccept['invoiceStatus'],
149  $this->orderId
150  );
151  $this->assertOrderButtonsAvailable->processAssert(
152  $this->salesOrderView,
153  $this->orderBeforeAccept['buttonsAvailable']
154  );
155  $this->salesOrder->open();
156  $this->salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $this->orderId]);
157 
159  $infoTab = $this->salesOrderView->getOrderForm()->openTab('info')->getTab('info');
160  $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment();
161  if (!preg_match('/"(\d+)"/', $latestComment['comment'], $matches)) {
162  throw new \Exception('Comment with transaction id cannot be found.');
163  }
164  $transactionId = $matches[1];
165  $this->main->open();
166  $this->browser->switchToFrame($this->browser->find($this->frame)->getLocator());
167  $this->main->getLoginForm()->fill($this->sandboxCustomer)->login();
168  $this->main->getModalBlock()->acceptNotification();
169  $this->main->getMenuBlock()->openSearchMenu();
170  $this->main->getSearchForm()->fill($this->transactionSearch)->search();
171  $this->main->getTransactionsGridBlock()->openTransaction($transactionId)->approveTransaction();
172  }
173 }
__construct(AuthorizenetSandboxCustomer $sandboxCustomer, TransactionSearch $transactionSearch, Main $main, SalesOrderView $salesOrderView, OrderIndex $salesOrder, AssertInvoiceStatusInOrdersGrid $assertInvoiceStatusInOrdersGrid, AssertOrderButtonsAvailable $assertOrderButtonsAvailable, BrowserInterface $browser, array $orderBeforeAccept, $orderId)