Skip to content

Commit 91335c2

Browse files
committed
Merge branch 'develop' of github.com:magento/magento2ce into TrollPR
2 parents 2509aa0 + 711ad81 commit 91335c2

File tree

7 files changed

+294
-54
lines changed

7 files changed

+294
-54
lines changed

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ protected function setUp()
5656
$this->productMock = $this->getMockBuilder(ProductInterface::class)
5757
->setMethods([
5858
'getId',
59+
'getTypeId',
5960
'getStoreId',
6061
'getResource',
6162
'getData',

app/code/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionsProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getProducts(ProductInterface $product)
6363
);
6464

6565
$this->linkedProductMap[$product->getId()] = $this->collectionFactory->create()
66-
->addAttributeToSelect(['price', 'special_price'])
66+
->addAttributeToSelect(['price', 'special_price', 'special_from_date', 'special_to_date'])
6767
->addIdFilter($productIds)
6868
->getItems();
6969
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\ConfigurableProduct\Test\Unit\Pricing\Price;
8+
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
10+
use Magento\Catalog\Api\Data\ProductInterface;
11+
use Magento\Catalog\Model\ResourceModel\Product\LinkedProductSelectBuilderInterface;
12+
13+
class LowestPriceOptionsProviderTest extends \PHPUnit_Framework_TestCase
14+
{
15+
/**
16+
* @var \Magento\ConfigurableProduct\Pricing\Price\LowestPriceOptionsProvider
17+
*/
18+
private $model;
19+
20+
/**
21+
* @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
22+
*/
23+
private $resourceConnection;
24+
25+
/**
26+
* @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
27+
*/
28+
protected $connection;
29+
30+
/**
31+
* @var LinkedProductSelectBuilderInterface|\PHPUnit_Framework_MockObject_MockObject
32+
*/
33+
private $linkedProductSelectBuilder;
34+
35+
/**
36+
* @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
37+
*/
38+
private $collectionFactory;
39+
40+
/**
41+
* @var \Magento\Catalog\Model\ResourceModel\Product\Collection|\PHPUnit_Framework_MockObject_MockObject
42+
*/
43+
private $productCollection;
44+
45+
protected function setUp()
46+
{
47+
$this->connection = $this
48+
->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
49+
->getMock();
50+
$this->resourceConnection = $this
51+
->getMockBuilder(\Magento\Framework\App\ResourceConnection::class)
52+
->disableOriginalConstructor()
53+
->setMethods(['getConnection'])
54+
->getMock();
55+
$this->resourceConnection->expects($this->once())->method('getConnection')->willReturn($this->connection);
56+
$this->linkedProductSelectBuilder = $this
57+
->getMockBuilder(LinkedProductSelectBuilderInterface::class)
58+
->setMethods(['build'])
59+
->getMock();
60+
$this->productCollection = $this
61+
->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class)
62+
->disableOriginalConstructor()
63+
->setMethods(['addAttributeToSelect', 'addIdFilter', 'getItems'])
64+
->getMock();
65+
$this->collectionFactory = $this
66+
->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class)
67+
->disableOriginalConstructor()
68+
->setMethods(['create'])
69+
->getMock();
70+
$this->collectionFactory->expects($this->once())->method('create')->willReturn($this->productCollection);
71+
72+
$objectManager = new ObjectManager($this);
73+
$this->model = $objectManager->getObject(
74+
\Magento\ConfigurableProduct\Pricing\Price\LowestPriceOptionsProvider::class,
75+
[
76+
'resourceConnection' => $this->resourceConnection,
77+
'linkedProductSelectBuilder' => $this->linkedProductSelectBuilder,
78+
'collectionFactory' => $this->collectionFactory,
79+
]
80+
);
81+
}
82+
83+
public function testGetProducts()
84+
{
85+
$productId = 1;
86+
$linkedProducts = ['some', 'linked', 'products', 'dataobjects'];
87+
$product = $this->getMockBuilder(ProductInterface::class)->disableOriginalConstructor()->getMock();
88+
$product->expects($this->any())->method('getId')->willReturn($productId);
89+
$this->linkedProductSelectBuilder->expects($this->any())->method('build')->with($productId)->willReturn([]);
90+
$this->productCollection
91+
->expects($this->once())
92+
->method('addAttributeToSelect')
93+
->with(['price', 'special_price', 'special_from_date', 'special_to_date'])
94+
->willReturnSelf();
95+
$this->productCollection->expects($this->once())->method('addIdFilter')->willReturnSelf();
96+
$this->productCollection->expects($this->once())->method('getItems')->willReturn($linkedProducts);
97+
98+
$this->assertEquals($linkedProducts, $this->model->getProducts($product));
99+
}
100+
}

app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurablePriceTest.php

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,106 @@ class ConfigurablePriceTest extends AbstractModifierTest
1515
*/
1616
protected function createModel()
1717
{
18-
return $this->objectManager->getObject(ConfigurablePriceModifier::class);
18+
return $this->objectManager->getObject(ConfigurablePriceModifier::class, ['locator' => $this->locatorMock]);
1919
}
2020

