Skip to content

Commit 9593330

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-33527
2 parents b90dafd + 385f475 commit 9593330

File tree

9 files changed

+185
-28
lines changed

9 files changed

+185
-28
lines changed

app/code/Magento/Customer/Model/Resource/GroupRepository.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public function getList(SearchCriteriaInterface $searchCriteria)
164164

165165
/** @var \Magento\Customer\Model\Resource\Group\Collection $collection */
166166
$collection = $this->groupFactory->create()->getCollection();
167+
$collection->addTaxClass();
167168

168169
//Add filters from root filter group to the collection
169170
/** @var FilterGroup $group */
@@ -234,6 +235,8 @@ protected function translateField($field)
234235
return 'customer_group_code';
235236
case GroupInterface::ID:
236237
return 'customer_group_id';
238+
case GroupInterface::TAX_CLASS_NAME:
239+
return 'class_name';
237240
default:
238241
return $field;
239242
}

app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function testGetCurrentStatus($status, $lastLoginAt, $lastVisitAt, $lastL
171171
'customer/online_customers/online_minutes_interval',
172172
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
173173
)
174-
->willReturn(60); //TODO: it's value mocked because unit tests run data providers before all testsuite
174+
->willReturn(240); //TODO: it's value mocked because unit tests run data providers before all testsuite
175175

176176
$this->customerLog->expects($this->any())->method('getLastLoginAt')->willReturn($lastLoginAt);
177177
$this->customerLog->expects($this->any())->method('getLastVisitAt')->willReturn($lastVisitAt);

app/code/Magento/Wishlist/Controller/Index/Cart.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ class Cart extends Action\Action implements IndexInterface
3636
*/
3737
protected $cart;
3838

39+
/**
40+
* @var \Magento\Checkout\Helper\Cart
41+
*/
42+
protected $cartHelper;
43+
44+
/**
45+
* @var \Magento\Framework\Json\Helper\Data
46+
*/
47+
protected $jsonHelper;
48+
3949
/**
4050
* @var \Magento\Wishlist\Model\Item\OptionFactory
4151
*/
@@ -66,6 +76,10 @@ class Cart extends Action\Action implements IndexInterface
6676
* @param \Magento\Catalog\Helper\Product $productHelper
6777
* @param \Magento\Framework\Escaper $escaper
6878
* @param \Magento\Wishlist\Helper\Data $helper
79+
* @param \Magento\Checkout\Helper\Cart $cartHelper
80+
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
81+
*
82+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6983
*/
7084
public function __construct(
7185
Action\Context $context,
@@ -76,7 +90,9 @@ public function __construct(
7690
\Magento\Wishlist\Model\Item\OptionFactory $optionFactory,
7791
\Magento\Catalog\Helper\Product $productHelper,
7892
\Magento\Framework\Escaper $escaper,
79-
\Magento\Wishlist\Helper\Data $helper
93+
\Magento\Wishlist\Helper\Data $helper,
94+
\Magento\Checkout\Helper\Cart $cartHelper,
95+
\Magento\Framework\Json\Helper\Data $jsonHelper
8096
) {
8197
$this->wishlistProvider = $wishlistProvider;
8298
$this->quantityProcessor = $quantityProcessor;
@@ -86,6 +102,8 @@ public function __construct(
86102
$this->productHelper = $productHelper;
87103
$this->escaper = $escaper;
88104
$this->helper = $helper;
105+
$this->cartHelper = $cartHelper;
106+
$this->jsonHelper = $jsonHelper;
89107
parent::__construct($context);
90108
}
91109

@@ -159,8 +177,8 @@ public function execute()
159177
$this->messageManager->addSuccess($message);
160178
}
161179

162-
if ($this->cart->getShouldRedirectToCart()) {
163-
$redirectUrl = $this->cart->getCartUrl();
180+
if ($this->cartHelper->getShouldRedirectToCart()) {
181+
$redirectUrl = $this->cartHelper->getCartUrl();
164182
} else {
165183
$refererUrl = $this->_redirect->getRefererUrl();
166184
if ($refererUrl && $refererUrl != $configureUrl) {
@@ -178,6 +196,13 @@ public function execute()
178196

179197
$this->helper->calculate();
180198

199+
if ($this->getRequest()->isAjax()) {
200+
$this->getResponse()->representJson(
201+
$this->jsonHelper->jsonEncode(['backUrl' => $redirectUrl])
202+
);
203+
return;
204+
}
205+
181206
return $this->getResponse()->setRedirect($redirectUrl);
182207
}
183208
}

app/code/Magento/Wishlist/Test/Unit/Controller/Index/CartTest.php

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ class CartTest extends \PHPUnit_Framework_TestCase
9696
*/
9797
protected $urlMock;
9898

99+
/**
100+
* @var \Magento\Checkout\Helper\Cart|\PHPUnit_Framework_MockObject_MockObject
101+
*/
102+
protected $cartHelperMock;
103+
104+
/**
105+
* @var \Magento\Framework\Json\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
106+
*/
107+
protected $jsonHelperMock;
108+
99109
/**
100110
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
101111
*/
@@ -139,12 +149,12 @@ protected function setUp()
139149

140150
$this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
141151
->disableOriginalConstructor()
142-
->setMethods(['getParams', 'getParam'])
152+
->setMethods(['getParams', 'getParam', 'isAjax'])
143153
->getMockForAbstractClass();
144154

145155
$this->responseMock = $this->getMockBuilder('Magento\Framework\App\ResponseInterface')
146156
->disableOriginalConstructor()
147-
->setMethods(['setRedirect'])
157+
->setMethods(['setRedirect', 'representJson'])
148158
->getMockForAbstractClass();
149159

150160
$this->redirectMock = $this->getMockBuilder('Magento\Framework\App\Response\RedirectInterface')
@@ -187,6 +197,14 @@ protected function setUp()
187197
->method('getUrl')
188198
->will($this->returnValue($this->urlMock));
189199

200+
$this->cartHelperMock = $this->getMockBuilder('Magento\Checkout\Helper\Cart')
201+
->disableOriginalConstructor()
202+
->getMock();
203+
204+
$this->jsonHelperMock = $this->getMockBuilder('Magento\Framework\Json\Helper\Data')
205+
->disableOriginalConstructor()
206+
->getMock();
207+
190208
$this->model = new Cart(
191209
$this->contextMock,
192210
$this->wishlistProviderMock,
@@ -196,7 +214,9 @@ protected function setUp()
196214
$this->optionFactoryMock,
197215
$this->productHelperMock,
198216
$this->escaperMock,
199-
$this->helperMock
217+
$this->helperMock,
218+
$this->cartHelperMock,
219+
$this->jsonHelperMock
200220
);
201221
}
202222

@@ -275,9 +295,13 @@ public function testExecuteWithNoWishlist()
275295
}
276296

