Skip to content

Commit 371feda

Browse files
oserediukvzabaznov
authored andcommitted
MAGETWO-61095: When attempting to place a reorder after a product is disabled, product still gets added to the cart
1 parent 81dbf54 commit 371feda

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ class History extends Block
4343
*/
4444
protected $viewButton = '.action.view';
4545

46+
/**
47+
* 'Reorder' button css selector.
48+
*
49+
* @var string
50+
*/
51+
protected $reorderButton = '.action.order';
52+
4653
/**
4754
* Order history form selector.
4855
*
@@ -100,6 +107,18 @@ public function openOrderById($id)
100107
$this->searchOrderById($id)->find($this->viewButton)->click();
101108
}
102109

110+
/**
111+
* Check if 'Reorder' button is visible for customer on order page
112+
*
113+
* @param string $id
114+
* @return boolean
115+
*/
116+
public function isReorderButtonPresentByOrderId($id)
117+
{
118+
$this->waitFormToLoad();
119+
return $this->searchOrderById($id)->find($this->reorderButton)->isVisible();
120+
}
121+
103122
/**
104123
* Method that escapes currency symbols.
105124
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Test\Constraint;
8+
9+
use Magento\Customer\Test\Fixture\Customer;
10+
use Magento\Customer\Test\Page\CustomerAccountIndex;
11+
use Magento\Sales\Test\Fixture\OrderInjectable;
12+
use Magento\Sales\Test\Page\OrderHistory;
13+
use Magento\Mtf\Constraint\AbstractConstraint;
14+
use Magento\Mtf\ObjectManager;
15+
16+
/**
17+
* Assert that "Reorder" button is absent in Orders grid on frontend.
18+
*/
19+
class AssertReorderButtonIsNotVisibleOnFrontend extends AbstractConstraint
20+
{
21+
/* tags */
22+
const SEVERITY = 'low';
23+
/* end tags */
24+
25+
/**
26+
* Assert that "Reorder" button is absent in Orders grid on frontend.
27+
*
28+
* @param OrderInjectable $order
29+
* @param Customer $customer
30+
* @param ObjectManager $objectManager
31+
* @param CustomerAccountIndex $customerAccountIndex
32+
* @param OrderHistory $orderHistory
33+
* @param string $status
34+
* @param string $orderId
35+
* @param string|null $statusToCheck
36+
* @return void
37+
*/
38+
public function processAssert(
39+
OrderInjectable $order,
40+
Customer $customer,
41+
ObjectManager $objectManager,
42+
CustomerAccountIndex $customerAccountIndex,
43+
OrderHistory $orderHistory,
44+
$status = null,
45+
$orderId = '',
46+
$statusToCheck = null
47+
) {
48+
$filter = [
49+
'id' => $order->hasData('id') ? $order->getId() : $orderId,
50+
'status' => $statusToCheck === null ? $status : $statusToCheck,
51+
];
52+
53+
$objectManager->create(
54+
\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class,
55+
['customer' => $customer]
56+
)->run();
57+
$customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders');
58+
$errorMessage = implode(', ', $filter);
59+
\PHPUnit_Framework_Assert::assertFalse(
60+
$orderHistory->getOrderHistoryBlock()->isReorderButtonPresentByOrderId($filter['id']),
61+
'"Reorder" button for order with following data \'' . $errorMessage . '\' is present in Orders block on frontend.'
62+
);
63+
}
64+
65+
/**
66+
* Returns a string representation of the object.
67+
*
68+
* @return string
69+
*/
70+
public function toString()
71+
{
72+
return '"Reorder" button is not present in orders on frontend.';
73+
}
74+
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,21 @@
165165
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
166166
<constraint name="Magento\Catalog\Test\Constraint\AssertProductsOutOfStock" />
167167
</variation>
168+
<variation name="CreateOrderBackendTestVariation19" summary="'Reorder' button is not visible for customer if ordered item is out of stock" ticketId="MAGETWO-63924">
169+
<data name="products/0" xsi:type="string">catalogProductSimple::default_qty_1</data>
170+
<data name="customer/dataset" xsi:type="string">default</data>
171+
<data name="billingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
172+
<data name="saveAddress" xsi:type="string">No</data>
173+
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
174+
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
175+
<data name="prices" xsi:type="array">
176+
<item name="grandTotal" xsi:type="string">565.00</item>
177+
</data>
178+
<data name="payment/method" xsi:type="string">cashondelivery</data>
179+
<data name="configData" xsi:type="string">cashondelivery</data>
180+
<constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" />
181+
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
182+
<constraint name="Magento\Sales\Test\Constraint\AssertReorderButtonIsNotVisibleOnFrontend" />
183+
</variation>
168184
</testCase>
169185
</config>

0 commit comments

Comments
 (0)