21-
public function testModifyMeta()
21+
/**
22+
* @param array $metaInput
23+
* @param array $metaOutput
24+
* @dataProvider metaDataProvider
25+
*/
26+
public function testModifyMeta($metaInput, $metaOutput)
2227
{
23-
$meta = ['initial' => 'meta'];
28+
$this->productMock->expects($this->any())
29+
->method('getTypeId')
30+
->willReturn(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE);
31+
32+
$metaResult = $this->getModel()->modifyMeta($metaInput);
33+
$this->assertEquals($metaResult, $metaOutput);
34+
}
2435

25-
$this->assertArrayHasKey('initial', $this->getModel()->modifyMeta($meta));
36+
/**
37+
* @return array
38+
*/
39+
public function metaDataProvider()
40+
{
41+
return [
42+
[
43+
'metaInput' => [
44+
'pruduct-details' => [
45+
'children' => [
46+
'container_price' => [
47+
'children' => [
48+
'advanced_pricing_button' => [
49+
'arguments' => []
50+
]
51+
]
52+
]
53+
]
54+
]
55+
],
56+
'metaOutput' => [
57+
'pruduct-details' => [
58+
'children' => [
59+
'container_price' => [
60+
'children' => [
61+
'advanced_pricing_button' => [
62+
'arguments' => [
63+
'data' => [
64+
'config' => [
65+
'visible' => 0,
66+
'disabled' => 1,
67+
'componentType' => 'container'
68+
],
69+
],
70+
],
71+
],
72+
'price' => [
73+
'arguments' => [
74+
'data' => [
75+
'config' => [
76+
'component' =>
77+
'Magento_ConfigurableProduct/js/components/price-configurable'
78+
],
79+
],
80+
],
81+
],
82+
],
83+
],
84+
],
85+
]
86+
]
87+
], [
88+
'metaInput' => [
89+
'pruduct-details' => [
90+
'children' => [
91+
'container_price' => [
92+
'children' => []
93+
]
94+
]
95+
]
96+
],
97+
'metaOutput' => [
98+
'pruduct-details' => [
99+
'children' => [
100+
'container_price' => [
101+
'children' => [
102+
'price' => [
103+
'arguments' => [
104+
'data' => [
105+
'config' => [
106+
'component' =>
107+
'Magento_ConfigurableProduct/js/components/price-configurable'
108+
]
109+
]
110+
]
111+
]
112+
]
113+
]
114+
]
115+
]
116+
]
117+
]
118+
];
26119
}
27120
}

app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePrice.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ public function modifyData(array $data)
4949
*/
5050
public function modifyMeta(array $meta)
5151
{
52-
if ($groupCode = $this->getGroupCodeByField($meta, ProductAttributeInterface::CODE_PRICE)
53-
?: $this->getGroupCodeByField($meta, self::CODE_GROUP_PRICE)
54-
) {
52+
$groupCode = $this->getGroupCodeByField($meta, ProductAttributeInterface::CODE_PRICE)
53+
?: $this->getGroupCodeByField($meta, self::CODE_GROUP_PRICE);
54+
55+
if ($groupCode && !empty($meta[$groupCode]['children'][self::CODE_GROUP_PRICE])) {
5556
if (!empty($meta[$groupCode]['children'][self::CODE_GROUP_PRICE])) {
5657
$meta[$groupCode]['children'][self::CODE_GROUP_PRICE] = array_replace_recursive(
5758
$meta[$groupCode]['children'][self::CODE_GROUP_PRICE],
@@ -71,7 +72,9 @@ public function modifyMeta(array $meta)
7172
]
7273
);
7374
}
74-
if (!empty($meta[$groupCode]['children'][self::CODE_GROUP_PRICE])) {
75+
if (
76+
!empty($meta[$groupCode]['children'][self::CODE_GROUP_PRICE]['children'][self::$advancedPricingButton])
77+
) {
7578
$productTypeId = $this->locator->getProduct()->getTypeId();
7679
$visibilityConfig = ($productTypeId === ConfigurableType::TYPE_CODE)
7780
? ['visible' => 0, 'disabled' => 1]
@@ -81,17 +84,16 @@ public function modifyMeta(array $meta)
8184
. ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty',
8285
]
8386
];
87+
$config = $visibilityConfig;
88+
$config['componentType'] = 'container';
8489
$meta[$groupCode]['children'][self::CODE_GROUP_PRICE] = array_replace_recursive(
8590
$meta[$groupCode]['children'][self::CODE_GROUP_PRICE],
8691
[
8792
'children' => [
8893
self::$advancedPricingButton => [
8994
'arguments' => [
9095
'data' => [
91-
'config' => [
92-
'componentType' => 'container',
93-
$visibilityConfig
94-
],
96+
'config' => $config,
9597
],
9698
],
9799
],

app/code/Magento/Shipping/Model/Shipping/Labels.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ public function requestToShipment(Shipment $orderShipment)
122122
|| !$storeInfo->getName()
123123
|| !$storeInfo->getPhone()
124124
|| !$originStreet1
125-
|| !$shipperRegionCode
126125
|| !$this->_scopeConfig->getValue(
127126
Shipment::XML_PATH_STORE_CITY,
128127
ScopeInterface::SCOPE_STORE,

0 commit comments

Comments
 (0)