277297
/**
298+
* @param bool $isAjax
299+
*
300+
* @dataProvider dataProviderExecuteWithQuantityArray
301+
*
278302
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
279303
*/
280-
public function testExecuteWithQuantityArray()
304+
public function testExecuteWithQuantityArray($isAjax)
281305
{
282306
$itemId = 2;
283307
$wishlistId = 1;
@@ -397,6 +421,9 @@ public function testExecuteWithQuantityArray()
397421
$this->requestMock->expects($this->once())
398422
->method('getParams')
399423
->willReturn($params);
424+
$this->requestMock->expects($this->once())
425+
->method('isAjax')
426+
->willReturn($isAjax);
400427

401428
$buyRequestMock = $this->getMockBuilder('Magento\Framework\Object')
402429
->disableOriginalConstructor()
@@ -467,7 +494,7 @@ public function testExecuteWithQuantityArray()
467494
->with('You added ' . $productName . ' to your shopping cart.', null)
468495
->willReturnSelf();
469496

470-
$this->checkoutCartMock->expects($this->once())
497+
$this->cartHelperMock->expects($this->once())
471498
->method('getShouldRedirectToCart')
472499
->willReturn(false);
473500

@@ -479,12 +506,33 @@ public function testExecuteWithQuantityArray()
479506
->method('calculate')
480507
->willReturnSelf();
481508

482-
$this->responseMock->expects($this->once())
509+
$this->jsonHelperMock->expects($this->any())
510+
->method('jsonEncode')
511+
->with(['backUrl' => $refererUrl])
512+
->willReturn('{"backUrl":"' . $refererUrl . '"}');
513+
514+
$this->responseMock->expects($this->any())
483515
->method('setRedirect')
484516
->with($refererUrl)
485517
->willReturn($this->responseMock);
518+
$this->responseMock->expects($this->any())
519+
->method('representJson')
520+
->with('{"backUrl":"' . $refererUrl . '"}')
521+
->willReturnSelf();
486522

487-
$this->assertEquals($this->responseMock, $this->model->execute());
523+
$expectedResult = ($isAjax ? null : $this->responseMock);
524+
$this->assertEquals($expectedResult, $this->model->execute());
525+
}
526+
527+
/**
528+
* @return array
529+
*/
530+
public function dataProviderExecuteWithQuantityArray()
531+
{
532+
return [
533+
['isAjax' => false],
534+
['isAjax' => true],
535+
];
488536
}
489537

