From 45c87daeb7fe973da6a68c574636653b58732e7b Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Thu, 16 Apr 2020 22:42:44 +0000 Subject: [PATCH] #27500 Code Review adjustments to ConfigurableProduct module --- .../Product/Edit/Button/SaveTest.php | 4 ++- .../Edit/Tab/Variations/Config/MatrixTest.php | 6 ++-- .../Product/Steps/SelectAttributesTest.php | 4 ++- .../Cart/Item/Renderer/ConfigurableTest.php | 4 ++- .../Plugin/Product/Media/GalleryTest.php | 4 ++- .../Configurable/AttributeSelectorTest.php | 4 ++- .../Product/View/Type/ConfigurableTest.php | 3 +- .../Adminhtml/Product/AddAttributeTest.php | 3 +- .../SuggestConfigurableAttributesTest.php | 4 ++- .../Adminhtml/Product/Builder/PluginTest.php | 4 ++- .../Helper/Plugin/ConfigurableTest.php | 6 ++-- .../Plugin/UpdateConfigurationsTest.php | 4 ++- .../Adminhtml/Product/WizardTest.php | 3 +- .../Test/Unit/Helper/DataTest.php | 3 +- .../Product/Configuration/PluginTest.php | 4 ++- .../Helper/Product/Options/FactoryTest.php | 6 ++-- .../Helper/Product/Options/LoaderTest.php | 6 ++-- .../Model/Attribute/LockValidatorTest.php | 4 ++- .../Model/AttributeOptionProviderTest.php | 3 +- .../Test/Unit/Model/AttributesListTest.php | 3 +- .../Model/ConfigurableAttributeDataTest.php | 5 +-- .../ConfigurableProductManagementTest.php | 3 +- .../Group/AttributeMapper/PluginTest.php | 4 ++- .../Test/Unit/Model/LinkManagementTest.php | 3 +- .../Test/Unit/Model/OptionRepositoryTest.php | 3 +- .../Admin/Item/Plugin/ConfigurableTest.php | 4 ++- .../Unit/Model/Plugin/PriceBackendTest.php | 5 +-- .../Plugin/ProductRepositorySaveTest.php | 4 ++- .../Plugin/ConfigurableTest.php | 4 ++- .../Product/ProductExtensionAttributes.php | 4 ++- .../ProductOptionExtensionAttributes.php | 4 ++- .../Unit/Model/Product/ReadHandlerTest.php | 6 ++-- .../Unit/Model/Product/SaveHandlerTest.php | 10 +++--- .../Type/Collection/SalableProcessorTest.php | 4 ++- .../Product/Type/Configurable/PriceTest.php | 3 +- .../Model/Product/Type/ConfigurableTest.php | 4 ++- .../Unit/Model/Product/Type/PluginTest.php | 3 +- .../Product/Type/VariationMatrixTest.php | 3 +- .../Plugin/ConfigurableTest.php | 4 ++- .../Model/Product/Validator/PluginTest.php | 4 ++- .../Model/Product/VariationHandlerTest.php | 8 +++-- .../Unit/Model/ProductOptionProcessorTest.php | 4 ++- .../Model/ProductVariationsBuilderTest.php | 3 +- .../Quote/Item/CartItemProcessorTest.php | 10 +++--- .../Option/Plugin/ConfigurableProductTest.php | 4 ++- .../Attribute/OptionProviderTest.php | 4 ++- .../Attribute/OptionSelectBuilderTest.php | 4 ++- .../LinkedProductSelectBuilderTest.php | 4 ++- .../StockStatusBaseSelectProcessorTest.php | 4 ++- .../Type/Configurable/AttributeTest.php | 3 +- .../Product/Type/ConfigurableTest.php | 15 ++++----- .../Unit/Model/SuggestedAttributeListTest.php | 3 +- .../HideUnsupportedAttributeTypesTest.php | 9 ++--- .../Pricing/Renderer/SalableResolverTest.php | 4 ++- .../InStockOptionSelectBuilderTest.php | 3 +- .../Model/ResourceModel/ProductTest.php | 3 +- .../CleanConfigurationTmpImagesTest.php | 4 ++- .../Model/Rule/Condition/ProductTest.php | 3 +- .../Price/ConfigurablePriceResolverTest.php | 4 ++- .../Price/LowestPriceOptionsProviderTest.php | 3 +- .../Unit/Pricing/Render/FinalPriceBoxTest.php | 4 ++- .../Columns/AttributesTest.php | 4 ++- .../AssociatedProduct/Columns/NameTest.php | 4 ++- .../AssociatedProduct/Columns/PriceTest.php | 4 ++- .../Product/Form/Modifier/CompositeTest.php | 4 ++- .../ConfigurableAttributeSetHandlerTest.php | 4 ++- .../Form/Modifier/ConfigurablePanelTest.php | 4 ++- .../Form/Modifier/ConfigurablePriceTest.php | 33 ++++++++----------- .../Form/Modifier/ConfigurableQtyTest.php | 4 ++- .../Form/Modifier/CustomOptionsTest.php | 4 ++- .../Product/Form/Modifier/StockDataTest.php | 4 ++- 71 files changed, 222 insertions(+), 116 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php index ab4e89903f4a9..dbf967eb43851 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php @@ -1,8 +1,10 @@ - $this->stockRegistryMock, ]; $helper = new ObjectManager($this); - $this->_object = $helper->getObject(Form::class, $data); $this->_block = $helper->getObject( Matrix::class, $data diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Steps/SelectAttributesTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Steps/SelectAttributesTest.php index ae0c8e56bdc24..496a2a7dfec7b 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Steps/SelectAttributesTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Steps/SelectAttributesTest.php @@ -1,8 +1,10 @@ -expects(static::once()) ->method('setId') diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/Collection/SalableProcessorTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/Collection/SalableProcessorTest.php index 6f7bb0983e6f0..121292564584b 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/Collection/SalableProcessorTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/Collection/SalableProcessorTest.php @@ -1,8 +1,10 @@ -setMethods(['getIsUnique', 'getAttributeCode', 'getFrontend', 'getIsVisible']) ->disableOriginalConstructor() ->getMock(); - $frontendAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Frontend::class) + $frontendAttributeMock = $this->getMockBuilder(FrontendInterface::class) ->setMethods(['getInputType']) ->disableOriginalConstructor() - ->getMock(); + ->getMockForAbstractClass(); $parentProductMock->expects($this->once()) ->method('getNewVariationsAttributeSetId') diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductOptionProcessorTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductOptionProcessorTest.php index 18c8d82e566bd..581e9d581bb0d 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductOptionProcessorTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductOptionProcessorTest.php @@ -1,8 +1,10 @@ -createMock(ProductOptionInterface::class); $cartItemMock = $this->createMock(CartItemInterface::class); $cartItemMock->expects($this->exactly(3))->method('getProductOption')->willReturn($productOptionMock); - $extAttributesMock = $this->getMockBuilder(\Magento\Quote\Api\Data\ProductOption::class) + $extAttributesMock = $this->getMockBuilder(ProductOptionInterface::class) ->setMethods(['getConfigurableItemOptions']) ->disableOriginalConstructor() - ->getMock(); + ->getMockForAbstractClass(); $productOptionMock ->expects($this->exactly(2)) ->method('getExtensionAttributes') diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProductTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProductTest.php index 3ee6c20de275e..5f00983ec254e 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProductTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProductTest.php @@ -1,8 +1,10 @@ -connectionMock = $this->getMockBuilder(AdapterInterface::class) @@ -90,10 +87,10 @@ protected function setUp(): void $this->relation = $this->getMockBuilder(ProductRelation::class) ->disableOriginalConstructor() ->getMock(); - $this->stockRegistryMock = $this->getMockBuilder(StockRegistryInterface::class) + $stockRegistryMock = $this->getMockBuilder(StockRegistryInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->scopeResolver = $this->getMockBuilder(ScopeResolverInterface::class) + $scopeResolver = $this->getMockBuilder(ScopeResolverInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->abstractAttribute = $this->getMockBuilder(AbstractAttribute::class) @@ -129,7 +126,7 @@ protected function setUp(): void Configurable::class, [ 'catalogProductRelation' => $this->relation, - 'scopeResolver' => $this->scopeResolver, + 'scopeResolver' => $scopeResolver, 'attributeOptionProvider' => $this->attributeOptionProvider, 'optionProvider' => $this->optionProvider, 'context' => $context diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php index a8a193d9aedbd..3afa4a080c051 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php @@ -1,8 +1,9 @@ -objectManager->getObject( HideUnsupportedAttributeTypes::class, @@ -90,7 +91,7 @@ function ($name) use ($popup, $productTab) { * @return EventObserver|\PHPUnit\Framework\MockObject\MockObject * @internal param null|MockObject $block */ - private function createEventMock(\PHPUnit\Framework\MockObject\MockObject $form = null) + private function createEventMock(MockObject $form = null) { $event = $this->getMockBuilder(EventObserver::class) ->setMethods(['getForm', 'getBlock']) diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolverTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolverTest.php index 1de93676a5905..597348f49bc7f 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolverTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolverTest.php @@ -1,8 +1,10 @@ - [ + 'data' => [ + 'config' => [ + 'component' => 'Magento_ConfigurableProduct/js/components/price-configurable' + ] + ] + ] + ]; return [ [ 'metaInput' => [ @@ -70,15 +81,7 @@ public function metaDataProvider() ], ], ], - 'price' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'component' => 'Magento_ConfigurableProduct/js/components/price-configurable' - ], - ], - ], - ], + 'price' => $priceComponentConfig, ], ], ], @@ -99,15 +102,7 @@ public function metaDataProvider() 'children' => [ 'container_price' => [ 'children' => [ - 'price' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'component' => 'Magento_ConfigurableProduct/js/components/price-configurable' - ] - ] - ] - ] + 'price' => $priceComponentConfig ] ] ] diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurableQtyTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurableQtyTest.php index dc74389e637d4..211d41e52e008 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurableQtyTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurableQtyTest.php @@ -1,8 +1,10 @@ -