diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/AssertTransactionIsPresentInSettlementReport.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/AssertTransactionIsPresentInSettlementReport.php index 96f84e4d3ef0f3b5f1b4819c833c22ce44fc6486..434e41bb50023a6680ccdef448515edbe8007911 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/AssertTransactionIsPresentInSettlementReport.php +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/AssertTransactionIsPresentInSettlementReport.php @@ -11,7 +11,7 @@ use Magento\Sales\Test\Page\Adminhtml\OrderIndex; use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; /** - * Class AssertTransactionIsPresentInSettlementReport + * Assert that comment with transaction id exists in Comments History section on order page in Admin. */ class AssertTransactionIsPresentInSettlementReport extends AbstractConstraint { @@ -26,6 +26,8 @@ class AssertTransactionIsPresentInSettlementReport extends AbstractConstraint private $settlementReportIndex; /** + * Assert that comment with transaction id exists in Comments History section on order page in Admin. + * * @param $orderId * @param OrderIndex $orderIndex * @param SalesOrderView $salesOrderView @@ -58,7 +60,9 @@ class AssertTransactionIsPresentInSettlementReport extends AbstractConstraint } /** - * @inheritdoc + * Returns a string representation of the object. + * + * @return string */ public function toString() { @@ -66,15 +70,18 @@ class AssertTransactionIsPresentInSettlementReport extends AbstractConstraint } /** - * Get transaction id from order comments - * @return mixed + * Get transaction id from order comments. + * + * @return null|string */ private function getTransactionId() { - $comments = $this->salesOrderView->getOrderHistoryBlock()->getCommentsHistory(); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $this->salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); $transactionId = null; - preg_match('/(\w+-*\w+)"/', $comments, $matches); + preg_match('/(\w+-*\w+)"/', $latestComment['comment'], $matches); if (!empty($matches[1])) { $transactionId = $matches[1]; } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/History.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/History.php deleted file mode 100644 index 8ae8bbb31584ef6ab7859b1c08ac62eb09f52016..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/History.php +++ /dev/null @@ -1,175 +0,0 @@ -<?php -/** - * Copyright © 2016 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Sales\Test\Block\Adminhtml\Order; - -use Magento\Mtf\Block\Block; -use Magento\Mtf\Client\Locator; - -/** - * Order comments block. - */ -class History extends Block -{ - /** - * Comment history Id. - * - * @var string - */ - protected $commentHistory = '.note-list-comment'; - - /** - * Comment history status. - * - * @var string - */ - protected $commentHistoryStatus = '.note-list-status'; - - /** - * Comment history notified status. - * - * @var string - */ - protected $commentHistoryNotifiedStatus = '.note-list-customer'; - - /** - * Authorized Amount. - * - * @var string - */ - protected $authorizedAmount = '//div[@class="note-list-comment"][contains(text(), "Authorized amount of")]'; - - /** - * Captured Amount from IPN. - * - * @var string - */ - protected $capturedAmount = '//div[@class="note-list-comment"][contains(text(), "Captured amount of")]'; - - /** - * Refunded Amount. - * - * @var string - */ - protected $refundedAmount = '//div[@class="note-list-comment"][contains(text(), "We refunded")]'; - - /** - * Voided Amount. - * - * @var string - */ - protected $voidedAmount = '//div[@class="note-list-comment"][contains(text(), "Voided authorization")]'; - - /** - * Note list locator. - * - * @var string - */ - protected $noteList = '.note-list'; - - /** - * Get comments history. - * - * @return string - */ - public function getCommentsHistory() - { - $this->waitCommentsHistory(); - return $this->_rootElement->find($this->commentHistory, Locator::SELECTOR_CSS)->getText(); - } - - /** - * Get the authorized amount from the comments history. - * - * @return string - */ - public function getAuthorizedAmount() - { - $this->waitCommentsHistory(); - return $this->_rootElement->find($this->authorizedAmount, Locator::SELECTOR_XPATH)->getText(); - } - - /** - * Get the captured amount from the comments history. - * - * @return array - */ - public function getCapturedAmount() - { - $result = []; - $this->waitCommentsHistory(); - $captureComments = $this->_rootElement->getElements($this->capturedAmount, Locator::SELECTOR_XPATH); - foreach ($captureComments as $captureComment) { - $result[] = $captureComment->getText(); - } - return $result; - } - - /** - * Get the refunded amount from the comments history. - * - * @return array - */ - public function getRefundedAmount() - { - $result = []; - $this->waitCommentsHistory(); - $refundedComments = $this->_rootElement->getElements($this->refundedAmount, Locator::SELECTOR_XPATH); - foreach ($refundedComments as $refundedComment) { - $result[] = $refundedComment->getText(); - } - return $result; - } - - /** - * Get the voided amount from the comments history. - * - * @return string - */ - public function getVoidedAmount() - { - $this->waitCommentsHistory(); - return $this->_rootElement->find($this->voidedAmount, Locator::SELECTOR_XPATH)->getText(); - } - - /** - * Gets the status which presented in comment - * - * @return string - */ - public function getStatus() - { - $this->waitCommentsHistory(); - return $this->_rootElement->find($this->commentHistoryStatus, Locator::SELECTOR_CSS)->getText(); - } - - /** - * Gets the is customer notified status which presented in comment - * - * @return string - */ - public function getNotifiedStatus() - { - $this->waitCommentsHistory(); - return $this->_rootElement->find($this->commentHistoryNotifiedStatus, Locator::SELECTOR_CSS)->getText(); - } - - /** - * Wait for comments history is visible. - * - * @return void - */ - protected function waitCommentsHistory() - { - $element = $this->_rootElement; - $selector = $this->noteList; - $element->waitUntil( - function () use ($element, $selector) { - return $element->find($selector)->isVisible() ? true : null; - } - ); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php index 146e3facccb6196f154af1487053f8e8b17e1991..414d6fdbc1b06509d19c3f957cbd9e729698a05d 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php @@ -7,6 +7,7 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\View\Tab; use Magento\Backend\Test\Block\Widget\Tab; +use Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info\CommentsHistoryBlock; use Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info\PaymentInfoBlock; /** @@ -28,6 +29,13 @@ class Info extends Tab */ private $paymentInfoBlockSelector = '.order-payment-method'; + /** + * Selector for Comments history block. + * + * @var string + */ + private $commentsHistoryBlockSelector = '#order_history_block'; + /** * Get order status from info block. * @@ -50,4 +58,17 @@ class Info extends Tab ['element' => $this->_rootElement->find($this->paymentInfoBlockSelector)] ); } + + /** + * Returns Comments history block. + * + * @return CommentsHistoryBlock + */ + public function getCommentsHistoryBlock() + { + return $this->blockFactory->create( + CommentsHistoryBlock::class, + ['element' => $this->_rootElement->find($this->commentsHistoryBlockSelector)] + ); + } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/CommentsHistoryBlock.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/CommentsHistoryBlock.php new file mode 100644 index 0000000000000000000000000000000000000000..ce36ae7324cac639e46e72c85fa81c26c79f2244 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/CommentsHistoryBlock.php @@ -0,0 +1,90 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info; + +use Magento\Mtf\Block\Block; + +/** + * Order comments history block. + */ +class CommentsHistoryBlock extends Block +{ + /** + * Comment history list locator. + * + * @var string + */ + protected $commentHistory = '.note-list-item'; + + /** + * Comment date. + * + * @var string + */ + protected $commentHistoryDate = '.note-list-date'; + + /** + * Comment time. + * + * @var string + */ + protected $commentHistoryTime = '.note-list-time'; + + /** + * Comment status. + * + * @var string + */ + protected $commentHistoryStatus = '.note-list-status'; + + /** + * Comment notified status. + * + * @var string + */ + protected $commentHistoryNotifiedStatus = '.note-list-customer'; + + /** + * Comment locator. + * + * @var string + */ + protected $comment = '.note-list-comment'; + + /** + * Get comment history block data. + * + * @return array + */ + public function getComments() + { + $result = []; + $elements = $this->_rootElement->getElements($this->commentHistory); + foreach ($elements as $key => $item) { + $result[$key] = [ + 'date' => $item->find($this->commentHistoryDate)->getText(), + 'time' => $item->find($this->commentHistoryTime)->getText(), + 'status' => $item->find($this->commentHistoryStatus)->getText(), + 'is_customer_notified' => $item->find($this->commentHistoryNotifiedStatus)->getText(), + 'comment' => $item->find($this->comment)->getText() + ]; + } + + return $result; + } + + /** + * Get last comment. + * + * @return array + */ + public function getLatestComment() + { + $comments = $this->getComments(); + return current($comments); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAcceptPaymentMessageInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAcceptPaymentMessageInCommentsHistory.php index 1871a12ee2ce421dd2df99912d545757a5e4550a..d9c75b3c9dad045109306e816838602026e1c012 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAcceptPaymentMessageInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAcceptPaymentMessageInCommentsHistory.php @@ -10,34 +10,42 @@ use Magento\Sales\Test\Page\Adminhtml\OrderIndex; use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; /** - * Class AssertAcceptPaymentMessageInCommentsHistory + * Assert that accept payment message exists in Comments History section on order page in Admin. * - * Constraint checks accept payment message in order comments history */ class AssertAcceptPaymentMessageInCommentsHistory extends AbstractConstraint { - /** + * Accept payment message. + * * @var string */ private static $message = 'Approved the payment online.'; /** - * @param SalesOrderView $orderView + * Assert that accept payment message exists in Comments History section on order page in Admin. + * + * @param SalesOrderView $salesOrderView * @param OrderIndex $orderIndex * @param $orderId + * @return void */ - public function processAssert(SalesOrderView $orderView, OrderIndex $orderIndex, $orderId) + public function processAssert(SalesOrderView $salesOrderView, OrderIndex $orderIndex, $orderId) { $orderIndex->open(); $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - $history = $orderView->getOrderHistoryBlock()->getCommentsHistory(); - \PHPUnit_Framework_Assert::assertContains(self::$message, $history); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); + + \PHPUnit_Framework_Assert::assertContains(self::$message, $latestComment['comment']); } /** - * @inheritdoc + * Returns a string representation of the object. + * + * @return string */ public function toString() { diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAuthorizationInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAuthorizationInCommentsHistory.php index 8b34837bc8df3efe77a348070abdcf12de71ac7f..309a3795e68ab84398d623476a00939c405bf51f 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAuthorizationInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAuthorizationInCommentsHistory.php @@ -21,7 +21,7 @@ class AssertAuthorizationInCommentsHistory extends AbstractConstraint const AUTHORIZED_AMOUNT_PATTERN = '/(IPN "Pending" )*Authorized amount of \w*\W{1,2}%s. Transaction ID: "[\w\-]*"/'; /** - * Assert that comment about authorized amount exist in Comments History section on order page in Admin. + * Assert that comment about authorized amount exists in Comments History section on order page in Admin. * * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder @@ -37,11 +37,14 @@ class AssertAuthorizationInCommentsHistory extends AbstractConstraint ) { $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - $actualAuthorizedAmount = $salesOrderView->getOrderHistoryBlock()->getAuthorizedAmount(); + + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); \PHPUnit_Framework_Assert::assertRegExp( sprintf(self::AUTHORIZED_AMOUNT_PATTERN, $prices['grandTotal']), - $actualAuthorizedAmount, + $latestComment['comment'], 'Incorrect authorized amount value for the order #' . $orderId ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCaptureInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCaptureInCommentsHistory.php index 90e0e7b091a11f51c04e8f719b3e1b4382080d61..cfaf95bbdeb1a285fc1dafd180d3cac863a6c909 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCaptureInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCaptureInCommentsHistory.php @@ -6,7 +6,6 @@ namespace Magento\Sales\Test\Constraint; -use Magento\Sales\Test\Fixture\OrderInjectable; use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Sales\Test\Page\Adminhtml\OrderIndex; use Magento\Mtf\Constraint\AbstractConstraint; @@ -22,7 +21,7 @@ class AssertCaptureInCommentsHistory extends AbstractConstraint const CAPTURED_AMOUNT_PATTERN = '/^Captured amount of \w*\W{1,2}%s online. Transaction ID: "[\w\-]*"/'; /** - * Assert that comment about captured amount exist in Comments History section on order page in Admin. + * Assert that comment about captured amount exists in Comments History section on order page in Admin. * * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder @@ -39,11 +38,21 @@ class AssertCaptureInCommentsHistory extends AbstractConstraint $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - $actualCapturedAmount = $salesOrderView->getOrderHistoryBlock()->getCapturedAmount(); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $comments = $infoTab->getCommentsHistoryBlock()->getComments(); + + foreach ($comments as $key => $comment) { + if (stristr($comment['comment'], 'captured') === false) { + unset($comments[$key]); + } + } + $comments = array_values($comments); + foreach ($capturedPrices as $key => $capturedPrice) { \PHPUnit_Framework_Assert::assertRegExp( sprintf(self::CAPTURED_AMOUNT_PATTERN, $capturedPrice), - $actualCapturedAmount[$key], + $comments[$key]['comment'], 'Incorrect captured amount value for the order #' . $orderId ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertDenyPaymentMessageInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertDenyPaymentMessageInCommentsHistory.php index 87cac1c38232b023174b515c4923f30dd3ab56f4..1fca0cc18869d4b5f1e0240119fee774596a46ab 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertDenyPaymentMessageInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertDenyPaymentMessageInCommentsHistory.php @@ -10,33 +10,43 @@ use Magento\Sales\Test\Page\Adminhtml\OrderIndex; use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; /** - * Class AssertDenyPaymentMessageInCommentsHistory + * Assert that deny payment message exists in Comments History section on order page in Admin. * * Constraint checks deny payment message in order comments history */ class AssertDenyPaymentMessageInCommentsHistory extends AbstractConstraint { /** + * Deny payment message. + * * @var string */ private static $message = 'Denied the payment online'; /** - * @param SalesOrderView $orderView + * Assert that deny payment message exists in Comments History section on order page in Admin. + * + * @param SalesOrderView $salesOrderView * @param OrderIndex $orderIndex * @param $orderId + * @return void */ - public function processAssert(SalesOrderView $orderView, OrderIndex $orderIndex, $orderId) + public function processAssert(SalesOrderView $salesOrderView, OrderIndex $orderIndex, $orderId) { $orderIndex->open(); $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - $history = $orderView->getOrderHistoryBlock()->getCommentsHistory(); - \PHPUnit_Framework_Assert::assertContains(self::$message, $history); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); + + \PHPUnit_Framework_Assert::assertContains(self::$message, $latestComment['comment']); } /** - * @inheritdoc + * Returns a string representation of the object. + * + * @return string */ public function toString() { diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderCommentsHistoryNotifyStatus.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderCommentsHistoryNotifyStatus.php index 013c3562b709096a12f8e5f88a4c8f806640af57..fba79572c570ed415175db6f4f701a2b7b8cdb28 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderCommentsHistoryNotifyStatus.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderCommentsHistoryNotifyStatus.php @@ -11,12 +11,12 @@ use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Sales\Test\Fixture\OrderInjectable; /** - * Class AssertOrderCommentsHistoryNotifyStatus + * Assert that comment has appropriate notification status in Comments History section on order page in Admin. */ class AssertOrderCommentsHistoryNotifyStatus extends AbstractConstraint { /** - * Assert that comment about refunded amount exist in Comments History section on order page in Admin. + * Assert that comment has appropriate notification status in Comments History section on order page in Admin. * * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder @@ -35,8 +35,13 @@ class AssertOrderCommentsHistoryNotifyStatus extends AbstractConstraint $data['form_data']['send_email'], FILTER_VALIDATE_BOOLEAN ) : false; + + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); + \PHPUnit_Framework_Assert::assertContains( - $salesOrderView->getOrderHistoryBlock()->getNotifiedStatus(), + $latestComment['is_customer_notified'], (bool)$sendMail ? 'Customer Notified' : 'Customer Not Notified' ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php index c0ce2a87fc1c3f62b1a934852c206358a3e76760..80ab8074410938752d02bc89d2dd415ba98ab42f 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php @@ -21,7 +21,7 @@ class AssertRefundInCommentsHistory extends AbstractConstraint const REFUNDED_AMOUNT_PATTERN = '/^We refunded \w*\W{1,2}%s online. Transaction ID: "[\w\-]*"/'; /** - * Assert that comment about refunded amount exist in Comments History section on order page in Admin. + * Assert that comment about refunded amount exists in Comments History section on order page in Admin. * * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder @@ -38,11 +38,21 @@ class AssertRefundInCommentsHistory extends AbstractConstraint $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - $actualRefundedAmount = $salesOrderView->getOrderHistoryBlock()->getRefundedAmount(); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $comments = $infoTab->getCommentsHistoryBlock()->getComments(); + + foreach ($comments as $key => $comment) { + if (stristr($comment['comment'], 'refunded') === false) { + unset($comments[$key]); + } + } + $comments = array_values($comments); + foreach ($refundedPrices as $key => $refundedPrice) { \PHPUnit_Framework_Assert::assertRegExp( sprintf(self::REFUNDED_AMOUNT_PATTERN, $refundedPrice), - $actualRefundedAmount[$key], + $comments[$key]['comment'], 'Incorrect refunded amount value for the order #' . $orderId ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php index 557e29a0b9830200381f7651e3807cff39247040..c90bbf68531cc02ad558bbe259ac74562facab82 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php @@ -11,12 +11,12 @@ use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Sales\Test\Fixture\OrderInjectable; /** - * Assert that comment about refunded amount exist in Comments History section on order page in Admin. + * Assert that comment with correct order status exists in Comments History section on order page in Admin. */ class AssertRefundOrderStatusInCommentsHistory extends AbstractConstraint { /** - * Assert that comment about refunded amount exist in Comments History section on order page in Admin. + * Assert that comment with correct order status exists in Comments History section on order page in Admin. * * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder @@ -33,9 +33,11 @@ class AssertRefundOrderStatusInCommentsHistory extends AbstractConstraint /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); + \PHPUnit_Framework_Assert::assertContains( $infoTab->getOrderStatus(), - $salesOrderView->getOrderHistoryBlock()->getStatus() + $latestComment['status'] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertVoidInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertVoidInCommentsHistory.php index bc3e90ee7f776c74fa8b55fb95be6ac19d49ffca..b3df74ea74a20696c2ee0e7fc9de6c0fce4b84c5 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertVoidInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertVoidInCommentsHistory.php @@ -21,7 +21,7 @@ class AssertVoidInCommentsHistory extends AbstractConstraint const VOIDED_AMOUNT = 'Voided authorization. Amount: $'; /** - * Assert that comment about voided amount exist in Comments History section on order page in Admin. + * Assert that comment about voided amount exists in Comments History section on order page in Admin. * * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder @@ -38,9 +38,13 @@ class AssertVoidInCommentsHistory extends AbstractConstraint $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); + \PHPUnit_Framework_Assert::assertContains( self::VOIDED_AMOUNT . $prices['grandTotal'], - $salesOrderView->getOrderHistoryBlock()->getVoidedAmount(), + $latestComment['comment'], 'Incorrect voided amount value for the order #' . $orderId ); }