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..5000bbed56f3de08b6a05fa920a3f0741145871d 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\CommentHistoryBlock; 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 Comment history block. + * + * @var string + */ + private $commentHistoryBlockSelector = '#order_history_block'; + /** * Get order status from info block. * @@ -50,4 +58,17 @@ class Info extends Tab ['element' => $this->_rootElement->find($this->paymentInfoBlockSelector)] ); } + + /** + * Returns Comment history block. + * + * @return CommentHistoryBlock + */ + public function getCommentHistoryBlock() + { + return $this->blockFactory->create( + CommentHistoryBlock::class, + ['element' => $this->_rootElement->find($this->commentHistoryBlockSelector)] + ); + } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/CommentHistoryBlock.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/CommentHistoryBlock.php new file mode 100644 index 0000000000000000000000000000000000000000..c9223d75115ec311a203ebf13f4ca7c4e0185d60 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/CommentHistoryBlock.php @@ -0,0 +1,119 @@ +<?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 CommentHistoryBlock extends Block +{ + /** + * Comment history list locator. + * + * @var string + */ + protected $commentHistory = '.note-list'; + + /** + * 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'; + + /** + * 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")]'; + + /** + * Get comment history block data. + * + * @return array + */ + public function getComments() + { + $result = []; + $elements = $this->_rootElement->getElements($this->commentHistory); + foreach ($elements as $item) { + $result['date'] = $item->find($this->commentHistoryDate)->getText(); + $result['time'] = $item->find($this->commentHistoryTime)->getText(); + $result['status'] = $item->find($this->commentHistoryStatus)->getText(); + $result['is_customer_notified'] = $item->find($this->commentHistoryNotifiedStatus)->getText(); + $result['authorized_amount'] = $item->find($this->authorizedAmount)->getText(); + $result['captured_amount'] = $item->find($this->capturedAmount)->getText(); + $result['refunded_amount'] = $item->find($this->refundedAmount)->getText(); + $result['voided_amount'] = $item->find($this->voidedAmount)->getText(); + } + + return $result; + } + + /** + * Get last comment. + * + * @return array + */ + public function getLatestComment() + { + $comments = $this->getComments(); + return end($comments); + } +} 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..2b03f14d3f9c3ff69feae25b9066f2bc624968f6 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 @@ -37,11 +37,17 @@ 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'); + $historyBlock = $infoTab->getCommentHistoryBlock(); + $lastComment = $historyBlock->getLatestComment(); + + //$actualAuthorizedAmount = $salesOrderView->getOrderHistoryBlock()->getAuthorizedAmount(); \PHPUnit_Framework_Assert::assertRegExp( sprintf(self::AUTHORIZED_AMOUNT_PATTERN, $prices['grandTotal']), - $actualAuthorizedAmount, + $lastComment['authorized_amount'], 'Incorrect authorized amount value for the order #' . $orderId ); }