Skip to content

Commit 8b97780

Browse files
committed
MAGETWO-58237: Order status history contains wrong data after creation of a Credit Memo. Add functional assertion
1 parent 52abf41 commit 8b97780

File tree

4 files changed

+75
-6
lines changed

4 files changed

+75
-6
lines changed

dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/History.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ class History extends Block
2828
*/
2929
protected $commentHistoryStatus = '.note-list-status';
3030

31+
/**
32+
* Comment history notified status.
33+
*
34+
* @var string
35+
*/
36+
protected $commentHistoryNotifiedStatus = '.note-list-customer';
37+
3138
/**
3239
* Authorized Amount.
3340
*
@@ -121,6 +128,17 @@ public function getStatus()
121128
return $this->_rootElement->find($this->commentHistoryStatus, Locator::SELECTOR_CSS)->getText();
122129
}
123130

131+
/**
132+
* Gets the is customer notified status which presented in comment
133+
*
134+
* @return string
135+
*/
136+
public function getNotifiedStatus()
137+
{
138+
$this->waitCommentsHistory();
139+
return $this->_rootElement->find($this->commentHistoryNotifiedStatus, Locator::SELECTOR_CSS)->getText();
140+
}
141+
124142
/**
125143
* Wait for comments history is visible.
126144
*
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Test\Constraint;
7+
8+
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
9+
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
use Magento\Sales\Test\Fixture\OrderInjectable;
12+
13+
/**
14+
* Class AssertOrderCommentsHistoryNotifyStatus
15+
*/
16+
class AssertOrderCommentsHistoryNotifyStatus extends AbstractConstraint
17+
{
18+
/**
19+
* Assert that comment about refunded amount exist in Comments History section on order page in Admin.
20+
*
21+
* @param SalesOrderView $salesOrderView
22+
* @param OrderIndex $salesOrder
23+
* @param OrderInjectable $order
24+
* @param array $data
25+
*/
26+
public function processAssert(
27+
SalesOrderView $salesOrderView,
28+
OrderIndex $salesOrder,
29+
OrderInjectable $order,
30+
array $data
31+
) {
32+
$salesOrder->open();
33+
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]);
34+
$sendMail = isset($data['form_data']['send_email']) ? filter_var(
35+
$data['form_data']['send_email'],
36+
FILTER_VALIDATE_BOOLEAN
37+
) : false;
38+
\PHPUnit_Framework_Assert::assertContains(
39+
$salesOrderView->getOrderHistoryBlock()->getNotifiedStatus(),
40+
(bool)$sendMail ? 'Customer Notified' : 'Customer Not Notified'
41+
);
42+
}
43+
44+
/**
45+
* Returns string representation of successful assertion.
46+
*
47+
* @return string
48+
*/
49+
public function toString()
50+
{
51+
return "Message with appropriate notification status is available in Comments History section.";
52+
}
53+
}

dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
*/
1616
class AssertRefundOrderStatusInCommentsHistory extends AbstractConstraint
1717
{
18-
/**
19-
* Message about refunded amount in order.
20-
*/
21-
const REFUNDED_AMOUNT = 'We refunded $';
22-
2318
/**
2419
* Assert that comment about refunded amount exist in Comments History section on order page in Admin.
2520
*
@@ -48,6 +43,6 @@ public function processAssert(
4843
*/
4944
public function toString()
5045
{
51-
return "Message about refunded amount is available in Comments History section.";
46+
return "Message with appropriate order status is available in Comments History section.";
5247
}
5348
}

dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCreditMemoEntityTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
<data name="description" xsi:type="string">Assert items return to stock (partial refund)</data>
1212
<data name="data/items_data/0/back_to_stock" xsi:type="string">Yes</data>
1313
<data name="data/items_data/0/qty" xsi:type="string">1</data>
14+
<data name="data/form_data/send_email" xsi:type="string">Yes</data>
1415
<data name="order/dataset" xsi:type="string">default</data>
1516
<data name="order/data/entity_id/products" xsi:type="string">catalogProductSimple::product_100_dollar</data>
1617
<data name="order/data/price/dataset" xsi:type="string">partial_refund</data>
18+
<data name="order/data/customer_note_notify" xsi:type="boolean">true</data>
1719
<constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" />
1820
<constraint name="Magento\Sales\Test\Constraint\AssertCreditMemoButton" />
1921
<constraint name="Magento\Sales\Test\Constraint\AssertRefundInCreditMemoTab" />
2022
<constraint name="Magento\Sales\Test\Constraint\AssertRefundInRefundsGrid" />
2123
<constraint name="Magento\Sales\Test\Constraint\AssertRefundOrderStatusInCommentsHistory" />
24+
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCommentsHistoryNotifyStatus" />
2225
<constraint name="Magento\Sales\Test\Constraint\AssertRefundedGrandTotalOnFrontend" />
2326
<constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" />
2427
<constraint name="Magento\Sales\Test\Constraint\AssertCreditMemoItems" />

0 commit comments

Comments
 (0)