Skip to content

Commit e150e90

Browse files
merge magento/2.3-develop into magento-helix/MAGETWO-95294-3
2 parents 9c9be75 + 3a4ba66 commit e150e90

File tree

11 files changed

+373
-32
lines changed

11 files changed

+373
-32
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Test\Unit\Ui\Component;
9+
10+
use PHPUnit\Framework\TestCase;
11+
use Magento\Catalog\Ui\Component\ColumnFactory;
12+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
13+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
14+
use Magento\Framework\View\Element\UiComponent\ContextInterface;
15+
use Magento\Framework\View\Element\UiComponentFactory;
16+
use Magento\Ui\Component\Listing\Columns\ColumnInterface;
17+
use Magento\Ui\Component\Filters\FilterModifier;
18+
19+
/**
20+
* ColumnFactory test.
21+
*/
22+
class ColumnFactoryTest extends TestCase
23+
{
24+
/**
25+
* @var ColumnFactory
26+
*/
27+
private $columnFactory;
28+
29+
/**
30+
* @var ObjectManager
31+
*/
32+
private $objectManager;
33+
34+
/**
35+
* @var ProductAttributeInterface|\PHPUnit\Framework\MockObject\MockObject
36+
*/
37+
private $attribute;
38+
39+
/**
40+
* @var ContextInterface|\PHPUnit\Framework\MockObject\MockObject
41+
*/
42+
private $context;
43+
44+
/**
45+
* @var UiComponentFactory|\PHPUnit\Framework\MockObject\MockObject
46+
*/
47+
private $uiComponentFactory;
48+
49+
/**
50+
* @var ColumnInterface|\PHPUnit\Framework\MockObject\MockObject
51+
*/
52+
private $column;
53+
54+
/**
55+
* @inheritdoc
56+
*/
57+
protected function setUp(): void
58+
{
59+
$this->objectManager = new ObjectManager($this);
60+
61+
$this->attribute = $this->getMockBuilder(ProductAttributeInterface::class)
62+
->setMethods(['usesSource'])
63+
->getMockForAbstractClass();
64+
$this->context = $this->createMock(ContextInterface::class);
65+
$this->uiComponentFactory = $this->createMock(UiComponentFactory::class);
66+
$this->column = $this->getMockForAbstractClass(ColumnInterface::class);
67+
$this->uiComponentFactory->method('create')
68+
->willReturn($this->column);
69+
70+
$this->columnFactory = $this->objectManager->getObject(ColumnFactory::class, [
71+
'componentFactory' => $this->uiComponentFactory
72+
]);
73+
}
74+
75+
/**
76+
* Tests the create method will return correct object.
77+
*
78+
* @return void
79+
*/
80+
public function testCreatedObject(): void
81+
{
82+
$this->context->method('getRequestParam')
83+
->with(FilterModifier::FILTER_MODIFIER, [])
84+
->willReturn([]);
85+
86+
$object = $this->columnFactory->create($this->attribute, $this->context);
87+
$this->assertEquals(
88+
$this->column,
89+
$object,
90+
'Object must be the same which the ui component factory creates.'
91+
);
92+
}
93+
94+
/**
95+
* Tests create method with not filterable in grid attribute.
96+
*
97+
* @param array $filterModifiers
98+
* @param null|string $filter
99+
*
100+
* @return void
101+
* @dataProvider filterModifiersProvider
102+
*/
103+
public function testCreateWithNotFilterableInGridAttribute(array $filterModifiers, ?string $filter): void
104+
{
105+
$componentFactoryArgument = [
106+
'data' => [
107+
'config' => [
108+
'label' => __(null),
109+
'dataType' => 'text',
110+
'add_field' => true,
111+
'visible' => null,
112+
'filter' => $filter,
113+
'component' => 'Magento_Ui/js/grid/columns/column',
114+
],
115+
],
116+
'context' => $this->context,
117+
];
118+
119+
$this->context->method('getRequestParam')
120+
->with(FilterModifier::FILTER_MODIFIER, [])
121+
->willReturn($filterModifiers);
122+
$this->attribute->method('getIsFilterableInGrid')
123+
->willReturn(false);
124+
$this->attribute->method('getAttributeCode')
125+
->willReturn('color');
126+
127+
$this->uiComponentFactory->expects($this->once())
128+
->method('create')
129+
->with($this->anything(), $this->anything(), $componentFactoryArgument);
130+
131+
$this->columnFactory->create($this->attribute, $this->context);
132+
}
133+
134+
/**
135+
* Filter modifiers data provider.
136+
*
137+
* @return array
138+
*/
139+
public function filterModifiersProvider(): array
140+
{
141+
return [
142+
'without' => [
143+
'filter_modifiers' => [],
144+
'filter' => null,
145+
],
146+
'with' => [
147+
'filter_modifiers' => [
148+
'color' => [
149+
'condition_type' => 'notnull',
150+
],
151+
],
152+
'filter' => 'text',
153+
],
154+
];
155+
}
156+
}

app/code/Magento/Catalog/Ui/Component/ColumnFactory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Ui\Component;
77

