Skip to content

Commit 7008065

Browse files
committed
Merge remote-tracking branch 'mavericks/MTA-3797-PR' into mavericks-PR
2 parents f0c9f7f + 113c5ba commit 7008065

File tree

7 files changed

+274
-10
lines changed

7 files changed

+274
-10
lines changed

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,7 @@ public function edit()
178178
public function cancel()
179179
{
180180
$this->_rootElement->find($this->cancel)->click();
181-
$element = $this->browser->find($this->confirmModal);
182-
/** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */
183-
$modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]);
184-
$modal->acceptAlert();
181+
$this->acceptAlert();
185182
}
186183

187184
/**
@@ -202,6 +199,7 @@ public function sendEmail()
202199
public function void()
203200
{
204201
$this->_rootElement->find($this->void)->click();
202+
$this->acceptAlert();
205203
}
206204

207205
/**
@@ -266,27 +264,36 @@ public function isActionButtonVisible($buttonName)
266264
}
267265

268266
/**
269-
* Accept order
267+
* Accept order.
268+
*
270269
* @return void
271270
*/
272271
public function accept()
273272
{
274273
$acceptPayment = '#accept_payment';
275274
$this->_rootElement->find($acceptPayment)->click();
276-
$element = $this->browser->find($this->confirmModal);
277-
/** @var Modal $modal */
278-
$modal = $this->blockFactory->create(Modal::class, ['element' => $element]);
279-
$modal->acceptAlert();
275+
$this->acceptAlert();
280276
}
281277

