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..be67cd524cf9b104a840f68ff9036aebba97d8d6 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 @@ -71,10 +71,12 @@ class AssertTransactionIsPresentInSettlementReport extends AbstractConstraint */ 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->getCommentHistoryBlock()->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/CommentHistoryBlock.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/CommentHistoryBlock.php index c9223d75115ec311a203ebf13f4ca7c4e0185d60..b86f923f612dedbe9922853c1db2d2049e1f3712 100644 --- 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 @@ -55,34 +55,6 @@ class CommentHistoryBlock extends Block */ 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. * @@ -92,15 +64,12 @@ class CommentHistoryBlock extends Block { $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(); + foreach ($elements as $key => $item) { + $result[$key]['date'] = $item->find($this->commentHistoryDate)->getText(); + $result[$key]['time'] = $item->find($this->commentHistoryTime)->getText(); + $result[$key]['status'] = $item->find($this->commentHistoryStatus)->getText(); + $result[$key]['is_customer_notified'] = $item->find($this->commentHistoryNotifiedStatus)->getText(); + $result[$key]['comment'] = $item->find($this->comment)->getText(); } return $result; 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..d6958ff5698ae29b35fd4d9f69167e7eee68686b 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 @@ -23,17 +23,21 @@ class AssertAcceptPaymentMessageInCommentsHistory extends AbstractConstraint private static $message = 'Approved the payment online.'; /** - * @param SalesOrderView $orderView + * @param SalesOrderView $salesOrderView * @param OrderIndex $orderIndex * @param $orderId + * @internal param SalesOrderView $orderView */ - 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->getCommentHistoryBlock()->getLatestComment(); + + \PHPUnit_Framework_Assert::assertContains(self::$message, $latestComment['comment']); } /** 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 2b03f14d3f9c3ff69feae25b9066f2bc624968f6..60e00991404ce043dc002f1d6ed142f291fe3042 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 @@ -40,14 +40,11 @@ class AssertAuthorizationInCommentsHistory extends AbstractConstraint /** @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(); + $latestComment = $infoTab->getCommentHistoryBlock()->getLatestComment(); \PHPUnit_Framework_Assert::assertRegExp( sprintf(self::AUTHORIZED_AMOUNT_PATTERN, $prices['grandTotal']), - $lastComment['authorized_amount'], + $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..ffcea34ef03b2c3d547240d82305ba9af1ddb6bc 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 @@ -39,11 +39,14 @@ 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->getCommentHistoryBlock()->getComments(); + 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..ed2a469d9704495e8aaec6345fb2d40c035da29f 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 @@ -22,17 +22,21 @@ class AssertDenyPaymentMessageInCommentsHistory extends AbstractConstraint private static $message = 'Denied the payment online'; /** - * @param SalesOrderView $orderView + * @param SalesOrderView $salesOrderView * @param OrderIndex $orderIndex * @param $orderId + * @internal param SalesOrderView $orderView */ - 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->getCommentHistoryBlock()->getLatestComment(); + + \PHPUnit_Framework_Assert::assertContains(self::$message, $latestComment['comment']); } /** 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..e8a4797fb1b110a99880a453a861872837ce1b1a 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 @@ -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->getCommentHistoryBlock()->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..ce242eab12a016e49f42d35fcf5c01a53a278e2d 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 @@ -38,11 +38,14 @@ 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->getCommentHistoryBlock()->getComments(); + 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..bfdfec027f745172e32d963188c82deedabee763 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 @@ -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->getCommentHistoryBlock()->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..c1e4db8ca0021549cc11010c086c9d6087907dde 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 @@ -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->getCommentHistoryBlock()->getLatestComment(); + \PHPUnit_Framework_Assert::assertContains( self::VOIDED_AMOUNT . $prices['grandTotal'], - $salesOrderView->getOrderHistoryBlock()->getVoidedAmount(), + $latestComment['comment'], 'Incorrect voided amount value for the order #' . $orderId ); }