Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertTransactionIsPresentInSettlementReport.php
Go to the documentation of this file.
1 <?php
7 
8 use Magento\Braintree\Test\Page\Adminhtml\BraintreeSettlementReportIndex;
9 use Magento\Mtf\Constraint\AbstractConstraint;
10 use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
11 use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
12 
16 class AssertTransactionIsPresentInSettlementReport extends AbstractConstraint
17 {
21  private $salesOrderView;
22 
26  private $settlementReportIndex;
27 
37  public function processAssert(
38  $orderId,
39  OrderIndex $orderIndex,
40  SalesOrderView $salesOrderView,
41  BraintreeSettlementReportIndex $braintreeSettlementReportIndex
42  ) {
43  $this->salesOrderView = $salesOrderView;
44  $this->settlementReportIndex = $braintreeSettlementReportIndex;
45 
46  $orderIndex->open();
47  $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
48 
49  $transactionId = $this->getTransactionId();
50  \PHPUnit\Framework\Assert::assertNotEmpty($transactionId);
51 
52  $this->settlementReportIndex->open();
53 
54  $grid = $this->settlementReportIndex->getSettlementReportGrid();
55  $grid->search(['id' => $transactionId]);
56 
57  $ids = $grid->getTransactionIds();
58 
59  \PHPUnit\Framework\Assert::assertTrue(in_array($transactionId, $ids));
60  }
61 
67  public function toString()
68  {
69  return 'Transaction is present in settlement report.';
70  }
71 
77  private function getTransactionId()
78  {
80  $infoTab = $this->salesOrderView->getOrderForm()->openTab('info')->getTab('info');
81  $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment();
82  $transactionId = null;
83 
84  preg_match('/(\w+-*\w+)"/', $latestComment['comment'], $matches);
85  if (!empty($matches[1])) {
86  $transactionId = $matches[1];
87  }
88 
89  return $transactionId;
90  }
91 }
processAssert( $orderId, OrderIndex $orderIndex, SalesOrderView $salesOrderView, BraintreeSettlementReportIndex $braintreeSettlementReportIndex)