282278
/**
283-
* Deny order
279+
* Deny order.
280+
*
284281
* @return void
285282
*/
286283
public function deny()
287284
{
288285
$denyPayment = '#deny_payment';
289286
$this->_rootElement->find($denyPayment)->click();
287+
$this->acceptAlert();
288+
}
289+
290+
/**
291+
* Accept alert.
292+
*
293+
* @return void
294+
*/
295+
private function acceptAlert()
296+
{
290297
$element = $this->browser->find($this->confirmModal);
291298
/** @var Modal $modal */
292299
$modal = $this->blockFactory->create(Modal::class, ['element' => $element]);

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
@@ -56,6 +56,13 @@ class History extends Block
5656
*/
5757
protected $refundedAmount = '//div[@class="note-list-comment"][contains(text(), "We refunded")]';
5858

59+
/**
60+
* Voided Amount.
61+
*
62+
* @var string
63+
*/
64+
protected $voidedAmount = '//div[@class="note-list-comment"][contains(text(), "Voided authorization")]';
65+
5966
/**
6067
* Note list locator.
6168
*
@@ -117,6 +124,17 @@ public function getRefundedAmount()
117124
return $result;
118125
}
119126

127+
/**
128+
* Get the voided amount from the comments history.
129+
*
130+
* @return string
131+
*/
132+
public function getVoidedAmount()
133+
{
134+
$this->waitCommentsHistory();
135+
return $this->_rootElement->find($this->voidedAmount, Locator::SELECTOR_XPATH)->getText();
136+
}
137+
120138
/**
121139
* Gets the status which presented in comment
122140
*
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Test\Constraint;
8+
9+
use Magento\Sales\Test\Page\Adminhtml\OrderStatusIndex;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
12+
/**
13+
* Assert that success message about order void is present.
14+
*
15+
*/
16+
class AssertOrderSuccessVoidedMessage extends AbstractConstraint
17+
{
18+
/* tags */
19+
const SEVERITY = 'low';
20+
/* end tags */
21+
22+
/**
23+
* Message about successful void.
24+
*/
25+
const SUCCESS_MESSAGE = 'The payment has been voided.';
26+
27+
/**
28+
* Assert that success message is displayed after order is voided.
29+
*
30+
* @param OrderStatusIndex $orderStatusIndexPage
31+
* @return void
32+
*/
33+
public function processAssert(OrderStatusIndex $orderStatusIndexPage)
34+
{
35+
$actualMessage = $orderStatusIndexPage->getMessagesBlock()->getSuccessMessage();
36+
\PHPUnit_Framework_Assert::assertEquals(
37+
self::SUCCESS_MESSAGE,
38+
$actualMessage,
39+
'Wrong success message is displayed.'
40+
. "\nExpected: " . self::SUCCESS_MESSAGE
41+
. "\nActual: " . $actualMessage
42+
);
43+
}
44+
45+
/**
46+
* Text of voided order message assert.
47+
*
48+
* @return string
49+
*/
50+
public function toString()
51+
{
52+
return 'Order successful void message is present.';
53+
}
54+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Test\Constraint;
8+
9+
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
10+
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
11+
use Magento\Mtf\Constraint\AbstractConstraint;
12+
13+
/**
14+
* Assert that comment about voided amount exists in Comments History section on order page in Admin.
15+
*/
16+
class AssertVoidInCommentsHistory extends AbstractConstraint
17+
{
18+
/**
19+
* Message about voided amount in order.
20+
*/
21+
const VOIDED_AMOUNT = 'Voided authorization. Amount: $';
22+
23+
/**
24+
* Assert that comment about voided amount exist in Comments History section on order page in Admin.
25+
*
26+
* @param SalesOrderView $salesOrderView
27+
* @param OrderIndex $salesOrder
28+
* @param string $orderId
29+
* @param array $prices
30+
* @return void
31+
*/
32+
public function processAssert(
33+
SalesOrderView $salesOrderView,
34+
OrderIndex $salesOrder,
35+
$orderId,
36+
array $prices
37+
) {
38+
$salesOrder->open();
39+
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
40+
41+
\PHPUnit_Framework_Assert::assertContains(
42+
self::VOIDED_AMOUNT . $prices['grandTotal'],
43+
$salesOrderView->getOrderHistoryBlock()->getVoidedAmount(),
44+
'Incorrect voided amount value for the order #' . $orderId
45+
);
46+
}
47+
48+
/**
49+
* Returns string representation of successful assertion.
50+
*
51+
* @return string
52+
*/
53+
public function toString()
54+
{
55+
return "Message about voided amount is available in Comments History section.";
56+
}
57+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Test\TestCase;
8+
9+
use Magento\Mtf\TestCase\Scenario;
10+
11+
/**
12+
* Preconditions:
13+
* 1. Configure shipping method.
14+
* 2. Configure payment method.
15+
* 3. Create products.
16+
*
17+
* Steps:
18+
* 1. Go to Storefront.
19+
* 2. Add products to the cart.
20+
* 3. Click the 'Proceed to Checkout' button.
21+
* 4. Select checkout method according to dataset.
22+
* 5. Fill billing information and select the 'Ship to this address' option.
23+
* 6. Select shipping method.
24+
* 7. Select payment method.
25+
* 8. Place order.
26+
* 9. Open created order.
27+
* 10. Click 'Void' button.
28+
* 11. Perform assertions.
29+
*
30+
* @group Order_Management
31+
* @ZephyrId MAGETWO-39444
32+
*/
33+
class VoidAuthorizationTest extends Scenario
34+
{
35+
/* tags */
36+
const MVP = 'yes';
37+
const TEST_TYPE = '3rd_party_test';
38+
/* end tags */
39+
40+
/**
41+
* Void order authorization.
42+
*
43+
* @return void
44+
*/
45+
public function test()
46+
{
47+
$this->executeScenario();
48+
}
49+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Test\TestStep;
8+
9+
use Magento\Sales\Test\Fixture\OrderInjectable;
10+
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
11+
use Magento\Mtf\TestStep\TestStepInterface;
12+
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
13+
14+
/**
15+
* Void authorization for created order.
16+
*/
17+
class VoidAuthorizationStep implements TestStepInterface
18+
{
19+
/**
20+
* Sales order index page.
21+
*
22+
* @var OrderIndex
23+
*/
24+
protected $orderIndex;
25+
26+
/**
27+
* Order instance.
28+
*
29+
* @var OrderInjectable
30+
*/
31+
protected $order;
32+
33+
/**
34+
* Order view page.
35+
*
36+
* @var SalesOrderView
37+
*/
38+
private $salesOrderView;
39+
40+
/**
41+
* @param OrderInjectable $order
42+
* @param OrderIndex $orderIndex
43+
* @param SalesOrderView $salesOrderView
44+
*/
45+
public function __construct(OrderInjectable $order, OrderIndex $orderIndex, SalesOrderView $salesOrderView)
46+
{
47+
$this->orderIndex = $orderIndex;
48+
$this->order = $order;
49+
$this->salesOrderView = $salesOrderView;
50+
}
51+
52+
/**
53+
* Void authorization.
54+
*
55+
* @return void
56+
*/
57+
public function run()
58+
{
59+
$this->orderIndex->open();
60+
$this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]);
61+
$this->salesOrderView->getPageActions()->void();
62+
}
63+
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@
3535
<step name="selectPaymentMethodForOrder" module="Magento_Sales" next="submitOrder" />
3636
<step name="submitOrder" module="Magento_Sales" />
3737
</scenario>
38+
<scenario name="VoidAuthorizationTest" firstStep="setupConfiguration">
39+
<step name="setupConfiguration" module="Magento_Config" next="createProducts" />
40+
<step name="createProducts" module="Magento_Catalog" next="createTaxRule" />
41+
<step name="createTaxRule" module="Magento_Tax" next="addProductsToTheCart" />
42+
<step name="addProductsToTheCart" module="Magento_Checkout" next="estimateShippingAndTax" />
43+
<step name="estimateShippingAndTax" module="Magento_Checkout" next="clickProceedToCheckout" />
44+
<step name="clickProceedToCheckout" module="Magento_Checkout" next="createCustomer" />
45+
<step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod" />
46+
<step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress" />
47+
<step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod" />
48+
<step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod" />
49+
<step name="selectPaymentMethod" module="Magento_Checkout" next="fillBillingInformation" />
50+
<step name="fillBillingInformation" module="Magento_Checkout" next="placeOrder" />
51+
<step name="placeOrder" module="Magento_Checkout" next="voidAuthorization" />
52+
<step name="voidAuthorization" module="Magento_Sales" />
53+
</scenario>
3854
<scenario name="PrintOrderFrontendGuestTest" firstStep="createProducts">
3955
<step name="createProducts" module="Magento_Catalog" next="createCustomer" />
4056
<step name="createCustomer" module="Magento_Customer" next="openSalesOrders" />

0 commit comments

Comments
 (0)