490538
/**

app/code/Magento/Wishlist/view/frontend/templates/view.phtml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
<?php echo($block->getChildHtml('wishlist.rss.link'));?>
1414
<form class="form-wishlist-items" id="wishlist-view-form"
1515
data-mage-init='{"wishlist":{
16-
"dataAttribute":"item-id",
17-
"nameFormat":"qty[{0}]",
18-
"btnRemoveSelector":".action.delete",
19-
"qtySelector":".qty",
20-
"addToCartSelector":".action.tocart",
21-
"addAllToCartSelector":".primary > .action.tocart",
22-
"commentInputType":"textarea",
23-
"infoList":false,
2416
"addToCartUrl":"<?php echo $block->getItemAddToCartUrl("%item%");?>",
2517
"confirmRemoveMessage":"<?php echo __("Are you sure you want to remove this product from your wishlist?") ?>",
2618
"addAllToCartUrl":"<?php echo $block->getAddAllToCartUrl(); ?>",

app/code/Magento/Wishlist/view/frontend/web/wishlist.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,11 @@ define([
8181
var itemId = elem.data(this.options.dataAttribute),
8282
url = this.options.addToCartUrl.replace('%item%', itemId),
8383
inputName = $.validator.format(this.options.nameFormat, itemId),
84-
inputValue = elem.parent().find('[name="' + inputName + '"]').val(),
84+
inputValue = $('[name="' + inputName + '"]').val(),
8585
separator = (url.indexOf('?') >= 0) ? '&' : '?';
8686
url += separator + inputName + '=' + encodeURIComponent(inputValue);
8787
this._validateAndRedirect(url);
8888
}
89-
9089
},
9190

9291
/**

dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct/Associated.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,19 @@ protected function getPreset($name)
198198
'id' => '%id%',
199199
'name' => '%item1_simple::getProductName%',
200200
'position' => '%position%',
201-
'qty' => 17,
201+
'qty' => 3,
202202
],
203203
[
204204
'id' => '%id%',
205205
'name' => '%item1_simple::getProductName%',
206206
'position' => '%position%',
207-
'qty' => 36,
207+
'qty' => 1,
208208
],
209209
[
210210
'id' => '%id%',
211211
'name' => '%item1_simple::getProductName%',
212212
'position' => '%position%',
213-
'qty' => 20,
213+
'qty' => 2,
214214
],
215215
],
216216
'products' => [

dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,24 @@
3333
<constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" />
3434
</variation>
3535
<variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation5">
36-
<data name="issue" xsi:type="string">Bug: MAGETWO-36224</data>
3736
<data name="products" xsi:type="string">downloadableProduct::with_two_separately_links</data>
3837
<data name="qty" xsi:type="string">-</data>
3938
<constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" />
4039
<constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" />
4140
</variation>
4241
<variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation6">
43-
<data name="issue" xsi:type="string">Bug: MAGETWO-36224</data>
4442
<data name="products" xsi:type="string">configurableProduct::default</data>
4543
<data name="qty" xsi:type="string">3</data>
4644
<constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" />
4745
<constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" />
4846
</variation>
4947
<variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation7">
50-
<data name="issue" xsi:type="string">Bug: MAGETWO-36224</data>
5148
<data name="products" xsi:type="string">bundleProduct::bundle_dynamic_product</data>
5249
<data name="qty" xsi:type="string">2</data>
5350
<constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" />
5451
<constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" />
5552
</variation>
5653
<variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation8">
57-
<data name="issue" xsi:type="string">Bug: MAGETWO-36224</data>
5854
<data name="products" xsi:type="string">bundleProduct::bundle_fixed_product</data>
5955
<data name="qty" xsi:type="string">2</data>
6056
<constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" />

0 commit comments

Comments
 (0)