Skip to content

Commit ab051bf

Browse files
author
Shkolyarenko, Serhiy(sshkolyarenko)
committed
Merge pull request #494 from magento-folks/bugs
[Folks]Bugfixes
2 parents 06c96e9 + 903407a commit ab051bf

File tree

25 files changed

+565
-66
lines changed

25 files changed

+565
-66
lines changed

app/code/Magento/Catalog/Model/Product/Link/Converter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Converter
1919
protected function indexBySku(array $products)
2020
{
2121
$converted = [];
22-
foreach($products as $product) {
22+
foreach ($products as $product) {
2323
$converted[$product->getSku()] = $product;
2424
}
2525
return $converted;
@@ -34,7 +34,7 @@ public function convertLinksToGroupedArray($entity)
3434
$basicData = $entity->getProductLinks();
3535
$associatedProducts = $entity->getTypeInstance()->getAssociatedProducts($entity);
3636
$associatedProducts = $this->indexBySku($associatedProducts);
37-
37+
$linksAsArray = [];
3838
/** @var \Magento\Catalog\Api\Data\ProductLinkInterface $link */
3939
foreach ($basicData as $link) {
4040
$info = $link->getData();
@@ -46,4 +46,4 @@ public function convertLinksToGroupedArray($entity)
4646
}
4747
return $linksAsArray;
4848
}
49-
}
49+
}

app/code/Magento/Catalog/Model/Product/Link/Resolver.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ class Resolver
1717
*/
1818
protected $links = null;
1919

20+
/**
21+
* Resolver constructor.
22+
* @param \Magento\Framework\App\RequestInterface $request
23+
*/
2024
public function __construct(
2125
\Magento\Framework\App\RequestInterface $request
2226
) {
2327
$this->request = $request;
2428
}
2529

26-
2730
/**
2831
* Get stored value.
2932
* Fallback to request if none.
@@ -42,6 +45,7 @@ public function getLinks()
4245
* Override link data from request
4346
*
4447
* @param array|null $links
48+
* @return void
4549
*/
4650
public function override($links)
4751
{
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Test\Unit\Model\Product\Link;
7+
8+
use Magento\Catalog\Model\Product\Link\Converter;
9+
10+
class ConverterTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/**
13+
* @var Converter
14+
*/
15+
protected $converter;
16+
17+
protected function setUp()
18+
{
19+
$this->converter = new Converter();
20+
}
21+
22+
public function testConvertLinksToGroupedArray()
23+
{
24+
$linkedProductSku = 'linkedProductSample';
25+
$linkedProductId = '2016';
26+
$linkType = 'associated';
27+
$linkMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductLinkInterface::class)
28+
->disableOriginalConstructor()
29+
->setMethods(['getData', 'getLinkType', 'getLinkedProductSku', 'getExtensionAttributes'])
30+
->getMockForAbstractClass();
31+
$basicData = [$linkMock];
32+
$linkedProductMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
33+
->disableOriginalConstructor()
34+
->getMock();
35+
$associatedProducts = [$linkedProductSku => $linkedProductMock];
36+
$info = [100, 300, 500];
37+
$infoFinal = [100, 300, 500, 'id' => $linkedProductId, 'qty' => 33];
38+
$linksAsArray = [$linkType => [$infoFinal]];
39+
40+
$typeMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\AbstractType::class)
41+
->setMethods(['getAssociatedProducts'])
42+
->disableOriginalConstructor()
43+
->getMockForAbstractClass();
44+
45+
$productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
46+
->disableOriginalConstructor()
47+
->getMock();
48+
$productMock->expects($this->once())
49+
->method('getProductLinks')
50+
->willReturn($basicData);
51+
$productMock->expects($this->once())
52+
->method('getTypeInstance')
53+
->willReturn($typeMock);
54+
$typeMock->expects($this->once())
55+
->method('getAssociatedProducts')
56+
->with($productMock)
57+
->willReturn($associatedProducts);
58+
$linkedProductMock->expects($this->once())
59+
->method('getSku')
60+
->willReturn($linkedProductSku);
61+
$linkMock->expects($this->once())
62+
->method('getData')
63+
->willReturn($info);
64+
$linkMock->expects($this->exactly(2))
65+
->method('getLinkType')
66+
->willReturn($linkType);
67+
$linkMock->expects($this->once())
68+
->method('getLinkedProductSku')
69+
->willReturn($linkedProductSku);
70+
$linkedProductMock->expects($this->once())
71+
->method('getId')
72+
->willReturn($linkedProductId);
73+
$attributeMock = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttributesInterface::class)
74+
->setMethods(['__toArray'])
75+
->getMockForAbstractClass();
76+
$linkMock->expects($this->once())
77+
->method('getExtensionAttributes')
78+
->willReturn($attributeMock);
79+
$attributeMock->expects($this->once())
80+
->method('__toArray')
81+
->willReturn(['qty' => 33]);
82+
83+
$this->assertEquals($linksAsArray, $this->converter->convertLinksToGroupedArray($productMock));
84+
}
85+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Test\Unit\Model\Product\Link;
7+
8+
use Magento\Catalog\Model\Product\Link\Resolver;
9+
10+
class ResolverTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/**
13+
* @var \PHPUnit_Framework_MockObject_MockObject
14+
*/
15+
protected $requestMock;
16+
17+
/**
18+
* @var Resolver
19+
*/
20+
protected $resolver;
21+
22+
protected function setUp()
23+
{
24+
$this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
25+
->getMockForAbstractClass();
26+
27+
$this->resolver = new Resolver($this->requestMock);
28+
}
29+
30+
public function testGetLinksEmpty()
31+
{
32+
$someLinks = [1, 2, 3];
33+
$this->requestMock->expects($this->once())
34+
->method('getParam')
35+
->with('links', [])
36+
->willReturn($someLinks);
37+
$this->assertEquals($someLinks, $this->resolver->getLinks());
38+
39+
}
40+
41+
public function testGetLinksOverridden()
42+
{
43+
$overriddenLinks = [3, 5, 7];
44+
$this->requestMock->expects($this->never())
45+
->method('getParam');
46+
47+
$this->resolver->override($overriddenLinks);
48+
$this->assertEquals($overriddenLinks, $this->resolver->getLinks());
49+
50+
}
51+
}

