diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Block/Adminhtml/Order/Create/SidebarTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Block/Adminhtml/Order/Create/SidebarTest.php index b173a848aec93..31b6514bf40fe 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Block/Adminhtml/Order/Create/SidebarTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Block/Adminhtml/Order/Create/SidebarTest.php @@ -1,29 +1,37 @@ -itemMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getProduct']); - $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $this->itemMock = $this->createPartialMock(DataObject::class, ['getProduct']); + $this->productMock = $this->createMock(Product::class); $this->subjectMock = $this->createMock( - \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar::class + AbstractSidebar::class ); $this->closureMock = function () { return 'Expected'; }; - $this->sidebarMock = new \Magento\GroupedProduct\Block\Adminhtml\Order\Create\Sidebar(); + $this->sidebarMock = new Sidebar(); } public function testAroundGetItemQtyWhenProductGrouped() @@ -53,7 +61,7 @@ public function testAroundGetItemQtyWhenProductGrouped() )->method( 'getTypeId' )->will( - $this->returnValue(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) + $this->returnValue(Grouped::TYPE_CODE) ); $this->assertEquals( '', @@ -75,7 +83,7 @@ public function testAroundIsConfigurationRequiredWhenProductGrouped() $this->sidebarMock->aroundIsConfigurationRequired( $this->subjectMock, $this->closureMock, - \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE + Grouped::TYPE_CODE ) ); } diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php index 8534ef4d2fbe3..5d384f260ea09 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php @@ -1,52 +1,64 @@ -registryMock = $this->createMock(\Magento\Framework\Registry::class); - $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class); - $this->pricingHelperMock = $this->createMock(\Magento\Framework\Pricing\Helper\Data::class); - $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->registryMock = $this->createMock(Registry::class); + $this->productMock = $this->createMock(Product::class); + $this->pricingHelperMock = $this->createMock(Data::class); + $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); $customerMock = $this->getMockBuilder( - \Magento\Customer\Api\Data\CustomerInterface::class + CustomerInterface::class )->disableOriginalConstructor()->getMock(); $customerMock->expects($this->any())->method('getId')->will($this->returnValue(1)); - $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $objectHelper = new ObjectManager($this); $this->block = $objectHelper->getObject( - \Magento\GroupedProduct\Block\Adminhtml\Product\Composite\Fieldset\Grouped::class, + Grouped::class, [ 'registry' => $this->registryMock, 'storeManager' => $this->storeManagerMock, @@ -62,7 +74,7 @@ protected function setUp() public function testGetProductPositive() { $instanceMock = $this->createMock(\Magento\GroupedProduct\Model\Product\Type\Grouped::class); - $storeMock = $this->createMock(\Magento\Store\Model\Store::class); + $storeMock = $this->createMock(Store::class); $this->productMock->expects($this->any())->method('getTypeInstance')->will($this->returnValue($instanceMock)); @@ -80,7 +92,7 @@ public function testGetProductNegative() { $storeId = 2; $instanceMock = $this->createMock(\Magento\GroupedProduct\Model\Product\Type\Grouped::class); - $storeMock = $this->createMock(\Magento\Store\Model\Store::class); + $storeMock = $this->createMock(Store::class); $this->productMock->expects($this->any())->method('getTypeInstance')->will($this->returnValue($instanceMock)); @@ -148,7 +160,7 @@ public function testSetPreconfiguredValue() { $storeId = 2; - $objectMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getSuperGroup']); + $objectMock = $this->createPartialMock(DataObject::class, ['getSuperGroup']); $instanceMock = $this->createMock(\Magento\GroupedProduct\Model\Product\Type\Grouped::class); $objectMock->expects($this->once())->method('getSuperGroup')->will($this->returnValue([])); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Block/Cart/Item/Renderer/GroupedTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Block/Cart/Item/Renderer/GroupedTest.php index 9302706342f13..516f6dde4578a 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Block/Cart/Item/Renderer/GroupedTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Block/Cart/Item/Renderer/GroupedTest.php @@ -1,26 +1,31 @@ -scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $objectManagerHelper = new ObjectManager($this); + $this->scopeConfig = $this->createMock(ScopeConfigInterface::class); $this->renderer = $objectManagerHelper->getObject( \Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped::class, ['scopeConfig' => $this->scopeConfig] @@ -30,9 +35,9 @@ protected function setUp() public function testGetIdentities() { $productTags = ['catalog_product_1']; - $product = $this->createMock(\Magento\Catalog\Model\Product::class); + $product = $this->createMock(Product::class); $product->expects($this->exactly(2))->method('getIdentities')->will($this->returnValue($productTags)); - $item = $this->createMock(\Magento\Quote\Model\Quote\Item::class); + $item = $this->createMock(Item::class); $item->expects($this->exactly(2))->method('getProduct')->will($this->returnValue($product)); $this->renderer->setItem($item); $this->assertEquals(array_merge($productTags, $productTags), $this->renderer->getIdentities()); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/Grouped/AssociatedProducts/ListAssociatedProductsTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/Grouped/AssociatedProducts/ListAssociatedProductsTest.php index 15f2dba606a6e..f2b101bd5883b 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/Grouped/AssociatedProducts/ListAssociatedProductsTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/Grouped/AssociatedProducts/ListAssociatedProductsTest.php @@ -1,60 +1,72 @@ -contextMock = $this->createMock(\Magento\Backend\Block\Template\Context::class); - $this->registryMock = $this->createMock(\Magento\Framework\Registry::class); - $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class); - $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class); - $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); - $this->typeInstanceMock = $this->createMock(\Magento\GroupedProduct\Model\Product\Type\Grouped::class); + $this->contextMock = $this->createMock(Context::class); + $this->registryMock = $this->createMock(Registry::class); + $this->productMock = $this->createMock(Product::class); + $this->storeMock = $this->createMock(Store::class); + $this->storeManagerMock = $this->createMock(StoreManager::class); + $this->typeInstanceMock = $this->createMock(Grouped::class); $this->contextMock->expects( $this->any() @@ -65,10 +77,10 @@ protected function setUp() ); $this->priceCurrency = $this->getMockBuilder( - \Magento\Framework\Pricing\PriceCurrencyInterface::class + PriceCurrencyInterface::class )->getMock(); - $this->block = new \Magento\GroupedProduct\Block\Product\Grouped\AssociatedProducts\ListAssociatedProducts( + $this->block = new ListAssociatedProducts( $this->contextMock, $this->registryMock, $this->priceCurrency @@ -148,12 +160,12 @@ public function testGetAssociatedProducts() * Generate associated product mock * * @param int $productKey - * @return \PHPUnit_Framework_MockObject_MockObject + * @return MockObject */ protected function generateAssociatedProduct($productKey = 0) { $associatedProduct = $this->createPartialMock( - \Magento\Framework\DataObject::class, + DataObject::class, ['getQty', 'getPosition', 'getId', 'getSku', 'getName', 'getPrice'] ); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/Grouped/AssociatedProductsTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/Grouped/AssociatedProductsTest.php index 9864e4d16c03c..08afb737f1b41 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/Grouped/AssociatedProductsTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/Grouped/AssociatedProductsTest.php @@ -1,26 +1,31 @@ -contextMock = $this->createMock(\Magento\Backend\Block\Template\Context::class); - $this->block = new \Magento\GroupedProduct\Block\Product\Grouped\AssociatedProducts($this->contextMock); + $this->contextMock = $this->createMock(Context::class); + $this->block = new AssociatedProducts($this->contextMock); } /** diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/View/Type/GroupedTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/View/Type/GroupedTest.php index e8ed2e5d6f880..cea2cee61129d 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/View/Type/GroupedTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/View/Type/GroupedTest.php @@ -1,35 +1,43 @@ -productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $methodsProduct); + $this->productMock = $this->createPartialMock(Product::class, $methodsProduct); $this->typeInstanceMock = $this->createMock(\Magento\GroupedProduct\Model\Product\Type\Grouped::class); $this->productMock->expects( $this->any() @@ -47,10 +55,10 @@ protected function setUp() )->will( $this->returnValue($this->typeInstanceMock) ); - $this->configuredValueMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getSuperGroup']); - $layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class); + $this->configuredValueMock = $this->createPartialMock(DataObject::class, ['getSuperGroup']); + $layout = $this->createMock(LayoutInterface::class); $this->groupedView = $helper->getObject( - \Magento\GroupedProduct\Block\Product\View\Type\Grouped::class, + Grouped::class, [ 'data' => ['product' => $this->productMock], 'layout' => $layout diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Block/Stockqty/Type/GroupedTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Block/Stockqty/Type/GroupedTest.php index 86bb53af62370..a99403aa99c3d 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Block/Stockqty/Type/GroupedTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Block/Stockqty/Type/GroupedTest.php @@ -1,33 +1,40 @@ -registry = $this->createMock(\Magento\Framework\Registry::class); + $objectManager = new ObjectManager($this); + $this->registry = $this->createMock(Registry::class); $this->block = $objectManager->getObject( - \Magento\GroupedProduct\Block\Stockqty\Type\Grouped::class, + Grouped::class, ['registry' => $this->registry] ); } - protected function tearDown() + protected function tearDown(): void { $this->block = null; } @@ -35,7 +42,7 @@ protected function tearDown() public function testGetIdentities() { $productTags = ['catalog_product_1']; - $childProduct = $this->createMock(\Magento\Catalog\Model\Product::class); + $childProduct = $this->createMock(Product::class); $childProduct->expects($this->once())->method('getIdentities')->will($this->returnValue($productTags)); $typeInstance = $this->createMock(\Magento\GroupedProduct\Model\Product\Type\Grouped::class); $typeInstance->expects( @@ -45,7 +52,7 @@ public function testGetIdentities() )->will( $this->returnValue([$childProduct]) ); - $product = $this->createMock(\Magento\Catalog\Model\Product::class); + $product = $this->createMock(Product::class); $product->expects($this->once())->method('getTypeInstance')->will($this->returnValue($typeInstance)); $this->registry->expects( $this->any() diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Controller/Adminhtml/Edit/PopupTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Controller/Adminhtml/Edit/PopupTest.php index ddc18682f2ddc..a8d64c316429a 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Controller/Adminhtml/Edit/PopupTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Controller/Adminhtml/Edit/PopupTest.php @@ -1,63 +1,73 @@ -request = $this->createMock(\Magento\Framework\App\RequestInterface::class); - $this->factory = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']); - $this->registry = $this->createMock(\Magento\Framework\Registry::class); - $this->resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) + $this->request = $this->createMock(RequestInterface::class); + $this->factory = $this->createPartialMock(ProductFactory::class, ['create']); + $this->registry = $this->createMock(Registry::class); + $this->resultFactoryMock = $this->getMockBuilder(ResultFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->resultLayoutMock = $this->getMockBuilder(\Magento\Framework\View\Result\Layout::class) + $this->resultLayoutMock = $this->getMockBuilder(Layout::class) ->disableOriginalConstructor() ->getMock(); @@ -66,16 +76,16 @@ protected function setUp() ->with(ResultFactory::TYPE_LAYOUT, []) ->willReturn($this->resultLayoutMock); - $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->objectManager = new ObjectManager($this); $this->context = $this->objectManager->getObject( - \Magento\Backend\App\Action\Context::class, + Context::class, [ 'request' => $this->request, 'resultFactory' => $this->resultFactoryMock ] ); $this->action = $this->objectManager->getObject( - \Magento\GroupedProduct\Controller\Adminhtml\Edit\Popup::class, + Popup::class, [ 'context' => $this->context, 'factory' => $this->factory, @@ -91,7 +101,7 @@ public function testPopupActionNoProductId() $productId = null; $setId = 0; $product = $this->createPartialMock( - \Magento\Catalog\Model\Product::class, + Product::class, ['setStoreId', 'setTypeId', 'setData', '__wakeup'] ); @@ -125,7 +135,7 @@ public function testPopupActionWithProductIdNoSetId() $setId = 0; $productId = 399; $product = $this->createPartialMock( - \Magento\Catalog\Model\Product::class, + Product::class, ['setStoreId', 'setTypeId', 'setData', 'load', '__wakeup'] ); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Helper/Product/Configuration/Plugin/GroupedTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Helper/Product/Configuration/Plugin/GroupedTest.php index 05280b66202b5..88b1db3f3b6f9 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Helper/Product/Configuration/Plugin/GroupedTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Helper/Product/Configuration/Plugin/GroupedTest.php @@ -1,14 +1,21 @@ -groupedConfigPlugin = new \Magento\GroupedProduct\Helper\Product\Configuration\Plugin\Grouped(); - $this->itemMock = $this->createMock(\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class); - $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $this->groupedConfigPlugin = new Grouped(); + $this->itemMock = $this->createMock(ItemInterface::class); + $this->productMock = $this->createMock(Product::class); $this->typeInstanceMock = $this->createMock(\Magento\GroupedProduct\Model\Product\Type\Grouped::class); $this->itemMock->expects($this->any())->method('getProduct')->will($this->returnValue($this->productMock)); @@ -54,7 +61,7 @@ protected function setUp() $this->returnValue($this->typeInstanceMock) ); - $this->subjectMock = $this->createMock(\Magento\Catalog\Helper\Product\Configuration::class); + $this->subjectMock = $this->createMock(Configuration::class); } /** @@ -65,7 +72,7 @@ public function testAroundGetOptionsGroupedProductWithAssociated() $associatedProductId = 'associatedId'; $associatedProdName = 'associatedProductName'; - $associatedProdMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $associatedProdMock = $this->createMock(Product::class); $associatedProdMock->expects($this->once())->method('getId')->will($this->returnValue($associatedProductId)); @@ -90,7 +97,7 @@ public function testAroundGetOptionsGroupedProductWithAssociated() ); $quantityItemMock = $this->createPartialMock( - \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class, + ItemInterface::class, ['getValue', 'getProduct', 'getOptionByCode', 'getFileDownloadParams'] ); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Cart/Configuration/Plugin/GroupedTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Cart/Configuration/Plugin/GroupedTest.php index 05a06324b8b27..8a3f14b45aacb 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Cart/Configuration/Plugin/GroupedTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Cart/Configuration/Plugin/GroupedTest.php @@ -1,24 +1,30 @@ -productMock = $this->createMock(\Magento\Catalog\Model\Product::class); - $this->subjectMock = $this->createMock(\Magento\Catalog\Model\Product\CartConfiguration::class); + $this->productMock = $this->createMock(Product::class); + $this->subjectMock = $this->createMock(CartConfiguration::class); $this->closureMock = function () { return 'Expected'; }; - $this->groupedPlugin = new \Magento\GroupedProduct\Model\Product\Cart\Configuration\Plugin\Grouped(); + $this->groupedPlugin = new Grouped(); } public function testAroundIsProductConfiguredWhenProductGrouped() diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/CatalogPriceTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/CatalogPriceTest.php index 5a8563dea6d2a..3f8da4b588362 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/CatalogPriceTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/CatalogPriceTest.php @@ -1,62 +1,71 @@ -storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); $this->commonPriceMock = $this->createMock(\Magento\Catalog\Model\Product\CatalogPrice::class); $productMethods = ['getWebsiteId', 'getCustomerGroupId', '__wakeup', 'getTypeInstance', 'setTaxClassId']; - $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $productMethods); + $this->productMock = $this->createPartialMock(Product::class, $productMethods); $methods = ['setWebsiteId', 'isSalable', '__wakeup', 'setCustomerGroupId', 'getTaxClassId']; - $this->associatedProductMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $methods); + $this->associatedProductMock = $this->createPartialMock(Product::class, $methods); $this->priceModelMock = $this->createPartialMock( - \Magento\Catalog\Model\Product\Type\Price::class, + Price::class, ['getTotalPrices'] ); - $this->productTypeMock = $this->createMock(\Magento\GroupedProduct\Model\Product\Type\Grouped::class); + $this->productTypeMock = $this->createMock(Grouped::class); - $this->catalogPrice = new \Magento\GroupedProduct\Model\Product\CatalogPrice( + $this->catalogPrice = new CatalogPrice( $this->storeManagerMock, $this->commonPriceMock ); @@ -130,9 +139,9 @@ public function testGetCatalogPriceWithDefaultStoreAndSubProductIsNotSalable() public function testGetCatalogPriceWithCustomStoreAndSubProductIsSalable() { - $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class); + $storeMock = $this->createMock(StoreInterface::class); $storeMock->expects($this->once())->method('getId')->willReturn('store_id'); - $currentStoreMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class); + $currentStoreMock = $this->createMock(StoreInterface::class); $currentStoreMock->expects($this->once())->method('getId')->willReturn('current_store_id'); $this->productMock->expects( diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/CopyConstructor/GroupedTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/CopyConstructor/GroupedTest.php index defeef31cc9e2..bb4bdca3b9ade 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/CopyConstructor/GroupedTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/CopyConstructor/GroupedTest.php @@ -1,53 +1,61 @@ -_model = new \Magento\GroupedProduct\Model\Product\CopyConstructor\Grouped(); + $this->_model = new Grouped(); $this->_productMock = $this->createPartialMock( - \Magento\Catalog\Model\Product::class, + Product::class, ['getTypeId', '__wakeup', 'getLinkInstance'] ); $this->_duplicateMock = $this->createPartialMock( - \Magento\Catalog\Model\Product::class, + Product::class, ['setGroupedLinkData', '__wakeup'] ); $this->_linkMock = $this->createPartialMock( - \Magento\Catalog\Model\Product\Link::class, + Link::class, ['setLinkTypeId', '__wakeup', 'getAttributes', 'getLinkCollection'] ); @@ -71,7 +79,7 @@ public function testBuildWithNonGroupedProductType() public function testBuild() { - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $helper = new ObjectManager($this); $expectedData = ['100500' => ['some' => 'data']]; $this->_productMock->expects( @@ -110,7 +118,7 @@ public function testBuild() ); $collectionMock = $helper->getCollectionMock( - \Magento\Catalog\Model\ResourceModel\Product\Link\Collection::class, + Collection::class, [$productLinkMock] ); $collectionMock->expects($this->once())->method('setProduct')->with($this->_productMock); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Initialization/Helper/ProductLinks/Plugin/GroupedTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Initialization/Helper/ProductLinks/Plugin/GroupedTest.php index 2dbdbb551f97a..d2b3554b80966 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Initialization/Helper/ProductLinks/Plugin/GroupedTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Initialization/Helper/ProductLinks/Plugin/GroupedTest.php @@ -1,4 +1,4 @@ -productMock = $this->createPartialMock( - \Magento\Catalog\Model\Product::class, + Product::class, [ 'getGroupedReadonly', '__wakeup', @@ -59,19 +65,19 @@ protected function setUp() ] ); $this->subjectMock = $this->createMock( - \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks::class + ProductLinks::class ); $this->productLinkExtensionFactory = $this->getMockBuilder( - \Magento\Catalog\Api\Data\ProductLinkExtensionFactory::class + ProductLinkExtensionFactory::class ) ->disableOriginalConstructor() ->setMethods(['create']) ->getMockForAbstractClass(); - $this->productLinkFactory = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductLinkInterfaceFactory::class) + $this->productLinkFactory = $this->getMockBuilder(ProductLinkInterfaceFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMockForAbstractClass(); - $this->productRepository = $this->getMockBuilder(\Magento\Catalog\Api\ProductRepositoryInterface::class) + $this->productRepository = $this->getMockBuilder(ProductRepositoryInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->model = new \Magento\GroupedProduct\Model\Product\Initialization\Helper\ProductLinks\Plugin\Grouped( @@ -115,16 +121,16 @@ public function testBeforeInitializeLinksRequestHasGrouped($linksData) $this->productMock->expects($this->once())->method('getProductLinks')->willReturn([]); $this->productMock->expects($this->once())->method('getSku')->willReturn('sku'); $linkedProduct = $this->createPartialMock( - \Magento\Catalog\Model\Product::class, + Product::class, ['getGroupedReadonly', '__wakeup', 'getTypeId', 'getSku', 'getProductLinks', 'setProductLinks'] ); - $extensionAttributes = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductLinkExtensionInterface::class) + $extensionAttributes = $this->getMockBuilder(ProductLinkExtensionInterface::class) ->setMethods(['setQty', 'getQty']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $linkedProduct->expects($this->once())->method('getTypeId')->will($this->returnValue(Grouped::TYPE_CODE)); $linkedProduct->expects($this->once())->method('getSku')->willReturn('sku'); - $productLink = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductLinkInterface::class) + $productLink = $this->getMockBuilder(ProductLinkInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->productRepository->expects($this->once()) diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/Grouped/PriceTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/Grouped/PriceTest.php index 176c29add4837..84ecdabf82d72 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/Grouped/PriceTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/Grouped/PriceTest.php @@ -1,29 +1,37 @@ -productMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $this->productMock = $this->createMock(Product::class); - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $helper = new ObjectManager($this); $this->finalPriceModel = $helper->getObject( - \Magento\GroupedProduct\Model\Product\Type\Grouped\Price::class, + Price::class, [] ); } @@ -102,7 +110,7 @@ public function testGetFinalPrice( //test method $this->productMock->expects($this->once())->method('hasCustomOptions')->will($this->returnValue(true)); - $productTypeMock = $this->createMock(\Magento\GroupedProduct\Model\Product\Type\Grouped::class); + $productTypeMock = $this->createMock(Grouped::class); $this->productMock->expects( $this->once() @@ -147,7 +155,7 @@ public function testGetFinalPrice( */ public function getFinalPriceDataProvider() { - $optionMock = $this->createPartialMock(\Magento\Catalog\Model\Product\Option::class, ['getValue', '__wakeup']); + $optionMock = $this->createPartialMock(Option::class, ['getValue', '__wakeup']); /* quantity of options */ $optionMock->expects($this->any())->method('getValue')->will($this->returnValue(5)); @@ -179,7 +187,7 @@ public function getFinalPriceDataProvider() protected function generateAssociatedProducts() { $childProductMock = $this->createPartialMock( - \Magento\Catalog\Model\Product::class, + Product::class, ['getId', 'getFinalPrice', '__wakeup'] ); /* price for option taking into account quantity discounts */ diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/GroupedTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/GroupedTest.php index 407224bf28f32..a32a43f881104 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/GroupedTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/GroupedTest.php @@ -1,70 +1,86 @@ -objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $eventManager = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); - $fileStorageDbMock = $this->createMock(\Magento\MediaStorage\Helper\File\Storage\Database::class); - $filesystem = $this->createMock(\Magento\Framework\Filesystem::class); - $coreRegistry = $this->createMock(\Magento\Framework\Registry::class); - $this->product = $this->createMock(\Magento\Catalog\Model\Product::class); - $logger = $this->createMock(\Psr\Log\LoggerInterface::class); - $productFactoryMock = $this->createMock(\Magento\Catalog\Model\ProductFactory::class); - $this->catalogProductLink = $this->createMock(\Magento\GroupedProduct\Model\ResourceModel\Product\Link::class); - $this->productStatusMock = $this->createMock(\Magento\Catalog\Model\Product\Attribute\Source\Status::class); - $this->serializer = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class) + $this->objectHelper = new ObjectManager($this); + $eventManager = $this->createMock(ManagerInterface::class); + $fileStorageDbMock = $this->createMock(Database::class); + $filesystem = $this->createMock(Filesystem::class); + $coreRegistry = $this->createMock(Registry::class); + $this->product = $this->createMock(Product::class); + $logger = $this->createMock(LoggerInterface::class); + $productFactoryMock = $this->createMock(ProductFactory::class); + $this->catalogProductLink = $this->createMock(Link::class); + $this->productStatusMock = $this->createMock(Status::class); + $this->serializer = $this->getMockBuilder(Json::class) ->setMethods(['serialize']) ->getMockForAbstractClass(); $this->_model = $this->objectHelper->getObject( - \Magento\GroupedProduct\Model\Product\Type\Grouped::class, + Grouped::class, [ 'eventManager' => $eventManager, 'fileStorageDb' => $fileStorageDbMock, @@ -104,7 +120,7 @@ public function testGetChildrenIds(): void 'getChildrenIds' )->with( $parentId, - \Magento\GroupedProduct\Model\ResourceModel\Product\Link::LINK_TYPE_GROUPED + Link::LINK_TYPE_GROUPED )->will( $this->returnValue($childrenIds) ); @@ -126,7 +142,7 @@ public function testGetParentIdsByChild(): void 'getParentIdsByChild' )->with( $childId, - \Magento\GroupedProduct\Model\ResourceModel\Product\Link::LINK_TYPE_GROUPED + Link::LINK_TYPE_GROUPED )->will( $this->returnValue($parentIds) ); @@ -201,8 +217,8 @@ public function testSetSaleableStatus(): void public function testGetStatusFiltersNoData(): void { $result = [ - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED, - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED, + Status::STATUS_ENABLED, + Status::STATUS_DISABLED, ]; $this->product->expects($this->once())->method('hasData')->will($this->returnValue(false)); $this->assertEquals($result, $this->_model->getStatusFilters($this->product)); @@ -216,8 +232,8 @@ public function testGetStatusFiltersNoData(): void public function testGetStatusFiltersWithData(): void { $result = [ - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED, - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED, + Status::STATUS_ENABLED, + Status::STATUS_DISABLED, ]; $this->product->expects($this->once())->method('hasData')->will($this->returnValue(true)); $this->product->expects($this->once())->method('getData')->will($this->returnValue($result)); @@ -249,17 +265,17 @@ public function testGetAssociatedProductIdsCached(): void public function testGetAssociatedProductIdsNonCached(): void { $args = $this->objectHelper->getConstructArguments( - \Magento\GroupedProduct\Model\Product\Type\Grouped::class, + Grouped::class, [] ); - /** @var \Magento\GroupedProduct\Model\Product\Type\Grouped $model */ - $model = $this->getMockBuilder(\Magento\GroupedProduct\Model\Product\Type\Grouped::class) + /** @var Grouped $model */ + $model = $this->getMockBuilder(Grouped::class) ->setMethods(['getAssociatedProducts']) ->setConstructorArgs($args) ->getMock(); - $associatedProduct = $this->createMock(\Magento\Catalog\Model\Product::class); + $associatedProduct = $this->createMock(Product::class); $model->expects( $this->once() )->method( @@ -307,10 +323,10 @@ public function testGetAssociatedProductCollection(): void )->method( 'setLinkTypeId' )->with( - \Magento\GroupedProduct\Model\ResourceModel\Product\Link::LINK_TYPE_GROUPED + Link::LINK_TYPE_GROUPED ); $collection = $this->createPartialMock( - \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection::class, + Collection::class, ['setFlag', 'setIsStrongMode', 'setProduct'] ); $link->expects($this->once())->method('getProductCollection')->will($this->returnValue($collection)); @@ -328,7 +344,7 @@ public function testGetAssociatedProductCollection(): void */ public function testProcessBuyRequest($superGroup, $result) { - $buyRequest = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getSuperGroup']); + $buyRequest = $this->createPartialMock(DataObject::class, ['getSuperGroup']); $buyRequest->expects($this->any())->method('getSuperGroup')->will($this->returnValue($superGroup)); $this->assertEquals($result, $this->_model->processBuyRequest($this->product, $buyRequest)); @@ -371,12 +387,12 @@ public function testGetChildrenMsrpWhenNoChildrenWithMsrp(): void */ public function testPrepareForCartAdvancedEmpty(): void { - $this->product = $this->createMock(\Magento\Catalog\Model\Product::class); - $buyRequest = new \Magento\Framework\DataObject(); + $this->product = $this->createMock(Product::class); + $buyRequest = new DataObject(); $expectedMsg = "Please specify the quantity of product(s)."; $productCollection = $this->createMock( - \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection::class + Collection::class ); $productCollection ->expects($this->atLeastOnce()) @@ -410,8 +426,8 @@ public function testPrepareForCartAdvancedEmpty(): void ->method('addAttributeToFilter') ->willReturnSelf(); $items = [ - $this->createMock(\Magento\Catalog\Model\Product::class), - $this->createMock(\Magento\Catalog\Model\Product::class) + $this->createMock(Product::class), + $this->createMock(Product::class) ]; $productCollection ->expects($this->atLeastOnce()) @@ -459,7 +475,7 @@ public function testPrepareForCartAdvancedEmpty(): void */ public function testPrepareForCartAdvancedNoProductsStrictTrue(): void { - $buyRequest = new \Magento\Framework\DataObject(); + $buyRequest = new DataObject(); $buyRequest->setSuperGroup([0 => 0]); $expectedMsg = "Please specify the quantity of product(s)."; @@ -487,7 +503,7 @@ public function testPrepareForCartAdvancedNoProductsStrictTrue(): void */ public function testPrepareForCartAdvancedNoProductsStrictFalse(): void { - $buyRequest = new \Magento\Framework\DataObject(); + $buyRequest = new DataObject(); $buyRequest->setSuperGroup([0 => 0]); $cached = true; @@ -517,12 +533,12 @@ public function testPrepareForCartAdvancedNoProductsStrictFalse(): void */ public function testPrepareForCartAdvancedWithProductsStrictFalseStringResult(): void { - $associatedProduct = $this->createMock(\Magento\Catalog\Model\Product::class); + $associatedProduct = $this->createMock(Product::class); $associatedId = 9384; $associatedProduct->expects($this->atLeastOnce())->method('getId')->will($this->returnValue($associatedId)); $typeMock = $this->createPartialMock( - \Magento\Catalog\Model\Product\Type\AbstractType::class, + AbstractType::class, ['_prepareProduct', 'deleteTypeSpecificData'] ); $associatedPrepareResult = ""; @@ -530,7 +546,7 @@ public function testPrepareForCartAdvancedWithProductsStrictFalseStringResult(): $associatedProduct->expects($this->once())->method('getTypeInstance')->willReturn($typeMock); - $buyRequest = new \Magento\Framework\DataObject(); + $buyRequest = new DataObject(); $buyRequest->setSuperGroup([$associatedId => 1]); $cached = true; @@ -557,12 +573,12 @@ public function testPrepareForCartAdvancedWithProductsStrictFalseStringResult(): public function testPrepareForCartAdvancedWithProductsStrictFalseEmptyArrayResult(): void { $expectedMsg = "Cannot process the item."; - $associatedProduct = $this->createMock(\Magento\Catalog\Model\Product::class); + $associatedProduct = $this->createMock(Product::class); $associatedId = 9384; $associatedProduct->expects($this->atLeastOnce())->method('getId')->will($this->returnValue($associatedId)); $typeMock = $this->createPartialMock( - \Magento\Catalog\Model\Product\Type\AbstractType::class, + AbstractType::class, ['_prepareProduct', 'deleteTypeSpecificData'] ); $associatedPrepareResult = []; @@ -570,7 +586,7 @@ public function testPrepareForCartAdvancedWithProductsStrictFalseEmptyArrayResul $associatedProduct->expects($this->once())->method('getTypeInstance')->willReturn($typeMock); - $buyRequest = new \Magento\Framework\DataObject(); + $buyRequest = new DataObject(); $buyRequest->setSuperGroup([$associatedId => 1]); $cached = true; @@ -596,16 +612,16 @@ public function testPrepareForCartAdvancedWithProductsStrictFalseEmptyArrayResul */ public function testPrepareForCartAdvancedWithProductsStrictFalse(): void { - $associatedProduct = $this->createMock(\Magento\Catalog\Model\Product::class); + $associatedProduct = $this->createMock(Product::class); $associatedId = 9384; $associatedProduct->expects($this->atLeastOnce())->method('getId')->will($this->returnValue($associatedId)); $typeMock = $this->createPartialMock( - \Magento\Catalog\Model\Product\Type\AbstractType::class, + AbstractType::class, ['_prepareProduct', 'deleteTypeSpecificData'] ); $associatedPrepareResult = [ - $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + $this->getMockBuilder(Product::class) ->setMockClassName('resultProduct') ->disableOriginalConstructor() ->getMock() @@ -614,7 +630,7 @@ public function testPrepareForCartAdvancedWithProductsStrictFalse(): void $associatedProduct->expects($this->once())->method('getTypeInstance')->willReturn($typeMock); - $buyRequest = new \Magento\Framework\DataObject(); + $buyRequest = new DataObject(); $buyRequest->setSuperGroup([$associatedId => 1]); $this->serializer->expects($this->any()) @@ -651,7 +667,7 @@ public function testPrepareForCartAdvancedWithProductsStrictTrue( $expectedResult ) { $associatedProducts = $this->configureProduct($subProducts); - $buyRequestObject = new \Magento\Framework\DataObject(); + $buyRequestObject = new DataObject(); $buyRequestObject->setSuperGroup($buyRequest); $associatedProductsById = []; foreach ($associatedProducts as $associatedProduct) { @@ -679,10 +695,10 @@ public function testPrepareForCartAdvancedZeroQtyAndSoldOutOption(): void { $expectedMsg = "Please specify the quantity of product(s)."; $associatedId = 91; - $associatedProduct = $this->createMock(\Magento\Catalog\Model\Product::class); + $associatedProduct = $this->createMock(Product::class); $associatedProduct->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(90)); $associatedProduct->expects($this->once())->method('isSalable')->willReturn(true); - $buyRequest = new \Magento\Framework\DataObject(); + $buyRequest = new DataObject(); $buyRequest->setSuperGroup([$associatedId => 90]); $cached = true; @@ -704,7 +720,7 @@ public function testPrepareForCartAdvancedZeroQtyAndSoldOutOption(): void */ public function testFlushAssociatedProductsCache(): void { - $productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['unsetData']); + $productMock = $this->createPartialMock(Product::class, ['unsetData']); $productMock->expects($this->once()) ->method('unsetData') ->with('_cache_instance_associated_products') @@ -802,14 +818,14 @@ private function configureProduct(array $subProducts): array { $associatedProducts = []; foreach ($subProducts as $data) { - $associatedProduct = $this->createMock(\Magento\Catalog\Model\Product::class); + $associatedProduct = $this->createMock(Product::class); foreach ($data as $method => $value) { $associatedProduct->method($method)->willReturn($value); } $associatedProducts[] = $associatedProduct; $typeMock = $this->createPartialMock( - \Magento\Catalog\Model\Product\Type\AbstractType::class, + AbstractType::class, ['_prepareProduct', 'deleteTypeSpecificData'] ); $typeMock->method('_prepareProduct')->willReturn([$associatedProduct]); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/PluginTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/PluginTest.php index 835ba878ce397..0f6a72ff55acb 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/PluginTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/PluginTest.php @@ -1,4 +1,4 @@ -moduleManagerMock = $this->createMock(\Magento\Framework\Module\Manager::class); - $this->subjectMock = $this->createMock(\Magento\Catalog\Model\Product\Type::class); - $this->object = new \Magento\GroupedProduct\Model\Product\Type\Plugin($this->moduleManagerMock); + $this->moduleManagerMock = $this->createMock(Manager::class); + $this->subjectMock = $this->createMock(Type::class); + $this->object = new Plugin($this->moduleManagerMock); } public function testAfterGetOptionArray() diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php index 78fa2445ff583..33a0a5d945928 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php @@ -1,4 +1,4 @@ -categoryIndexerMock = $this->getMockForAbstractClass(\Magento\Framework\Indexer\IndexerInterface::class); + $this->categoryIndexerMock = $this->getMockForAbstractClass(IndexerInterface::class); - $this->moduleManager = $this->createPartialMock(\Magento\Framework\Module\Manager::class, ['isEnabled']); + $this->moduleManager = $this->createPartialMock(Manager::class, ['isEnabled']); $this->stockItemFactoryMock = $this->createPartialMock( - \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory::class, + StockItemInterfaceFactory::class, ['create'] ); - $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) + $this->dataObjectHelperMock = $this->getMockBuilder(DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); - $this->productFlatProcessor = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\Processor::class); + $this->productFlatProcessor = $this->createMock(Processor::class); - $this->_priceInfoMock = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class); - $this->productTypeInstanceMock = $this->createMock(\Magento\Catalog\Model\Product\Type::class); + $this->_priceInfoMock = $this->createMock(Base::class); + $this->productTypeInstanceMock = $this->createMock(Type::class); $this->productPriceProcessor = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Price\Processor::class); - $stateMock = $this->createPartialMock(\Magento\Framework\App\State::class, ['getAreaCode']); + $stateMock = $this->createPartialMock(State::class, ['getAreaCode']); $stateMock->expects($this->any()) ->method('getAreaCode') - ->will($this->returnValue(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE)); + ->will($this->returnValue(FrontNameResolver::AREA_CODE)); - $eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); - $actionValidatorMock = $this->createMock(\Magento\Framework\Model\ActionValidator\RemoveAction::class); + $eventManagerMock = $this->createMock(ManagerInterface::class); + $actionValidatorMock = $this->createMock(RemoveAction::class); $actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); - $cacheInterfaceMock = $this->createMock(\Magento\Framework\App\CacheInterface::class); + $cacheInterfaceMock = $this->createMock(CacheInterface::class); $contextMock = $this->createPartialMock( - \Magento\Framework\Model\Context::class, + Context::class, ['getEventDispatcher', 'getCacheManager', 'getAppState', 'getActionValidator'] ); $contextMock->expects($this->any())->method('getAppState')->will($this->returnValue($stateMock)); @@ -198,31 +230,31 @@ protected function setUp() ->method('getActionValidator') ->will($this->returnValue($actionValidatorMock)); - $this->optionInstanceMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) + $this->optionInstanceMock = $this->getMockBuilder(Option::class) ->setMethods(['setProduct', 'saveOptions', '__wakeup', '__sleep']) ->disableOriginalConstructor()->getMock(); - $this->resource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product::class) + $this->resource = $this->getMockBuilder(ProductResourceModel::class) ->disableOriginalConstructor() ->getMock(); - $this->registry = $this->getMockBuilder(\Magento\Framework\Registry::class) + $this->registry = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() ->getMock(); - $this->category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) + $this->category = $this->getMockBuilder(Category::class) ->disableOriginalConstructor() ->getMock(); - $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class) + $this->store = $this->getMockBuilder(Store::class) ->disableOriginalConstructor() ->getMock(); - $this->website = $this->getMockBuilder(\Magento\Store\Model\Website::class) + $this->website = $this->getMockBuilder(Website::class) ->disableOriginalConstructor() ->getMock(); - $storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) + $storeManager = $this->getMockBuilder(StoreManagerInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $storeManager->expects($this->any()) @@ -232,44 +264,44 @@ protected function setUp() ->method('getWebsite') ->will($this->returnValue($this->website)); $this->indexerRegistryMock = $this->createPartialMock( - \Magento\Framework\Indexer\IndexerRegistry::class, + IndexerRegistry::class, ['get'] ); - $this->categoryRepository = $this->createMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); + $this->categoryRepository = $this->createMock(CategoryRepositoryInterface::class); $this->_catalogProduct = $this->createPartialMock( \Magento\Catalog\Helper\Product::class, ['isDataForProductCategoryIndexerWasChanged'] ); - $this->imageCache = $this->getMockBuilder(\Magento\Catalog\Model\Product\Image\Cache::class) + $this->imageCache = $this->getMockBuilder(Cache::class) ->disableOriginalConstructor() ->getMock(); - $this->imageCacheFactory = $this->getMockBuilder(\Magento\Catalog\Model\Product\Image\CacheFactory::class) + $this->imageCacheFactory = $this->getMockBuilder(CacheFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->productLinkFactory = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductLinkInterfaceFactory::class) + $this->productLinkFactory = $this->getMockBuilder(ProductLinkInterfaceFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->mediaGalleryEntryFactoryMock = - $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory::class) + $this->getMockBuilder(ProductAttributeMediaGalleryEntryInterfaceFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->metadataServiceMock = $this->createMock(\Magento\Catalog\Api\ProductAttributeRepositoryInterface::class); - $this->attributeValueFactory = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class) + $this->metadataServiceMock = $this->createMock(ProductAttributeRepositoryInterface::class); + $this->attributeValueFactory = $this->getMockBuilder(AttributeValueFactory::class) ->disableOriginalConstructor()->getMock(); $this->linkTypeProviderMock = $this->createPartialMock( - \Magento\Catalog\Model\Product\LinkTypeProvider::class, + LinkTypeProvider::class, ['getLinkTypes'] ); $this->entityCollectionProviderMock = $this->createPartialMock( - \Magento\Catalog\Model\ProductLink\CollectionProvider::class, + CollectionProvider::class, ['getCollection'] ); @@ -312,7 +344,7 @@ public function testGetProductLinks() $linkTypes = ['related' => 1, 'upsell' => 4, 'crosssell' => 5, 'associated' => 3]; $this->linkTypeProviderMock->expects($this->once())->method('getLinkTypes')->willReturn($linkTypes); - $inputRelatedLink = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\ProductLink\Link::class); + $inputRelatedLink = $this->objectManagerHelper->getObject(Link::class); $inputRelatedLink->setProductSku("Simple Product 1"); $inputRelatedLink->setLinkType("related"); $inputRelatedLink->setData("sku", "Simple Product 2"); @@ -320,7 +352,7 @@ public function testGetProductLinks() $inputRelatedLink->setPosition(0); $customData = ["attribute_code" => "qty", "value" => 1]; - $inputGroupLink = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\ProductLink\Link::class); + $inputGroupLink = $this->objectManagerHelper->getObject(Link::class); $inputGroupLink->setProductSku("Simple Product 1"); $inputGroupLink->setLinkType("associated"); $inputGroupLink->setData("sku", "Simple Product 2"); @@ -328,20 +360,20 @@ public function testGetProductLinks() $inputGroupLink->setPosition(0); $inputGroupLink["custom_attributes"] = [$customData]; - $outputRelatedLink = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\ProductLink\Link::class); + $outputRelatedLink = $this->objectManagerHelper->getObject(Link::class); $outputRelatedLink->setProductSku("Simple Product 1"); $outputRelatedLink->setLinkType("related"); $outputRelatedLink->setLinkedProductSku("Simple Product 2"); $outputRelatedLink->setLinkedProductType("simple"); $outputRelatedLink->setPosition(0); - $groupExtension = $this->objectManagerHelper->getObject(\Magento\Catalog\Api\Data\ProductLinkExtension::class); - $reflectionOfExtension = new \ReflectionClass(\Magento\Catalog\Api\Data\ProductLinkExtension::class); + $groupExtension = $this->objectManagerHelper->getObject(ProductLinkExtension::class); + $reflectionOfExtension = new \ReflectionClass(ProductLinkExtension::class); $method = $reflectionOfExtension->getMethod('setData'); $method->setAccessible(true); $method->invokeArgs($groupExtension, ['qty', 1]); - $outputGroupLink = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\ProductLink\Link::class); + $outputGroupLink = $this->objectManagerHelper->getObject(Link::class); $outputGroupLink->setProductSku("Simple Product 1"); $outputGroupLink->setLinkType("associated"); $outputGroupLink->setLinkedProductSku("Simple Product 2"); @@ -373,8 +405,8 @@ public function testGetProductLinks() $typeInstanceMock->expects($this->atLeastOnce())->method('getSku')->willReturn("Simple Product 1"); $this->model->setTypeInstance($typeInstanceMock); - $productLink1 = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\ProductLink\Link::class); - $productLink2 = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\ProductLink\Link::class); + $productLink1 = $this->objectManagerHelper->getObject(Link::class); + $productLink2 = $this->objectManagerHelper->getObject(Link::class); $this->productLinkFactory->expects($this->at(0)) ->method('create') ->willReturn($productLink1); @@ -382,7 +414,7 @@ public function testGetProductLinks() ->method('create') ->willReturn($productLink2); - $extension = $this->objectManagerHelper->getObject(\Magento\Catalog\Api\Data\ProductLinkExtension::class); + $extension = $this->objectManagerHelper->getObject(ProductLinkExtension::class); $productLink2->setExtensionAttributes($extension); $links = $this->model->getProductLinks(); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/ResourceModel/Product/Link/RelationPersisterTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/ResourceModel/Product/Link/RelationPersisterTest.php index 57466d551d296..35848102feab8 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/ResourceModel/Product/Link/RelationPersisterTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/ResourceModel/Product/Link/RelationPersisterTest.php @@ -1,20 +1,22 @@ -objectManager = new ObjectManager($this); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/Sales/AdminOrder/Product/Quote/Plugin/InitializerTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/Sales/AdminOrder/Product/Quote/Plugin/InitializerTest.php index afa4ef256ccc7..58c30fb3d493a 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/Sales/AdminOrder/Product/Quote/Plugin/InitializerTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/Sales/AdminOrder/Product/Quote/Plugin/InitializerTest.php @@ -1,19 +1,21 @@ -objectManagerHelper = new ObjectManagerHelper($this); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/Wishlist/Product/ItemTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/Wishlist/Product/ItemTest.php index 1edf5e8ce2d95..fac8c9c348f8e 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/Wishlist/Product/ItemTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/Wishlist/Product/ItemTest.php @@ -1,4 +1,4 @@ -subjectMock = $this->createPartialMock( \Magento\Wishlist\Model\Item::class, @@ -45,7 +51,7 @@ protected function setUp() ); $this->productMock = $this->createPartialMock( - \Magento\Catalog\Model\Product::class, + Product::class, [ 'getId', 'getTypeId', @@ -53,7 +59,7 @@ protected function setUp() ] ); - $this->model = new \Magento\GroupedProduct\Model\Wishlist\Product\Item(); + $this->model = new Item(); } /** @@ -73,7 +79,7 @@ public function testBeforeRepresentProduct() ] ]; - $superGroupObj = new \Magento\Framework\DataObject($superGroup); + $superGroupObj = new DataObject($superGroup); $this->productMock->expects($this->once())->method('getId')->willReturn($testSimpleProdId); $this->productMock->expects($this->once())->method('getTypeId') @@ -84,7 +90,7 @@ public function testBeforeRepresentProduct() ); $wishlistItemProductMock = $this->createPartialMock( - \Magento\Catalog\Model\Product::class, + Product::class, [ 'getId', ] @@ -143,7 +149,7 @@ private function getWishlistAssocOption($initVal, $resVal, $prodId) $items = []; $optionMock = $this->createPartialMock( - \Magento\Wishlist\Model\Item\Option::class, + Option::class, [ 'getValue', ] diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Pricing/Price/ConfiguredPriceTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Pricing/Price/ConfiguredPriceTest.php index 2306a6ae2ad90..a90533dc08a94 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Pricing/Price/ConfiguredPriceTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Pricing/Price/ConfiguredPriceTest.php @@ -1,4 +1,4 @@ -price = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class) + $this->price = $this->getMockBuilder(PriceInterface::class) ->getMock(); - $this->priceInfo = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfoInterface::class) + $this->priceInfo = $this->getMockBuilder(PriceInfoInterface::class) ->getMock(); - $this->saleableItem = $this->getMockBuilder(\Magento\Framework\Pricing\SaleableInterface::class) + $this->saleableItem = $this->getMockBuilder(SaleableInterface::class) ->setMethods([ 'getTypeId', 'getId', @@ -69,10 +82,10 @@ protected function setUp() ->method('getPriceInfo') ->willReturn($this->priceInfo); - $this->calculator = $this->getMockBuilder(\Magento\Framework\Pricing\Adjustment\CalculatorInterface::class) + $this->calculator = $this->getMockBuilder(CalculatorInterface::class) ->getMock(); - $this->priceCurrency = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class) + $this->priceCurrency = $this->getMockBuilder(PriceCurrencyInterface::class) ->getMock(); $this->model = new ConfiguredPrice( @@ -85,7 +98,7 @@ protected function setUp() public function testSetItem() { - $item = $this->getMockBuilder(\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class) + $item = $this->getMockBuilder(ItemInterface::class) ->getMock(); $this->model->setItem($item); @@ -113,7 +126,7 @@ public function testGetValue() $customOptionOneQty = rand(1, 9); $customOptionTwoQty = rand(1, 9); - $priceInfoBase = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class) + $priceInfoBase = $this->getMockBuilder(Base::class) ->disableOriginalConstructor() ->getMock(); $priceInfoBase->expects($this->any()) @@ -121,7 +134,7 @@ public function testGetValue() ->with(FinalPrice::PRICE_CODE) ->willReturn($this->price); - $productOne = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + $productOne = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() ->getMock(); $productOne->expects($this->once()) @@ -131,7 +144,7 @@ public function testGetValue() ->method('getPriceInfo') ->willReturn($priceInfoBase); - $productTwo = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + $productTwo = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() ->getMock(); $productTwo->expects($this->once()) @@ -145,25 +158,25 @@ public function testGetValue() ->method('getValue') ->willReturn($resultPrice); - $customOptionOne = $this->getMockBuilder(\Magento\Wishlist\Model\Item\Option::class) + $customOptionOne = $this->getMockBuilder(Option::class) ->disableOriginalConstructor() ->getMock(); $customOptionOne->expects($this->any()) ->method('getValue') ->willReturn($customOptionOneQty); - $customOptionTwo = $this->getMockBuilder(\Magento\Wishlist\Model\Item\Option::class) + $customOptionTwo = $this->getMockBuilder(Option::class) ->disableOriginalConstructor() ->getMock(); $customOptionTwo->expects($this->any()) ->method('getValue') ->willReturn($customOptionTwoQty); - $store = $this->getMockBuilder(\Magento\Store\Model\Store::class) + $store = $this->getMockBuilder(Store::class) ->disableOriginalConstructor() ->getMock(); - $groupedProduct = $this->getMockBuilder(\Magento\GroupedProduct\Model\Product\Type\Grouped::class) + $groupedProduct = $this->getMockBuilder(Grouped::class) ->disableOriginalConstructor() ->getMock(); $groupedProduct->expects($this->once()) @@ -188,7 +201,7 @@ public function testGetValue() ['associated_product_' . 2, $customOptionTwo], ]); - $item = $this->getMockBuilder(\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class) + $item = $this->getMockBuilder(ItemInterface::class) ->getMock(); $this->model->setItem($item); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Pricing/Price/FinalPriceTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Pricing/Price/FinalPriceTest.php index 97727b286c9cb..8644b142d1299 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Pricing/Price/FinalPriceTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Pricing/Price/FinalPriceTest.php @@ -1,4 +1,4 @@ -saleableItemMock = $this->createMock(\Magento\Catalog\Model\Product::class); - $this->calculatorMock = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class); + $this->saleableItemMock = $this->createMock(Product::class); + $this->calculatorMock = $this->createMock(Calculator::class); - $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->priceCurrencyMock = $this->createMock(PriceCurrencyInterface::class); - $this->finalPrice = new \Magento\GroupedProduct\Pricing\Price\FinalPrice( + $this->finalPrice = new FinalPrice( $this->saleableItemMock, null, $this->calculatorMock, @@ -54,7 +61,7 @@ public function testGetMinProduct() $product1 = $this->getProductMock(10); $product2 = $this->getProductMock(20); - $typeInstanceMock = $this->createMock(\Magento\GroupedProduct\Model\Product\Type\Grouped::class); + $typeInstanceMock = $this->createMock(Grouped::class); $typeInstanceMock->expects($this->once()) ->method('getAssociatedProducts') ->with($this->equalTo($this->saleableItemMock)) @@ -72,7 +79,7 @@ public function testGetValue() $product1 = $this->getProductMock(10); $product2 = $this->getProductMock(20); - $typeInstanceMock = $this->createMock(\Magento\GroupedProduct\Model\Product\Type\Grouped::class); + $typeInstanceMock = $this->createMock(Grouped::class); $typeInstanceMock->expects($this->once()) ->method('getAssociatedProducts') ->with($this->equalTo($this->saleableItemMock)) @@ -88,7 +95,7 @@ public function testGetValue() public function testGetValueWithoutMinProduct() { $typeInstanceMock = $this->createMock( - \Magento\GroupedProduct\Model\Product\Type\Grouped::class + Grouped::class ); $typeInstanceMock->expects($this->once()) ->method('getAssociatedProducts') @@ -104,7 +111,7 @@ public function testGetValueWithoutMinProduct() /** * @param $price - * @return \PHPUnit_Framework_MockObject_MockObject + * @return MockObject */ protected function getProductMock($price) { @@ -113,16 +120,16 @@ protected function getProductMock($price) ->method('getValue') ->will($this->returnValue($price)); - $priceInfoMock = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class); + $priceInfoMock = $this->createMock(Base::class); $priceInfoMock->expects($this->any()) ->method('getPrice') ->with($this->equalTo(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)) ->will($this->returnValue($priceTypeMock)); - $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $productMock = $this->createMock(Product::class); $productMock->expects($this->any()) ->method('setQty') - ->with($this->equalTo(\Magento\Framework\Pricing\PriceInfoInterface::PRODUCT_QUANTITY_DEFAULT)); + ->with($this->equalTo(PriceInfoInterface::PRODUCT_QUANTITY_DEFAULT)); $productMock->expects($this->any()) ->method('getPriceInfo') ->will($this->returnValue($priceInfoMock)); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php index 567061d370967..9ba633117f266 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php @@ -1,4 +1,4 @@ -objectManager = new ObjectManager($this); $this->locatorMock = $this->getMockBuilder(LocatorInterface::class) diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Ui/DataProvider/Product/GroupedProductDataProviderTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Ui/DataProvider/Product/GroupedProductDataProviderTest.php index 9a4662ffa42cc..cb3266d398dc5 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Ui/DataProvider/Product/GroupedProductDataProviderTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Ui/DataProvider/Product/GroupedProductDataProviderTest.php @@ -1,18 +1,20 @@ -objectManager = new ObjectManager($this);