Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertAuthorizationInCommentsHistory.php
Go to the documentation of this file.
1 <?php
8 
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 AssertAuthorizationInCommentsHistory extends AbstractConstraint
17 {
21  const AUTHORIZED_AMOUNT_PATTERN = '/(IPN "Pending" )*Authorized amount of .+?%s. Transaction ID: "[\w\-]*"/';
22 
32  public function processAssert(
33  SalesOrderView $salesOrderView,
34  OrderIndex $salesOrder,
35  $orderId,
36  array $prices
37  ) {
38  $salesOrder->open();
39  $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
40 
42  $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
43  $orderComments = $infoTab->getCommentsHistoryBlock()->getComments();
44  $commentsMessages = array_column($orderComments, 'comment');
45 
46  \PHPUnit\Framework\Assert::assertRegExp(
47  sprintf(self::AUTHORIZED_AMOUNT_PATTERN, $prices['grandTotal']),
48  implode('. ', $commentsMessages),
49  'Incorrect authorized amount value for the order #' . $orderId
50  );
51  }
52 
58  public function toString()
59  {
60  return "Message about authorized amount is available in Comments History section.";
61  }
62 }