app/code/Magento/Checkout/Block/Shipping/Price.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
use Magento\Framework\Pricing\PriceCurrencyInterface;
1010
use Magento\Quote\Model\Quote\Address\Rate;
1111

12+
/**
13+
* Class Price
14+
* @deprecated
15+
*/
1216
class Price extends AbstractCart
1317
{
1418
/**

app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<update handle="checkout_cart_item_renderers"/>
10-
<update handle="checkout_shipping_price_renderer"/>
1110
<body>
1211
<referenceContainer name="page.messages">
1312
<block class="Magento\Checkout\Block\Cart\ValidationMessages" name="checkout.cart.validationmessages"/>

app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<item name="subtotal" xsi:type="array">
1919
<item name="children" xsi:type="array">
2020
<item name="subtotal.totals" xsi:type="array">
21-
<item name="component" xsi:type="string">uiComponent</item>
21+
<item name="component" xsi:type="string">Magento_Checkout/js/view/checkout/minicart/subtotal/totals</item>
2222
<item name="config" xsi:type="array">
2323
<item name="template" xsi:type="string">Magento_Checkout/minicart/subtotal/totals</item>
2424
</item>

app/code/Magento/Checkout/view/frontend/layout/checkout_shipping_price_renderer.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ define(
107107
*/
108108
objectToArray: function (object) {
109109
var convertedArray = [];
110+
110111
$.each(object, function (key) {
111-
return object[key].length ? convertedArray.push(object[key]) : false;
112+
return typeof object[key] === 'string' ? convertedArray.push(object[key]) : false;
112113
});
113114

114115
return convertedArray.slice(0);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright © 2016 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'ko',
7+
'uiComponent',
8+
'Magento_Customer/js/customer-data'
9+
], function (ko, Component, customerData) {
10+
'use strict';
11+
12+
return Component.extend({
13+
displaySubtotal: ko.observable(true),
14+
15+
/**
16+
* @override
17+
*/
18+
initialize: function () {
19+
this._super();
20+
this.cart = customerData.get('cart');
21+
}
22+
});
23+
});

0 commit comments

Comments
 (0)