8+
use Magento\Ui\Component\Filters\FilterModifier;
9+
810
/**
911
* Column Factory
1012
*
@@ -60,13 +62,15 @@ public function __construct(\Magento\Framework\View\Element\UiComponentFactory $
6062
*/
6163
public function create($attribute, $context, array $config = [])
6264
{
65+
$filterModifiers = $context->getRequestParam(FilterModifier::FILTER_MODIFIER, []);
66+
6367
$columnName = $attribute->getAttributeCode();
6468
$config = array_merge([
6569
'label' => __($attribute->getDefaultFrontendLabel()),
6670
'dataType' => $this->getDataType($attribute),
6771
'add_field' => true,
6872
'visible' => $attribute->getIsVisibleInGrid(),
69-
'filter' => ($attribute->getIsFilterableInGrid())
73+
'filter' => ($attribute->getIsFilterableInGrid() || array_key_exists($columnName, $filterModifiers))
7074
? $this->getFilterType($attribute->getFrontendInput())
7175
: null,
7276
], $config);

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,9 @@ private function addAdvancedPriceLink()
389389
'componentType' => Container::NAME,
390390
'component' => 'Magento_Ui/js/form/components/button',
391391
'template' => 'ui/form/components/button/container',
392+
'imports' => [
393+
'childError' => $this->scopeName . '.advanced_pricing_modal.advanced-pricing:error',
394+
],
392395
'actions' => [
393396
[
394397
'targetName' => $this->scopeName . '.advanced_pricing_modal',

app/code/Magento/Cms/Test/Mftf/Test/StoreViewLanguageCorrectSwitchTest.xml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
<test name="StoreViewLanguageCorrectSwitchTest">
1212
<annotations>
1313
<features value="Cms"/>
14-
<stories value="Store View (language) switch leads to 404"/>
15-
<group value="Cms"/>
1614
<title value="Check that Store View(language) switches correct"/>
1715
<description value="Check that Store View(language) switches correct"/>
1816
<severity value="MAJOR"/>
1917
<testCaseId value="MAGETWO-96388"/>
2018
<useCaseId value="MAGETWO-57337"/>
19+
<group value="Cms"/>
2120
</annotations>
2221
<before>
2322
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
@@ -37,7 +36,7 @@
3736

3837
<!-- Create StoreView -->
3938
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreView">
40-
<argument name="customStore" value="NewStoreViewData"/>
39+
<argument name="customStore" value="NewStoreViewData"/>
4140
</actionGroup>
4241

4342
<!-- Add StoreView To Cms Page-->
@@ -51,10 +50,18 @@
5150
<see userInput="$$createFirstCmsPage.title$$" stepKey="seePageTitle"/>
5251

5352
<!-- Switch StoreView and check that Cms Page is open -->
54-
<click selector="{{StorefrontHeaderSection.storeViewSwitcher}}" stepKey="clickStoreViewSwitcher"/>
55-
<waitForElementVisible selector="{{StorefrontHeaderSection.storeViewDropdown}}" stepKey="waitForStoreViewDropDown"/>
56-
<click selector="{{StorefrontHeaderSection.storeViewOption(NewStoreViewData.code)}}" stepKey="selectStoreView"/>
53+
<actionGroup ref="StorefrontSwitchStoreViewActionGroup" stepKey="switchToCustomStoreView">
54+
<argument name="storeView" value="NewStoreViewData"/>
55+
</actionGroup>
5756
<amOnPage url="{{StorefrontHomePage.url}}/$$createSecondCmsPage.identifier$$" stepKey="gotToSecondCmsPage"/>
5857
<see userInput="$$createSecondCmsPage.title$$" stepKey="seePageTitle1"/>
58+
59+
<!--Open first Cms page on custom store view-->
60+
<amOnPage url="{{StorefrontHomePage.url}}/$$createFirstCmsPage.identifier$$" stepKey="gotToFirstCmsPage1"/>
61+
<see userInput="Whoops, our bad..." stepKey="seePageError"/>
62+
63+
<!--Switch to default store view and check Cms page-->
64+
<actionGroup ref="StorefrontSwitchDefaultStoreViewActionGroup" stepKey="switchToDefualtStoreView"/>
65+
<see userInput="$$createFirstCmsPage.title$$" stepKey="seePageTitle2"/>
5966
</test>
6067
</tests>

app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,26 @@
77
*/
88
namespace Magento\ConfigurableProduct\Model\Product\Type\Configurable;
99

10+
use Magento\Catalog\Model\Product;
11+
12+
/**
13+
* Class Price for configurable product
14+
*/
1015
class Price extends \Magento\Catalog\Model\Product\Type\Price
1116
{
1217
/**
13-
* Get product final price
14-
*
15-
* @param float $qty
16-
* @param \Magento\Catalog\Model\Product $product
17-
* @return float
18+
* @inheritdoc
1819
*/
1920
public function getFinalPrice($qty, $product)
2021
{
2122
if ($qty === null && $product->getCalculatedFinalPrice() !== null) {
2223
return $product->getCalculatedFinalPrice();
2324
}
2425
if ($product->getCustomOption('simple_product') && $product->getCustomOption('simple_product')->getProduct()) {
25-
$finalPrice = parent::getFinalPrice($qty, $product->getCustomOption('simple_product')->getProduct());
26+
/** @var Product $simpleProduct */
27+
$simpleProduct = $product->getCustomOption('simple_product')->getProduct();
28+
$simpleProduct->setCustomerGroupId($product->getCustomerGroupId());
29+
$finalPrice = parent::getFinalPrice($qty, $simpleProduct);
2630
} else {
2731
$priceInfo = $product->getPriceInfo();
2832
$finalPrice = $priceInfo->getPrice('final_price')->getAmount()->getValue();
@@ -35,7 +39,7 @@ public function getFinalPrice($qty, $product)
3539
}
3640

3741
/**
38-
* {@inheritdoc}
42+
* @inheritdoc
3943
*/
4044
public function getPrice($product)
4145
{
@@ -48,6 +52,7 @@ public function getPrice($product)
4852
}
4953
}
5054
}
55+
5156
return 0;
5257
}
5358
}

0 commit comments

Comments
 (0)