Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.3-develop' into feature/update…
Browse files Browse the repository at this point in the history
…-cart-items
  • Loading branch information
naydav committed Mar 6, 2019
2 parents faacfe0 + 3a4ba66 commit c9d6491
Show file tree
Hide file tree
Showing 11 changed files with 373 additions and 32 deletions.
156 changes: 156 additions & 0 deletions app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Test\Unit\Ui\Component;

use PHPUnit\Framework\TestCase;
use Magento\Catalog\Ui\Component\ColumnFactory;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\ColumnInterface;
use Magento\Ui\Component\Filters\FilterModifier;

/**
* ColumnFactory test.
*/
class ColumnFactoryTest extends TestCase
{
/**
* @var ColumnFactory
*/
private $columnFactory;

/**
* @var ObjectManager
*/
private $objectManager;

/**
* @var ProductAttributeInterface|\PHPUnit\Framework\MockObject\MockObject
*/
private $attribute;

/**
* @var ContextInterface|\PHPUnit\Framework\MockObject\MockObject
*/
private $context;

/**
* @var UiComponentFactory|\PHPUnit\Framework\MockObject\MockObject
*/
private $uiComponentFactory;

/**
* @var ColumnInterface|\PHPUnit\Framework\MockObject\MockObject
*/
private $column;

/**
* @inheritdoc
*/
protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);

$this->attribute = $this->getMockBuilder(ProductAttributeInterface::class)
->setMethods(['usesSource'])
->getMockForAbstractClass();
$this->context = $this->createMock(ContextInterface::class);
$this->uiComponentFactory = $this->createMock(UiComponentFactory::class);
$this->column = $this->getMockForAbstractClass(ColumnInterface::class);
$this->uiComponentFactory->method('create')
->willReturn($this->column);

$this->columnFactory = $this->objectManager->getObject(ColumnFactory::class, [
'componentFactory' => $this->uiComponentFactory
]);
}

/**
* Tests the create method will return correct object.
*
* @return void
*/
public function testCreatedObject(): void
{
$this->context->method('getRequestParam')
->with(FilterModifier::FILTER_MODIFIER, [])
->willReturn([]);

$object = $this->columnFactory->create($this->attribute, $this->context);
$this->assertEquals(
$this->column,
$object,
'Object must be the same which the ui component factory creates.'
);
}

/**
* Tests create method with not filterable in grid attribute.
*
* @param array $filterModifiers
* @param null|string $filter
*
* @return void
* @dataProvider filterModifiersProvider
*/
public function testCreateWithNotFilterableInGridAttribute(array $filterModifiers, ?string $filter): void
{
$componentFactoryArgument = [
'data' => [
'config' => [
'label' => __(null),
'dataType' => 'text',
'add_field' => true,
'visible' => null,
'filter' => $filter,
'component' => 'Magento_Ui/js/grid/columns/column',
],
],
'context' => $this->context,
];

$this->context->method('getRequestParam')
->with(FilterModifier::FILTER_MODIFIER, [])
->willReturn($filterModifiers);
$this->attribute->method('getIsFilterableInGrid')
->willReturn(false);
$this->attribute->method('getAttributeCode')
->willReturn('color');

$this->uiComponentFactory->expects($this->once())
->method('create')
->with($this->anything(), $this->anything(), $componentFactoryArgument);

$this->columnFactory->create($this->attribute, $this->context);
}

/**
* Filter modifiers data provider.
*
* @return array
*/
public function filterModifiersProvider(): array
{
return [
'without' => [
'filter_modifiers' => [],
'filter' => null,
],
'with' => [
'filter_modifiers' => [
'color' => [
'condition_type' => 'notnull',
],
],
'filter' => 'text',
],
];
}
}
6 changes: 5 additions & 1 deletion app/code/Magento/Catalog/Ui/Component/ColumnFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Magento\Catalog\Ui\Component;

use Magento\Ui\Component\Filters\FilterModifier;

