Skip to content

Commit 92d97a5

Browse files
committed
Merge branch 'MAGETWO-60352' of github.com:magento-troll/magento2ce into PR_Troll
2 parents c17c5df + c473fc6 commit 92d97a5

File tree

4 files changed

+106
-1
lines changed

4 files changed

+106
-1
lines changed

app/code/Magento/Checkout/Controller/Cart/CouponPost.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ public function execute()
124124
$escaper->escapeHtml($couponCode)
125125
)
126126
);
127-
$this->cart->save();
128127
}
129128
}
130129
} else {

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/CartTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,31 @@ private function _getQuoteItemIdByProductId(\Magento\Quote\Model\Quote $quote, $
6464
}
6565
return null;
6666
}
67+
68+
/**
69+
* Test for \Magento\Checkout\Controller\Cart\CouponPost::execute() with configurable product with last option
70+
* Covers MAGETWO-60352
71+
*
72+
* @magentoDataFixture Magento/ConfigurableProduct/_files/quote_with_configurable_product_last_variation.php
73+
*/
74+
public function testExecuteForConfigurableLastOption()
75+
{
76+
/** @var $session \Magento\Checkout\Model\Session */
77+
$session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
78+
$quote = $session->getQuote();
79+
$quote->setData('trigger_recollect', 1)->setTotalsCollectedFlag(true);
80+
$inputData = [
81+
'remove' => 0,
82+
'coupon_code' => 'test'
83+
];
84+
$this->getRequest()->setPostValue($inputData);
85+
$this->dispatch(
86+
'checkout/cart/couponPost/'
87+
);
88+
89+
$this->assertSessionMessages(
90+
$this->equalTo(['The coupon code "test" is not valid.']),
91+
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
92+
);
93+
}
6794
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
// @codingStandardsIgnoreFile
8+
9+
require __DIR__ . '/configurable_products.php';
10+
11+
/** @var \Magento\Quote\Model\Quote $quote */
12+
$quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Quote\Model\Quote::class);
13+
14+
$product = $productRepository->getById(10);
15+
$product->setStockData(['use_config_manage_stock' => 1, 'qty' => 1, 'is_qty_decimal' => 0, 'is_in_stock' => 1]);
16+
$productRepository->save($product);
17+
18+
$product = $productRepository->getById(20);
19+
$product->setStockData(['use_config_manage_stock' => 1, 'qty' => 0, 'is_qty_decimal' => 0, 'is_in_stock' => 0]);
20+
$productRepository->save($product);
21+
22+
/** @var \Magento\Quote\Model\Quote $quote */
23+
$quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Quote\Model\Quote::class);
24+
$request = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Framework\DataObject::class);
25+
26+
/** @var \Magento\Eav\Model\Config $eavConfig */
27+
$eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
28+
/** @var $attribute */
29+
$attribute = $eavConfig->getAttribute('catalog_product', 'test_configurable');
30+
31+
$request->setData(
32+
[
33+
'product_id' => $productRepository->get('configurable')->getId(),
34+
'selected_configurable_option' => '1',
35+
'super_attribute' => [
36+
$attribute->getAttributeId() => $attribute->getOptions()[1]->getValue()
37+
],
38+
'qty' => '1'
39+
]
40+
);
41+
42+
$quote->setStoreId(
43+
1
44+
)->setIsActive(
45+
true
46+
)->setIsMultiShipping(
47+
false
48+
)->setReservedOrderId(
49+
'test_order_with_configurable_product'
50+
)->setEmail(
51+
'store@example.com'
52+
)->addProduct(
53+
$productRepository->get('configurable'),
54+
$request
55+
);
56+
57+
/** @var \Magento\Quote\Model\QuoteRepository $quoteRepository */
58+
$quoteRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
59+
\Magento\Quote\Model\QuoteRepository::class
60+
);
61+
$quote->collectTotals();
62+
$quoteRepository->save($quote);
63+
64+
/** @var \Magento\Checkout\Model\Session $session */
65+
$session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
66+
\Magento\Checkout\Model\Session::class
67+
);
68+
$session->setQuoteId($quote->getId());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* Rollback for quote_with_configurable_product_last_variation.php fixture.
4+
*
5+
* Copyright © Magento, Inc. All rights reserved.
6+
* See COPYING.txt for license details.
7+
*/
8+
/** @var $objectManager \Magento\TestFramework\ObjectManager */
9+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
10+
$quote = $objectManager->create(\Magento\Quote\Model\Quote::class);
11+
$quote->load('test_order_with_configurable_product', 'reserved_order_id')->delete();

0 commit comments

Comments
 (0)