Skip to content

Commit e10e50f

Browse files
author
Dmytro Yushkin
committed
MAGETWO-63855: Create functional automated test for complete flow
1 parent a81251a commit e10e50f

File tree

4 files changed

+133
-2
lines changed

4 files changed

+133
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ public function processAssert(
4040

4141
/** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
4242
$infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
43-
$latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment();
43+
$orderComments = $infoTab->getCommentsHistoryBlock()->getComments();
44+
$commentsMessages = array_column($orderComments, 'comment');
4445

4546
\PHPUnit_Framework_Assert::assertRegExp(
4647
sprintf(self::AUTHORIZED_AMOUNT_PATTERN, $prices['grandTotal']),
47-
$latestComment['comment'],
48+
implode('. ', $commentsMessages),
4849
'Incorrect authorized amount value for the order #' . $orderId
4950
);
5051
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Test\Constraint;
7+
8+
use Magento\Mtf\Constraint\AbstractConstraint;
9+
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
10+
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
11+
12+
/**
13+
* Assert that comment about canceled amount exists in
14+
* Comments History section on order page in Admin.
15+
*/
16+
class AssertCancelInCommentsHistory extends AbstractConstraint
17+
{
18+
/**
19+
* Pattern of message about canceled amount in order.
20+
*/
21+
private $canceledAmountPattern = '/^Canceled order online Amount: \w*\W{1,2}%s. Transaction ID: "[\w\-]*"/';
22+
23+
/**
24+
* @param SalesOrderView $salesOrderView
25+
* @param OrderIndex $salesOrder
26+
* @param string $orderId
27+
* @param array $prices
28+
* @return void
29+
*/
30+
public function processAssert(
31+
SalesOrderView $salesOrderView,
32+
OrderIndex $salesOrder,
33+
$orderId,
34+
array $prices
35+
) {
36+
$salesOrder->open();
37+
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
38+
39+
/** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
40+
$infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
41+
$comments = $infoTab->getCommentsHistoryBlock()->getComments();
42+
$commentsMessages = array_column($comments, 'comment');
43+
44+
\PHPUnit_Framework_Assert::assertRegExp(
45+
sprintf($this->canceledAmountPattern, $prices['grandTotal']),
46+
implode('. ', $commentsMessages),
47+
'Incorrect canceled amount value for the order #' . $orderId
48+
);
49+
}
50+
51+
/**
52+
* Returns a string representation of the object.
53+
*
54+
* @return string
55+
*/
56+
public function toString()
57+
{
58+
return "Message about canceled amount is available in Comments History section.";
59+
}
60+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Test\TestStep;
7+
8+
use Magento\Mtf\TestStep\TestStepInterface;
9+
use Magento\Sales\Test\Fixture\OrderInjectable;
10+
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
11+
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
12+
13+
/**
14+
* Click cancel from order on backend.
15+
*/
16+
class CancelOrderStep implements TestStepInterface
17+
{
18+
/**
19+
* Sales order index page.
20+
*
21+
* @var OrderIndex
22+
*/
23+
private $orderIndex;
24+
25+
/**
26+
* Order instance.
27+
*
28+
* @var OrderInjectable
29+
*/
30+
private $order;
31+
32+
/**
33+
* Order View Page.
34+
*
35+
* @var SalesOrderView
36+
*/
37+
protected $salesOrderView;
38+
39+
/**
40+
* @param OrderIndex $orderIndex
41+
* @param OrderInjectable $order
42+
* @param SalesOrderView $salesOrderView
43+
*/
44+
public function __construct(
45+
OrderIndex $orderIndex,
46+
OrderInjectable $order,
47+
SalesOrderView $salesOrderView
48+
) {
49+
$this->orderIndex = $orderIndex;
50+
$this->order = $order;
51+
$this->salesOrderView = $salesOrderView;
52+
}
53+
54+
/**
55+
* Run step flow
56+
*
57+
* @return void
58+
*/
59+
public function run()
60+
{
61+
$this->orderIndex->open();
62+
$this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]);
63+
$this->salesOrderView->getPageActions()->cancel();
64+
}
65+
}

dev/tests/functional/tests/app/Magento/Sales/Test/etc/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,9 @@
111111
<argument name="severity" xsi:type="string">S0</argument>
112112
</arguments>
113113
</type>
114+
<type name="Magento\Sales\Test\Constraint\AssertCancelInCommentsHistory">
115+
<arguments>
116+
<argument name="severity" xsi:type="string">S0</argument>
117+
</arguments>
118+
</type>
114119
</config>

0 commit comments

Comments
 (0)