/**
* Column Factory
*
Expand Down Expand Up @@ -60,13 +62,15 @@ public function __construct(\Magento\Framework\View\Element\UiComponentFactory $
*/
public function create($attribute, $context, array $config = [])
{
$filterModifiers = $context->getRequestParam(FilterModifier::FILTER_MODIFIER, []);

$columnName = $attribute->getAttributeCode();
$config = array_merge([
'label' => __($attribute->getDefaultFrontendLabel()),
'dataType' => $this->getDataType($attribute),
'add_field' => true,
'visible' => $attribute->getIsVisibleInGrid(),
'filter' => ($attribute->getIsFilterableInGrid())
'filter' => ($attribute->getIsFilterableInGrid() || array_key_exists($columnName, $filterModifiers))
? $this->getFilterType($attribute->getFrontendInput())
: null,
], $config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ private function addAdvancedPriceLink()
'componentType' => Container::NAME,
'component' => 'Magento_Ui/js/form/components/button',
'template' => 'ui/form/components/button/container',
'imports' => [
'childError' => $this->scopeName . '.advanced_pricing_modal.advanced-pricing:error',
],
'actions' => [
[
'targetName' => $this->scopeName . '.advanced_pricing_modal',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
<test name="StoreViewLanguageCorrectSwitchTest">
<annotations>
<features value="Cms"/>
<stories value="Store View (language) switch leads to 404"/>
<group value="Cms"/>
<title value="Check that Store View(language) switches correct"/>
<description value="Check that Store View(language) switches correct"/>
<severity value="MAJOR"/>
<testCaseId value="MAGETWO-96388"/>
<useCaseId value="MAGETWO-57337"/>
<group value="Cms"/>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
Expand All @@ -37,7 +36,7 @@

<!-- Create StoreView -->
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreView">
<argument name="customStore" value="NewStoreViewData"/>
<argument name="customStore" value="NewStoreViewData"/>
</actionGroup>

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

<!-- Switch StoreView and check that Cms Page is open -->
<click selector="{{StorefrontHeaderSection.storeViewSwitcher}}" stepKey="clickStoreViewSwitcher"/>
<waitForElementVisible selector="{{StorefrontHeaderSection.storeViewDropdown}}" stepKey="waitForStoreViewDropDown"/>
<click selector="{{StorefrontHeaderSection.storeViewOption(NewStoreViewData.code)}}" stepKey="selectStoreView"/>
<actionGroup ref="StorefrontSwitchStoreViewActionGroup" stepKey="switchToCustomStoreView">
<argument name="storeView" value="NewStoreViewData"/>
</actionGroup>
<amOnPage url="{{StorefrontHomePage.url}}/$$createSecondCmsPage.identifier$$" stepKey="gotToSecondCmsPage"/>
<see userInput="$$createSecondCmsPage.title$$" stepKey="seePageTitle1"/>

<!--Open first Cms page on custom store view-->
<amOnPage url="{{StorefrontHomePage.url}}/$$createFirstCmsPage.identifier$$" stepKey="gotToFirstCmsPage1"/>
<see userInput="Whoops, our bad..." stepKey="seePageError"/>

<!--Switch to default store view and check Cms page-->
<actionGroup ref="StorefrontSwitchDefaultStoreViewActionGroup" stepKey="switchToDefualtStoreView"/>
<see userInput="$$createFirstCmsPage.title$$" stepKey="seePageTitle2"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@
*/
namespace Magento\ConfigurableProduct\Model\Product\Type\Configurable;

use Magento\Catalog\Model\Product;

/**
* Class Price for configurable product
*/
class Price extends \Magento\Catalog\Model\Product\Type\Price
{
/**
* Get product final price
*
* @param float $qty
* @param \Magento\Catalog\Model\Product $product
* @return float
* @inheritdoc
*/
public function getFinalPrice($qty, $product)
{
if ($qty === null && $product->getCalculatedFinalPrice() !== null) {
return $product->getCalculatedFinalPrice();
}
if ($product->getCustomOption('simple_product') && $product->getCustomOption('simple_product')->getProduct()) {
$finalPrice = parent::getFinalPrice($qty, $product->getCustomOption('simple_product')->getProduct());
/** @var Product $simpleProduct */
$simpleProduct = $product->getCustomOption('simple_product')->getProduct();
$simpleProduct->setCustomerGroupId($product->getCustomerGroupId());
$finalPrice = parent::getFinalPrice($qty, $simpleProduct);
} else {
$priceInfo = $product->getPriceInfo();
$finalPrice = $priceInfo->getPrice('final_price')->getAmount()->getValue();
Expand All @@ -35,7 +39,7 @@ public function getFinalPrice($qty, $product)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getPrice($product)
{
Expand All @@ -48,6 +52,7 @@ public function getPrice($product)
}
}
}

return 0;
}
}
Loading

0 comments on commit c9d6491

Please sign in to comment.