|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © 2013-2017 Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | + |
| 7 | +namespace Magento\Signifyd\Test\Constraint; |
| 8 | + |
| 9 | +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; |
| 10 | +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; |
| 11 | +use Magento\Mtf\Constraint\AbstractConstraint; |
| 12 | + |
| 13 | +/** |
| 14 | + * Assert that comment about authorized amount exists in Comments History section on order page in Admin. |
| 15 | + */ |
| 16 | +class AssertSignifydCaseInCommentsHistory extends AbstractConstraint |
| 17 | +{ |
| 18 | + /** |
| 19 | + * Pattern of message about authorized amount in order. |
| 20 | + */ |
| 21 | + const CASE_CREATED_PATTERN = '/Signifyd Case (\d)+ has been created for order\./'; |
| 22 | + |
| 23 | + /** |
| 24 | + * Assert that comment about authorized amount exists in Comments History section on order page in Admin. |
| 25 | + * |
| 26 | + * @param SalesOrderView $salesOrderView |
| 27 | + * @param OrderIndex $salesOrder |
| 28 | + * @param string $orderId |
| 29 | + * @param array $prices |
| 30 | + * @return void |
| 31 | + */ |
| 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 | + |
| 41 | + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ |
| 42 | + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); |
| 43 | + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); |
| 44 | + |
| 45 | + \PHPUnit_Framework_Assert::assertRegExp( |
| 46 | + sprintf(self::CASE_CREATED_PATTERN, $prices['grandTotal']), |
| 47 | + $latestComment['comment'], |
| 48 | + 'Signifyd case is not created for the order #' . $orderId |
| 49 | + ); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Returns string representation of successful assertion. |
| 54 | + * |
| 55 | + * @return string |
| 56 | + */ |
| 57 | + public function toString() |
| 58 | + { |
| 59 | + return "Message about Signifyd Case is available in Comments History section."; |
| 60 | + } |
| 61 | +} |
0 commit comments