Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCancelInCommentsHistory.php
Go to the documentation of this file.
1 <?php
7 
8 use Magento\Mtf\Constraint\AbstractConstraint;
9 use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
10 use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
11 
16 class AssertCancelInCommentsHistory extends AbstractConstraint
17 {
21  private $canceledAmountPattern = '/^Canceled order online Amount: \w*\W{1,2}%s. Transaction ID: "[\w\-]*"/';
22 
30  public function processAssert(
31  SalesOrderView $salesOrderView,
32  OrderIndex $salesOrder,
33  $orderId,
34  array $prices
35  ) {
36  $salesOrder->open();
37  $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
38 
40  $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
41  $comments = $infoTab->getCommentsHistoryBlock()->getComments();
42  $commentsMessages = array_column($comments, 'comment');
43 
44  \PHPUnit\Framework\Assert::assertRegExp(
45  sprintf($this->canceledAmountPattern, $prices['grandTotal']),
46  implode('. ', $commentsMessages),
47  'Incorrect canceled amount value for the order #' . $orderId
48  );
49  }
50 
56  public function toString()
57  {
58  return "Message about canceled amount is available in Comments History section.";
59  }
60 }