diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Category/AbstractCategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Category/AbstractCategoryTest.php
index 9e290e4201576..707ec0976cc70 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Category/AbstractCategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Category/AbstractCategoryTest.php
@@ -3,54 +3,66 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Category;
-class AbstractCategoryTest extends \PHPUnit\Framework\TestCase
+use Magento\Backend\Block\Template\Context;
+use Magento\Catalog\Block\Adminhtml\Category\AbstractCategory;
+use Magento\Catalog\Model\Category;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\UrlInterface;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class AbstractCategoryTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManager;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $contextMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $storeManagerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $requestMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $urlBuilderMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $storeMock;
/**
- * @var \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
+ * @var AbstractCategory
*/
protected $category;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
- $this->contextMock = $this->createMock(\Magento\Backend\Block\Template\Context::class);
+ $this->contextMock = $this->createMock(Context::class);
$this->requestMock = $this->getMockBuilder(
- \Magento\Framework\App\RequestInterface::class
+ RequestInterface::class
)
->disableOriginalConstructor()
->getMock();
@@ -60,13 +72,13 @@ protected function setUp()
->will($this->returnValue($this->requestMock));
$this->urlBuilderMock = $this->getMockBuilder(
- \Magento\Framework\UrlInterface::class
+ UrlInterface::class
)
->disableOriginalConstructor()
->getMock();
$this->storeManagerMock = $this->getMockBuilder(
- \Magento\Store\Model\StoreManagerInterface::class
+ StoreManagerInterface::class
)
->disableOriginalConstructor()
->getMock();
@@ -75,7 +87,7 @@ protected function setUp()
->method('getStoreManager')
->will($this->returnValue($this->storeManagerMock));
- $this->storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class)
+ $this->storeMock = $this->getMockBuilder(Store::class)
->disableOriginalConstructor()
->getMock();
@@ -84,7 +96,7 @@ protected function setUp()
->will($this->returnValue($this->urlBuilderMock));
$this->category = $this->objectManager->getObject(
- \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory::class,
+ AbstractCategory::class,
[
'context' => $this->contextMock,
]
@@ -129,6 +141,6 @@ public function testGetRootIds()
$this->storeManagerMock->expects($this->once())->method('getGroups')->willReturn([$this->storeMock]);
$this->storeMock->expects($this->once())->method('getRootCategoryId')->willReturn('storeId');
- $this->assertEquals([\Magento\Catalog\Model\Category::TREE_ROOT_ID, 'storeId'], $this->category->getRootIds());
+ $this->assertEquals([Category::TREE_ROOT_ID, 'storeId'], $this->category->getRootIds());
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Button/CancelTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Button/CancelTest.php
index b50c6bc1e4b5b..5a455de7b5873 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Button/CancelTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Button/CancelTest.php
@@ -3,13 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Attribute\Button;
use Magento\Catalog\Block\Adminhtml\Product\Attribute\Button\Cancel;
-/**
- * Class CancelTest
- */
class CancelTest extends GenericTest
{
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Button/GenericTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Button/GenericTest.php
index 2388ee2cc30e9..ad00f189e1707 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Button/GenericTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Button/GenericTest.php
@@ -3,25 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Attribute\Button;
use Magento\Catalog\Block\Adminhtml\Product\Edit\Button\Generic;
use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\View\Element\UiComponent\Context;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class GenericTest
- */
-class GenericTest extends \PHPUnit\Framework\TestCase
+class GenericTest extends TestCase
{
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $contextMock;
/**
- * @var Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registryMock;
@@ -30,7 +31,7 @@ class GenericTest extends \PHPUnit\Framework\TestCase
*/
protected $objectManager;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
$this->contextMock = $this->getMockBuilder(Context::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Button/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Button/SaveTest.php
index 00093c3dd925d..f915b51b430c8 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Button/SaveTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Button/SaveTest.php
@@ -3,13 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Attribute\Button;
use Magento\Catalog\Block\Adminhtml\Product\Attribute\Button\Save;
-/**
- * Class SaveTest
- */
class SaveTest extends GenericTest
{
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php
index 4d9345d0b3f22..ca2757d4ea90b 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Attribute\Edit\Tab;
use Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced;
@@ -22,13 +24,14 @@
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test product attribute add/edit advanced form tab
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class AdvancedTest extends \PHPUnit\Framework\TestCase
+class AdvancedTest extends TestCase
{
/**
* @var Advanced
@@ -73,7 +76,7 @@ class AdvancedTest extends \PHPUnit\Framework\TestCase
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
$this->registry = $this->createMock(Registry::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/GridTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/GridTest.php
index 9fffbe71a4290..6a7c72f2a4a48 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/GridTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/GridTest.php
@@ -3,18 +3,28 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Attribute;
-class GridTest extends \PHPUnit\Framework\TestCase
+use Magento\Backend\Block\Template\Context;
+use Magento\Catalog\Block\Adminhtml\Product\Attribute\Grid;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Framework\Filesystem;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\UrlInterface;
+use PHPUnit\Framework\TestCase;
+
+class GridTest extends TestCase
{
public function testGetRowUrl()
{
- $attribute = $this->createMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
+ $attribute = $this->createMock(Attribute::class);
$attribute->expects($this->once())->method('getAttributeId')->will($this->returnValue(2));
- $filesystem = $this->createMock(\Magento\Framework\Filesystem::class);
+ $filesystem = $this->createMock(Filesystem::class);
- $urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class);
+ $urlBuilder = $this->createMock(UrlInterface::class);
$urlBuilder->expects(
$this->once()
)->method(
@@ -26,15 +36,15 @@ public function testGetRowUrl()
$this->returnValue('catalog/product_attribute/edit/id/2')
);
- $context = $this->createMock(\Magento\Backend\Block\Template\Context::class);
+ $context = $this->createMock(Context::class);
$context->expects($this->once())->method('getUrlBuilder')->will($this->returnValue($urlBuilder));
$context->expects($this->any())->method('getFilesystem')->will($this->returnValue($filesystem));
$data = ['context' => $context];
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- /** @var \Magento\Catalog\Block\Adminhtml\Product\Attribute\Grid $block */
- $block = $helper->getObject(\Magento\Catalog\Block\Adminhtml\Product\Attribute\Grid::class, $data);
+ $helper = new ObjectManager($this);
+ /** @var Grid $block */
+ $block = $helper->getObject(Grid::class, $data);
$this->assertEquals('catalog/product_attribute/edit/id/2', $block->getRowUrl($attribute));
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php
index da31c89053a7f..f29e71172ebe7 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php
@@ -3,57 +3,68 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Composite\Fieldset;
+use Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Options;
+use Magento\Catalog\Model\CategoryFactory;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Configuration\Item\OptionFactory;
+use Magento\Catalog\Model\ProductFactory;
+use Magento\Catalog\Model\ResourceModel\Product\Option;
+use Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory;
+use Magento\Framework\Data\CollectionFactory;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Element\Template\Context;
+use Magento\Framework\View\Layout;
+use PHPUnit\Framework\TestCase;
+
/**
* Test class for \Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Options
*
* @SuppressWarnings(PHPMD.LongVariable)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class OptionsTest extends \PHPUnit\Framework\TestCase
+class OptionsTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $_objectHelper;
/**
- * @var \Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Options
+ * @var Options
*/
protected $_optionsBlock;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Option
+ * @var Option
*/
protected $_optionResource;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->_optionResource = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Option::class);
+ $this->_objectHelper = new ObjectManager($this);
+ $this->_optionResource = $this->createMock(Option::class);
}
public function testGetOptionHtml()
{
$layout = $this->createPartialMock(
- \Magento\Framework\View\Layout::class,
+ Layout::class,
['getChildName', 'getBlock', 'renderElement']
);
$context = $this->_objectHelper->getObject(
- \Magento\Framework\View\Element\Template\Context::class,
+ Context::class,
['layout' => $layout]
);
- $optionFactoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\ValueFactory::class)
- ->setMethods(['create'])
- ->disableOriginalConstructor()
- ->getMock();
-
+ $optionFactoryMock = $this->createPartialMock('\Magento\Catalog\Model\Product\Option\ValueFactory', ['create']);
$option = $this->_objectHelper->getObject(
\Magento\Catalog\Model\Product\Option::class,
['resource' => $this->_optionResource, 'optionValueFactory' => $optionFactoryMock]
);
- $dateBlock = $this->getMockBuilder(\Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Options::class)
+ $dateBlock = $this->getMockBuilder(Options::class)
->setMethods(['setSkipJsReloadPrice'])
->setConstructorArgs(['context' => $context, 'option' => $option])
->disableOriginalConstructor()
@@ -65,26 +76,26 @@ public function testGetOptionHtml()
$layout->expects($this->any())->method('renderElement')->with('date', false)->will($this->returnValue('html'));
$this->_optionsBlock = $this->_objectHelper->getObject(
- \Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Options::class,
+ Options::class,
['context' => $context, 'option' => $option]
);
$itemOptFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Configuration\Item\OptionFactory::class,
+ OptionFactory::class,
['create']
);
$stockItemFactoryMock = $this->createPartialMock(
- \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory::class,
+ StockItemInterfaceFactory::class,
['create']
);
- $productFactoryMock = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']);
- $categoryFactoryMock = $this->createPartialMock(\Magento\Catalog\Model\CategoryFactory::class, ['create']);
+ $productFactoryMock = $this->createPartialMock(ProductFactory::class, ['create']);
+ $categoryFactoryMock = $this->createPartialMock(CategoryFactory::class, ['create']);
$this->_optionsBlock->setProduct(
$this->_objectHelper->getObject(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
[
- 'collectionFactory' => $this->createMock(\Magento\Framework\Data\CollectionFactory::class),
+ 'collectionFactory' => $this->createMock(CollectionFactory::class),
'itemOptionFactory' => $itemOptFactoryMock,
'stockItemFactory' => $stockItemFactoryMock,
'productFactory' => $productFactoryMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/InventoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/InventoryTest.php
index fb8a3d221b029..ac7008080a46f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/InventoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/InventoryTest.php
@@ -3,30 +3,38 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Action\Attribute\Tab;
-/**
- * Class InventoryTest
- */
-class InventoryTest extends \PHPUnit\Framework\TestCase
+use Magento\Backend\Block\Template\Context;
+use Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab\Inventory;
+use Magento\CatalogInventory\Api\StockConfigurationInterface;
+use Magento\CatalogInventory\Model\Source\Backorders;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class InventoryTest extends TestCase
{
/**
- * @var \Magento\CatalogInventory\Model\Source\Backorders|\PHPUnit_Framework_MockObject_MockObject
+ * @var Backorders|MockObject
*/
protected $backordersMock;
/**
- * @var \Magento\CatalogInventory\Api\StockConfigurationInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StockConfigurationInterface|MockObject
*/
protected $stockConfigurationMock;
/**
- * @var \Magento\Backend\Block\Template\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $contextMock;
/**
- * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $requestMock;
@@ -40,20 +48,20 @@ class InventoryTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
- $this->contextMock = $this->createPartialMock(\Magento\Backend\Block\Template\Context::class, ['getRequest']);
- $this->backordersMock = $this->createMock(\Magento\CatalogInventory\Model\Source\Backorders::class);
+ $this->contextMock = $this->createPartialMock(Context::class, ['getRequest']);
+ $this->backordersMock = $this->createMock(Backorders::class);
$this->stockConfigurationMock = $this->getMockForAbstractClass(
- \Magento\CatalogInventory\Api\StockConfigurationInterface::class,
+ StockConfigurationInterface::class,
[],
'',
false
);
$this->requestMock = $this->getMockForAbstractClass(
- \Magento\Framework\App\RequestInterface::class,
+ RequestInterface::class,
['getParam'],
'',
false
@@ -64,7 +72,7 @@ protected function setUp()
->will($this->returnValue($this->requestMock));
$this->inventory = $objectManager->getObject(
- \Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab\Inventory::class,
+ Inventory::class,
[
'context' => $this->contextMock,
'backorders' => $this->backordersMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/AddAttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/AddAttributeTest.php
index bcfa1b642dcbf..a6ad5a034b3d6 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/AddAttributeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/AddAttributeTest.php
@@ -3,41 +3,41 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Button;
use Magento\Catalog\Block\Adminhtml\Product\Edit\Button\AddAttribute;
-/**
- * Class AddAttributeTest
- */
class AddAttributeTest extends GenericTest
{
+ private const STUB_EXPECTED_CONFIG = [
+ 'label' => 'Add Attribute',
+ 'class' => 'action-secondary',
+ 'data_attribute' => [
+ 'mage-init' => [
+ 'Magento_Ui/js/form/button-adapter' => [
+ 'actions' => [
+ [
+ 'targetName' => 'product_form.product_form.add_attribute_modal',
+ 'actionName' => 'toggleModal'
+ ],
+ [
+ 'targetName' => 'product_form.product_form.add_attribute_modal.product_attributes_grid',
+ 'actionName' => 'render'
+ ]
+ ]
+ ]
+ ]
+ ],
+ 'on_click' => '',
+ 'sort_order' => 20
+ ];
+
public function testGetButtonData()
{
$this->assertEquals(
- [
- 'label' => __('Add Attribute'),
- 'class' => 'action-secondary',
- 'data_attribute' => [
- 'mage-init' => [
- 'Magento_Ui/js/form/button-adapter' => [
- 'actions' => [
- [
- 'targetName' => 'product_form.product_form.add_attribute_modal',
- 'actionName' => 'toggleModal'
- ],
- [
- 'targetName' =>
- 'product_form.product_form.add_attribute_modal.product_attributes_grid',
- 'actionName' => 'render'
- ]
- ]
- ]
- ]
- ],
- 'on_click' => '',
- 'sort_order' => 20
- ],
+ self::STUB_EXPECTED_CONFIG,
$this->getModel(AddAttribute::class)->getButtonData()
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/BackTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/BackTest.php
index 6b7b639b31ee2..af35427a2957e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/BackTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/BackTest.php
@@ -3,13 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Button;
use Magento\Catalog\Block\Adminhtml\Product\Edit\Button\Back;
-/**
- * Class BackTest
- */
class BackTest extends GenericTest
{
public function testGetButtonData()
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/CreateCategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/CreateCategoryTest.php
index 0d1bab9df346f..15357202c5729 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/CreateCategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/CreateCategoryTest.php
@@ -3,13 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Button;
use Magento\Catalog\Block\Adminhtml\Product\Edit\Button\CreateCategory;
-/**
- * Class CreateCategoryTest
- */
class CreateCategoryTest extends GenericTest
{
public function testGetButtonData()
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/GenericTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/GenericTest.php
index e5ab23d59572d..d5dd6b06de082 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/GenericTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/GenericTest.php
@@ -3,18 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Button;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Block\Adminhtml\Product\Edit\Button\Generic;
use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\View\Element\UiComponent\Context;
-use Magento\Catalog\Block\Adminhtml\Product\Edit\Button\Generic;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class GenericTest
- */
-class GenericTest extends \PHPUnit\Framework\TestCase
+class GenericTest extends TestCase
{
/**
* @var ObjectManager
@@ -22,21 +23,21 @@ class GenericTest extends \PHPUnit\Framework\TestCase
protected $objectManager;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $contextMock;
/**
- * @var Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registryMock;
/**
- * @var ProductInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductInterface|MockObject
*/
protected $productMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
$this->contextMock = $this->getMockBuilder(Context::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php
index 7f9a480394dca..0171224e225ec 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php
@@ -3,13 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Button;
use Magento\Catalog\Block\Adminhtml\Product\Edit\Button\Save;
-/**
- * Class SaveTest
- */
class SaveTest extends GenericTest
{
public function testGetButtonData()
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/AlertsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/AlertsTest.php
index 5d8db5d5ba589..92649ee54b269 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/AlertsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/AlertsTest.php
@@ -3,27 +3,36 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Tab;
-class AlertsTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\ScopeInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class AlertsTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts
+ * @var Alerts
*/
protected $alerts;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $scopeConfigMock;
- protected function setUp()
+ protected function setUp(): void
{
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $helper = new ObjectManager($this);
+ $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
$this->alerts = $helper->getObject(
- \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts::class,
+ Alerts::class,
['scopeConfig' => $this->scopeConfigMock]
);
}
@@ -40,13 +49,13 @@ public function testCanShowTab($priceAllow, $stockAllow, $canShowTab)
$valueMap = [
[
'catalog/productalert/allow_price',
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
null,
$priceAllow,
],
[
'catalog/productalert/allow_stock',
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
null,
$stockAllow
],
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php
index 19c578e976cdd..dc4a6f7de90ec 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php
@@ -3,57 +3,74 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Tab;
+use Magento\Backend\Block\Template\Context;
+use Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Inventory;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Type\AbstractType;
+use Magento\CatalogInventory\Api\Data\StockItemInterface;
+use Magento\CatalogInventory\Api\StockConfigurationInterface;
+use Magento\CatalogInventory\Api\StockRegistryInterface;
+use Magento\CatalogInventory\Model\Source\Backorders;
+use Magento\CatalogInventory\Model\Source\Stock;
+use Magento\Framework\Module\Manager;
+use Magento\Framework\Registry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
- * Class InventoryTest
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class InventoryTest extends \PHPUnit\Framework\TestCase
+class InventoryTest extends TestCase
{
/**
- * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject
+ * @var Manager|MockObject
*/
protected $moduleManager;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $coreRegistryMock;
/**
- * @var \Magento\CatalogInventory\Model\Source\Stock|\PHPUnit_Framework_MockObject_MockObject
+ * @var Stock|MockObject
*/
protected $stockMock;
/**
- * @var \Magento\CatalogInventory\Model\Source\Backorders|\PHPUnit_Framework_MockObject_MockObject
+ * @var Backorders|MockObject
*/
protected $backordersMock;
/**
- * @var \Magento\CatalogInventory\Api\StockRegistryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StockRegistryInterface|MockObject
*/
protected $stockRegistryMock;
/**
- * @var \Magento\CatalogInventory\Api\StockConfigurationInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StockConfigurationInterface|MockObject
*/
protected $stockConfigurationMock;
/**
- * @var \Magento\Backend\Block\Template\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $contextMock;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManagerMock;
/**
- * @var \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Inventory
+ * @var Inventory
*/
protected $inventory;
@@ -62,32 +79,32 @@ class InventoryTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->contextMock = $this->createPartialMock(
- \Magento\Backend\Block\Template\Context::class,
+ Context::class,
['getRequest', 'getStoreManager']
);
$this->stockConfigurationMock = $this->getMockForAbstractClass(
- \Magento\CatalogInventory\Api\StockConfigurationInterface::class,
+ StockConfigurationInterface::class,
[],
'',
false
);
$this->stockRegistryMock = $this->getMockForAbstractClass(
- \Magento\CatalogInventory\Api\StockRegistryInterface::class,
+ StockRegistryInterface::class,
[],
'',
false
);
- $this->backordersMock = $this->createMock(\Magento\CatalogInventory\Model\Source\Backorders::class);
- $this->stockMock = $this->createMock(\Magento\CatalogInventory\Model\Source\Stock::class);
- $this->coreRegistryMock = $this->createMock(\Magento\Framework\Registry::class);
- $this->moduleManager = $this->createMock(\Magento\Framework\Module\Manager::class);
+ $this->backordersMock = $this->createMock(Backorders::class);
+ $this->stockMock = $this->createMock(Stock::class);
+ $this->coreRegistryMock = $this->createMock(Registry::class);
+ $this->moduleManager = $this->createMock(Manager::class);
$this->storeManagerMock = $this->getMockForAbstractClass(
- \Magento\Store\Model\StoreManagerInterface::class,
+ StoreManagerInterface::class,
[],
'',
false
@@ -98,7 +115,7 @@ protected function setUp()
->will($this->returnValue($this->storeManagerMock));
$this->inventory = $objectManager->getObject(
- \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Inventory::class,
+ Inventory::class,
[
'context' => $this->contextMock,
'backorders' => $this->backordersMock,
@@ -184,8 +201,8 @@ public function testGetStockItem()
{
$productId = 10;
$websiteId = 15;
- $productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getId', 'getStore']);
- $storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getWebsiteId']);
+ $productMock = $this->createPartialMock(Product::class, ['getId', 'getStore']);
+ $storeMock = $this->createPartialMock(Store::class, ['getWebsiteId']);
$productMock->expects($this->once())
->method('getId')
->will($this->returnValue($productId));
@@ -225,7 +242,7 @@ public function testGetFieldValue($stockId, $methods, $result)
$fieldName = 'field';
$stockItemMock = $this->getMockForAbstractClass(
- \Magento\CatalogInventory\Api\Data\StockItemInterface::class,
+ StockItemInterface::class,
[],
'',
false,
@@ -233,8 +250,8 @@ public function testGetFieldValue($stockId, $methods, $result)
false,
$methods
);
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
+ $productMock = $this->createMock(Product::class);
+ $storeMock = $this->createMock(Store::class);
$productMock->expects($this->once())
->method('getId')
->will($this->returnValue($productId));
@@ -288,7 +305,7 @@ public function testGetConfigFieldValue($stockId, $methods, $result)
$fieldName = 'field';
$stockItemMock = $this->getMockForAbstractClass(
- \Magento\CatalogInventory\Api\Data\StockItemInterface::class,
+ StockItemInterface::class,
[],
'',
false,
@@ -296,8 +313,8 @@ public function testGetConfigFieldValue($stockId, $methods, $result)
false,
$methods
);
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
+ $productMock = $this->createMock(Product::class);
+ $storeMock = $this->createMock(Store::class);
$productMock->expects($this->once())
->method('getId')
->will($this->returnValue($productId));
@@ -357,7 +374,7 @@ public function testGetDefaultConfigValue()
*/
public function testIsReadonly()
{
- $productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getInventoryReadonly']);
+ $productMock = $this->createPartialMock(Product::class, ['getInventoryReadonly']);
$this->coreRegistryMock->expects($this->once())
->method('registry')
->with('product')
@@ -382,7 +399,7 @@ public function testIsReadonly()
*/
public function testIsNew($id, $result)
{
- $productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getId']);
+ $productMock = $this->createPartialMock(Product::class, ['getId']);
$this->coreRegistryMock->expects($this->once())
->method('registry')
->with('product')
@@ -413,9 +430,9 @@ public function testGetFieldSuffix()
*/
public function testCanUseQtyDecimals()
{
- $productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getTypeInstance']);
+ $productMock = $this->createPartialMock(Product::class, ['getTypeInstance']);
$typeMock = $this->getMockForAbstractClass(
- \Magento\Catalog\Model\Product\Type\AbstractType::class,
+ AbstractType::class,
[],
'',
false,
@@ -445,7 +462,7 @@ public function testCanUseQtyDecimals()
*/
public function testIsVirtual()
{
- $productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getIsVirtual']);
+ $productMock = $this->createPartialMock(Product::class, ['getIsVirtual']);
$this->coreRegistryMock->expects($this->once())
->method('registry')
->with('product')
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/CategoryTest.php
index 1fc105686011f..0cd88ff9b121a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/CategoryTest.php
@@ -3,26 +3,33 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Helper\Form;
-class CategoryTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category;
+use Magento\Framework\AuthorizationInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
+class CategoryTest extends TestCase
{
/**
- * @var \Magento\Framework\AuthorizationInterface
+ * @var AuthorizationInterface
*/
protected $authorization;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManager;
- protected function setUp()
+ protected function setUp(): void
{
- $this->authorization = $this->getMockBuilder(\Magento\Framework\AuthorizationInterface::class)
+ $this->authorization = $this->getMockBuilder(AuthorizationInterface::class)
->disableOriginalConstructor()
->getMock();
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
}
/**
@@ -35,7 +42,7 @@ public function testIsAllowed($isAllowed)
->method('isAllowed')
->will($this->returnValue($isAllowed));
$model = $this->objectManager->getObject(
- \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category::class,
+ Category::class,
['authorization' => $this->authorization]
);
switch ($isAllowed) {
@@ -64,7 +71,7 @@ public function isAllowedDataProvider()
public function testGetAfterElementHtml()
{
$model = $this->objectManager->getObject(
- \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category::class,
+ Category::class,
['authorization' => $this->authorization]
);
$this->authorization->expects($this->any())
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php
index 9a2199859a1df..648a83b53c171 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php
@@ -3,77 +3,90 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Helper\Form\Gallery;
+use Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery;
use Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery\Content;
+use Magento\Catalog\Helper\Image;
use Magento\Catalog\Model\Entity\Attribute;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Media\Config;
+use Magento\Framework\Exception\FileSystemException;
+use Magento\Framework\Filesystem;
+use Magento\Framework\Filesystem\Directory\Read;
+use Magento\Framework\Filesystem\Directory\ReadInterface;
+use Magento\Framework\Json\EncoderInterface;
use Magento\Framework\Phrase;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\MediaStorage\Helper\File\Storage\Database;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ContentTest extends \PHPUnit\Framework\TestCase
+class ContentTest extends TestCase
{
/**
- * @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject
+ * @var Filesystem|MockObject
*/
protected $fileSystemMock;
/**
- * @var \Magento\Framework\Filesystem\Directory\Read|\PHPUnit_Framework_MockObject_MockObject
+ * @var Read|MockObject
*/
protected $readMock;
/**
- * @var Content|\PHPUnit_Framework_MockObject_MockObject
+ * @var Content|MockObject
*/
protected $content;
/**
- * @var \Magento\Catalog\Model\Product\Media\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
protected $mediaConfigMock;
/**
- * @var \Magento\Framework\Json\EncoderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var EncoderInterface|MockObject
*/
protected $jsonEncoderMock;
/**
- * @var \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery|\PHPUnit_Framework_MockObject_MockObject
+ * @var Gallery|MockObject
*/
protected $galleryMock;
/**
- * @var \Magento\Catalog\Helper\Image|\PHPUnit_Framework_MockObject_MockObject
+ * @var Image|MockObject
*/
protected $imageHelper;
/**
- * @var \Magento\MediaStorage\Helper\File\Storage\Database|\PHPUnit_Framework_MockObject_MockObject
+ * @var Database|MockObject
*/
protected $databaseMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManager;
- public function setUp()
+ public function setUp(): void
{
$this->fileSystemMock = $this->createPartialMock(
- \Magento\Framework\Filesystem::class,
+ Filesystem::class,
['stat', 'getDirectoryRead']
);
- $this->readMock = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class);
- $this->galleryMock = $this->createMock(\Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery::class);
+ $this->readMock = $this->createMock(ReadInterface::class);
+ $this->galleryMock = $this->createMock(Gallery::class);
$this->mediaConfigMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Media\Config::class,
+ Config::class,
['getMediaUrl', 'getMediaPath']
);
- $this->jsonEncoderMock = $this->getMockBuilder(\Magento\Framework\Json\EncoderInterface::class)
+ $this->jsonEncoderMock = $this->getMockBuilder(EncoderInterface::class)
->disableOriginalConstructor()
->getMock();
@@ -81,9 +94,9 @@ public function setUp()
->disableOriginalConstructor()
->getMock();
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
$this->content = $this->objectManager->getObject(
- \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery\Content::class,
+ Content::class,
[
'mediaConfig' => $this->mediaConfigMock,
'jsonEncoder' => $this->jsonEncoderMock,
@@ -174,7 +187,7 @@ public function testGetImagesJsonWithoutImages()
public function testGetImagesJsonWithException()
{
- $this->imageHelper = $this->getMockBuilder(\Magento\Catalog\Helper\Image::class)
+ $this->imageHelper = $this->getMockBuilder(Image::class)
->disableOriginalConstructor()
->setMethods(['getDefaultPlaceholderUrl'])
->getMock();
@@ -238,10 +251,10 @@ public function testGetImagesJsonWithException()
$this->readMock->expects($this->any())->method('stat')->willReturnOnConsecutiveCalls(
$this->throwException(
- new \Magento\Framework\Exception\FileSystemException(new Phrase('test'))
+ new FileSystemException(new Phrase('test'))
),
$this->throwException(
- new \Magento\Framework\Exception\FileSystemException(new Phrase('test'))
+ new FileSystemException(new Phrase('test'))
)
);
$this->imageHelper->expects($this->any())->method('getDefaultPlaceholderUrl')->willReturn($placeholderUrl);
@@ -369,7 +382,7 @@ private function getImageTypesAssertions(string $attributeCode, string $scopeLab
*
* @param string $label
* @param string $attributeCode
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
private function getMediaAttribute(string $label, string $attributeCode)
{
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/GalleryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/GalleryTest.php
index 1e04680676eb2..b1426d7636342 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/GalleryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/GalleryTest.php
@@ -3,54 +3,64 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Helper\Form;
+use Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Framework\App\Request\DataPersistorInterface;
+use Magento\Framework\Data\Form;
+use Magento\Framework\Registry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class GalleryTest extends \PHPUnit\Framework\TestCase
+class GalleryTest extends TestCase
{
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registryMock;
/**
- * @var \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery|\PHPUnit_Framework_MockObject_MockObject
+ * @var Gallery|MockObject
*/
protected $gallery;
/**
- * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
protected $productMock;
/**
- * @var \Magento\Framework\Data\Form|\PHPUnit_Framework_MockObject_MockObject
+ * @var Form|MockObject
*/
protected $formMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManager;
/**
- * @var DataPersistorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var DataPersistorInterface|MockObject
*/
private $dataPersistorMock;
- public function setUp()
+ public function setUp(): void
{
- $this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
- $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getData']);
- $this->formMock = $this->createMock(\Magento\Framework\Data\Form::class);
+ $this->registryMock = $this->createMock(Registry::class);
+ $this->productMock = $this->createPartialMock(Product::class, ['getData']);
+ $this->formMock = $this->createMock(Form::class);
$this->dataPersistorMock = $this->getMockBuilder(DataPersistorInterface::class)
->disableOriginalConstructor()
->setMethods(['get'])
->getMockForAbstractClass();
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
$this->gallery = $this->objectManager->getObject(
- \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery::class,
+ Gallery::class,
[
'registry' => $this->registryMock,
'form' => $this->formMock,
@@ -154,7 +164,7 @@ public function testGetAttributeFieldName()
{
$name = 'product[image]';
- $attribute = $this->createMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
+ $attribute = $this->createMock(Attribute::class);
$attribute->expects($this->once())->method('getAttributeCode')->willReturn('image');
$this->formMock->expects($this->once())->method('addSuffixToName')->willReturn($name);
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php
index 2b11d62961007..7ebe3d6575820 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Helper\Form;
use Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight;
@@ -42,7 +44,7 @@ class WeightTest extends TestCase
*/
protected $localeFormat;
- protected function setUp()
+ protected function setUp(): void
{
$this->weightSwitcher = $this->createPartialMock(
Radios::class,
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php
index 7f1b4a8ea7ee7..dbf58f0ed8e4c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php
@@ -3,46 +3,60 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Options;
+use Magento\Backend\Block\Context;
+use Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Option;
+use Magento\Catalog\Block\Adminhtml\Product\Options\Ajax;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ProductFactory;
+use Magento\Framework\App\Config;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\Event\Manager;
+use Magento\Framework\Json\EncoderInterface;
+use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\View\LayoutInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class AjaxTest extends \PHPUnit\Framework\TestCase
+class AjaxTest extends TestCase
{
- /** @var \Magento\Catalog\Block\Adminhtml\Product\Options\Ajax */
+ /** @var Ajax */
protected $block;
/** @var ObjectManagerHelper */
protected $objectManagerHelper;
- /** @var \Magento\Backend\Block\Context|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Context|MockObject */
protected $context;
- /** @var \Magento\Framework\Json\EncoderInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var EncoderInterface|MockObject */
protected $encoderInterface;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
protected $productFactory;
- /** @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Registry|MockObject */
protected $registry;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->context = $this->getMockBuilder(\Magento\Backend\Block\Context::class)
+ $this->context = $this->getMockBuilder(Context::class)
->setMethods(['getEventManager', 'getScopeConfig', 'getLayout', 'getRequest'])
->disableOriginalConstructor()
->getMock();
- $this->encoderInterface = $this->createMock(\Magento\Framework\Json\EncoderInterface::class);
- $this->productFactory = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']);
- $this->registry = $this->createMock(\Magento\Framework\Registry::class);
+ $this->encoderInterface = $this->createMock(EncoderInterface::class);
+ $this->productFactory = $this->createPartialMock(ProductFactory::class, ['create']);
+ $this->registry = $this->createMock(Registry::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
}
@@ -52,26 +66,26 @@ protected function setUp()
*/
public function testToHtml()
{
- $eventManager = $this->getMockBuilder(\Magento\Framework\Event\Manager::class)
+ $eventManager = $this->getMockBuilder(Manager::class)
->disableOriginalConstructor()
->setMethods(['dispatch'])
->getMock();
$eventManager->expects($this->exactly(2))->method('dispatch')->will($this->returnValue(true));
- $scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config::class)
+ $scopeConfig = $this->getMockBuilder(Config::class)
->setMethods(['getValue'])
->disableOriginalConstructor()->getMock();
$scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()
->will($this->returnValue(false));
- $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()
+ $product = $this->getMockBuilder(Product::class)->disableOriginalConstructor()
->setMethods(['setStoreId', 'load', 'getId', '__wakeup', '__sleep'])
->getMock();
$product->expects($this->once())->method('setStoreId')->will($this->returnSelf());
$product->expects($this->once())->method('load')->will($this->returnSelf());
$product->expects($this->once())->method('getId')->will($this->returnValue(1));
- $optionsBlock = $this->getMockBuilder(\Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Option::class)
+ $optionsBlock = $this->getMockBuilder(Option::class)
->setMethods(['setIgnoreCaching', 'setProduct', 'getOptionValues'])
->disableOriginalConstructor()
->getMock();
@@ -79,15 +93,15 @@ public function testToHtml()
$optionsBlock->expects($this->once())->method('setProduct')->with($product)->will($this->returnSelf());
$optionsBlock->expects($this->once())->method('getOptionValues')->will($this->returnValue([]));
- $layout = $this->getMockBuilder(\Magento\Framework\View\Layout\Element\Layout::class)
+ $layout = $this->getMockBuilder(LayoutInterface::class)
->disableOriginalConstructor()
->setMethods(['createBlock'])
- ->getMock();
+ ->getMockForAbstractClass();
$layout->expects($this->once())->method('createBlock')
- ->with(\Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Option::class)
+ ->with(Option::class)
->will($this->returnValue($optionsBlock));
- $request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
+ $request = $this->getMockBuilder(Http::class)
->setMethods(['getParam'])
->disableOriginalConstructor()
->getMock();
@@ -108,7 +122,7 @@ public function testToHtml()
$this->productFactory->expects($this->once())->method('create')->will($this->returnValue($product));
$this->block = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Block\Adminhtml\Product\Options\Ajax::class,
+ Ajax::class,
[
'context' => $this->context,
'jsonEncoder' => $this->encoderInterface,
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/Grid/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/Grid/LinkTest.php
index fd5feaaef83a9..ed1c07d40d057 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/Grid/LinkTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/Grid/LinkTest.php
@@ -3,18 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Rss\Grid;
+use Magento\Catalog\Block\Adminhtml\Rss\Grid\Link;
+use Magento\Framework\App\Rss\UrlBuilderInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class LinkTest
- * @package Magento\Catalog\Block\Adminhtml\Rss\Grid
- */
-class LinkTest extends \PHPUnit\Framework\TestCase
+class LinkTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Adminhtml\Rss\Grid\Link
+ * @var Link
*/
protected $link;
@@ -24,17 +26,17 @@ class LinkTest extends \PHPUnit\Framework\TestCase
protected $objectManagerHelper;
/**
- * @var \Magento\Framework\App\Rss\UrlBuilderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlBuilderInterface|MockObject
*/
protected $urlBuilderInterface;
- protected function setUp()
+ protected function setUp(): void
{
- $this->urlBuilderInterface = $this->createMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class);
+ $this->urlBuilderInterface = $this->createMock(UrlBuilderInterface::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->link = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Block\Adminhtml\Rss\Grid\Link::class,
+ Link::class,
[
'rssUrlBuilder' => $this->urlBuilderInterface
]
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/NotifyStockTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/NotifyStockTest.php
index da35d845468d5..c9229a93bc834 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/NotifyStockTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Rss/NotifyStockTest.php
@@ -3,18 +3,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Rss;
+use Magento\Backend\Block\Context;
+use Magento\Catalog\Block\Adminhtml\Rss\NotifyStock;
+use Magento\Catalog\Model\Product;
+use Magento\Framework\App\Rss\UrlBuilderInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\UrlInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class NotifyStockTest
- * @package Magento\Catalog\Block\Adminhtml\Rss
- */
-class NotifyStockTest extends \PHPUnit\Framework\TestCase
+class NotifyStockTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Adminhtml\Rss\NotifyStock
+ * @var NotifyStock
*/
protected $block;
@@ -24,22 +29,22 @@ class NotifyStockTest extends \PHPUnit\Framework\TestCase
protected $objectManagerHelper;
/**
- * @var \Magento\Backend\Block\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $context;
/**
- * @var \Magento\Catalog\Model\Rss\Product\NotifyStock|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Model\Rss\Product\NotifyStock|MockObject
*/
protected $rssModel;
/**
- * @var \Magento\Framework\App\Rss\UrlBuilderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlBuilderInterface|MockObject
*/
protected $rssUrlBuilder;
/**
- * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlInterface|MockObject
*/
protected $urlBuilder;
@@ -61,16 +66,16 @@ class NotifyStockTest extends \PHPUnit\Framework\TestCase
],
];
- protected function setUp()
+ protected function setUp(): void
{
$this->rssModel = $this->getMockBuilder(\Magento\Catalog\Model\Rss\Product\NotifyStock::class)
->setMethods(['getProductsCollection', '__wakeup'])
->disableOriginalConstructor()->getMock();
- $this->rssUrlBuilder = $this->createMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class);
- $this->urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class);
+ $this->rssUrlBuilder = $this->createMock(UrlBuilderInterface::class);
+ $this->urlBuilder = $this->createMock(UrlInterface::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->block = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Block\Adminhtml\Rss\NotifyStock::class,
+ NotifyStock::class,
[
'urlBuilder' => $this->urlBuilder,
'rssModel' => $this->rssModel,
@@ -83,7 +88,7 @@ public function testGetRssData()
{
$this->rssUrlBuilder->expects($this->once())->method('getUrl')
->will($this->returnValue('http://magento.com/rss/feeds/index/type/notifystock'));
- $item = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $item = $this->getMockBuilder(Product::class)
->setMethods(['__sleep', '__wakeup', 'getId', 'getQty', 'getName'])
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Category/Plugin/PriceBoxTagsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Category/Plugin/PriceBoxTagsTest.php
index 3f388d00eaf9f..ab01b89590e28 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Category/Plugin/PriceBoxTagsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Category/Plugin/PriceBoxTagsTest.php
@@ -3,65 +3,82 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Block\Category\Plugin;
+use Magento\Catalog\Block\Category\Plugin\PriceBoxTags;
+use Magento\Customer\Model\Session;
+use Magento\Directory\Model\Currency;
+use Magento\Framework\App\ScopeInterface;
+use Magento\Framework\App\ScopeResolverInterface;
+use Magento\Framework\DataObject;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\Pricing\Render\PriceBox;
+use Magento\Framework\Pricing\SaleableInterface;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Tax\Model\Calculation;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class PriceBoxTagsTest extends \PHPUnit\Framework\TestCase
+class PriceBoxTagsTest extends TestCase
{
/**
- * @var \Magento\Framework\Pricing\PriceCurrencyInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var PriceCurrencyInterface|MockObject
*/
private $priceCurrencyInterface;
/**
- * @var \Magento\Directory\Model\Currency | \PHPUnit_Framework_MockObject_MockObject
+ * @var Currency|MockObject
*/
private $currency;
/**
- * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var TimezoneInterface|MockObject
*/
private $timezoneInterface;
/**
- * @var \Magento\Framework\App\ScopeResolverInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeResolverInterface|MockObject
*/
private $scopeResolverInterface;
/**
- * @var \Magento\Customer\Model\Session | \PHPUnit_Framework_MockObject_MockObject
+ * @var Session|MockObject
*/
private $session;
/**
- * @var \Magento\Tax\Model\Calculation | \PHPUnit_Framework_MockObject_MockObject
+ * @var Calculation|MockObject
*/
private $taxCalculation;
/**
- * @var \Magento\Catalog\Block\Category\Plugin\PriceBoxTags
+ * @var PriceBoxTags
*/
private $priceBoxTags;
- protected function setUp()
+ protected function setUp(): void
{
$this->priceCurrencyInterface = $this->getMockBuilder(
- \Magento\Framework\Pricing\PriceCurrencyInterface::class
+ PriceCurrencyInterface::class
)->getMock();
- $this->currency = $this->getMockBuilder(\Magento\Directory\Model\Currency::class)
+ $this->currency = $this->getMockBuilder(Currency::class)
->disableOriginalConstructor()
->getMock();
$this->timezoneInterface = $this->getMockBuilder(
- \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class
+ TimezoneInterface::class
)->getMock();
$this->scopeResolverInterface = $this->getMockBuilder(
- \Magento\Framework\App\ScopeResolverInterface::class
+ ScopeResolverInterface::class
)
->getMockForAbstractClass();
- $this->session = $this->getMockBuilder(\Magento\Customer\Model\Session::class)->disableOriginalConstructor()
+ $this->session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()
->setMethods(
[
'getCustomerGroupId',
@@ -72,11 +89,11 @@ protected function setUp()
]
)
->getMock();
- $this->taxCalculation = $this->getMockBuilder(\Magento\Tax\Model\Calculation::class)
+ $this->taxCalculation = $this->getMockBuilder(Calculation::class)
->disableOriginalConstructor()->getMock();
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->priceBoxTags = $objectManager->getObject(
- \Magento\Catalog\Block\Category\Plugin\PriceBoxTags::class,
+ PriceBoxTags::class,
[
'priceCurrency' => $this->priceCurrencyInterface,
'dateTime' => $this->timezoneInterface,
@@ -110,11 +127,11 @@ public function testAfterGetCacheKey()
implode('_', $rateIds)
]
);
- $priceBox = $this->getMockBuilder(\Magento\Framework\Pricing\Render\PriceBox::class)
+ $priceBox = $this->getMockBuilder(PriceBox::class)
->disableOriginalConstructor()->getMock();
$this->priceCurrencyInterface->expects($this->once())->method('getCurrency')->willReturn($this->currency);
$this->currency->expects($this->once())->method('getCode')->willReturn($currencyCode);
- $scope = $this->getMockBuilder(\Magento\Framework\App\ScopeInterface::class)->getMock();
+ $scope = $this->getMockBuilder(ScopeInterface::class)->getMock();
$this->scopeResolverInterface->expects($this->any())->method('getScope')->willReturn($scope);
$scope->expects($this->any())->method('getId')->willReturn($scopeId);
$dateTime = $this->getMockBuilder(\DateTime::class)->getMock();
@@ -126,20 +143,20 @@ public function testAfterGetCacheKey()
$this->session->expects($this->once())->method('getCustomerTaxClassId')
->willReturn($customerTaxClassId);
$this->session->expects($this->once())->method('getCustomerId')->willReturn($customerId);
- $rateRequest = $this->getMockBuilder(\Magento\Framework\DataObject::class)->getMock();
+ $rateRequest = $this->getMockBuilder(DataObject::class)->getMock();
$this->taxCalculation->expects($this->once())->method('getRateRequest')->with(
- new \Magento\Framework\DataObject($shippingAddress),
- new \Magento\Framework\DataObject($billingAddress),
+ new DataObject($shippingAddress),
+ new DataObject($billingAddress),
$customerTaxClassId,
$scopeId,
$customerId
)->willReturn($rateRequest);
- $salableInterface = $this->getMockBuilder(\Magento\Framework\Pricing\SaleableInterface::class)
+ $salableInterface = $this->getMockBuilder(SaleableInterface::class)
->setMethods(['getTaxClassId'])
->getMockForAbstractClass();
$priceBox->expects($this->once())->method('getSaleableItem')->willReturn($salableInterface);
$salableInterface->expects($this->once())->method('getTaxClassId')->willReturn($customerTaxClassId);
- $resource = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\AbstractResource::class)
+ $resource = $this->getMockBuilder(AbstractResource::class)
->setMethods(['getRateIds'])
->getMockForAbstractClass();
$this->taxCalculation->expects($this->once())->method('getResource')->willReturn($resource);
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Category/Rss/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Category/Rss/LinkTest.php
index 0cff8b2d0f207..2e4a0cfde1eec 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Category/Rss/LinkTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Category/Rss/LinkTest.php
@@ -3,18 +3,24 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Category\Rss;
+use Magento\Catalog\Block\Category\Rss\Link;
+use Magento\Catalog\Model\Category;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\Rss\UrlBuilderInterface;
+use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class LinkTest
- * @package Magento\Catalog\Block\Category\Rss
- */
-class LinkTest extends \PHPUnit\Framework\TestCase
+class LinkTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Category\Rss\Link
+ * @var Link
*/
protected $link;
@@ -24,35 +30,35 @@ class LinkTest extends \PHPUnit\Framework\TestCase
protected $objectManagerHelper;
/**
- * @var \Magento\Framework\App\Rss\UrlBuilderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlBuilderInterface|MockObject
*/
protected $urlBuilderInterface;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $scopeConfigInterface;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManagerInterface;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registry;
- protected function setUp()
+ protected function setUp(): void
{
- $this->urlBuilderInterface = $this->createMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class);
- $this->scopeConfigInterface = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
- $this->storeManagerInterface = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->registry = $this->createMock(\Magento\Framework\Registry::class);
+ $this->urlBuilderInterface = $this->createMock(UrlBuilderInterface::class);
+ $this->scopeConfigInterface = $this->createMock(ScopeConfigInterface::class);
+ $this->storeManagerInterface = $this->createMock(StoreManagerInterface::class);
+ $this->registry = $this->createMock(Registry::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->link = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Block\Category\Rss\Link::class,
+ Link::class,
[
'rssUrlBuilder' => $this->urlBuilderInterface,
'registry' => $this->registry,
@@ -95,7 +101,7 @@ public function testGetLabel()
*/
public function testIsTopCategory($isTop, $categoryLevel)
{
- $categoryModel = $this->createPartialMock(\Magento\Catalog\Model\Category::class, ['__wakeup', 'getLevel']);
+ $categoryModel = $this->createPartialMock(Category::class, ['__wakeup', 'getLevel']);
$this->registry->expects($this->once())->method('registry')->will($this->returnValue($categoryModel));
$categoryModel->expects($this->any())->method('getLevel')->will($this->returnValue($categoryLevel));
$this->assertEquals($isTop, $this->link->isTopCategory());
@@ -117,11 +123,11 @@ public function testGetLink()
$rssUrl = 'http://rss.magento.com';
$this->urlBuilderInterface->expects($this->once())->method('getUrl')->will($this->returnValue($rssUrl));
- $categoryModel = $this->createPartialMock(\Magento\Catalog\Model\Category::class, ['__wakeup', 'getId']);
+ $categoryModel = $this->createPartialMock(Category::class, ['__wakeup', 'getId']);
$this->registry->expects($this->once())->method('registry')->will($this->returnValue($categoryModel));
$categoryModel->expects($this->any())->method('getId')->will($this->returnValue('1'));
- $storeModel = $this->createPartialMock(\Magento\Catalog\Model\Category::class, ['__wakeup', 'getId']);
+ $storeModel = $this->createPartialMock(Category::class, ['__wakeup', 'getId']);
$this->storeManagerInterface->expects($this->any())->method('getStore')->will($this->returnValue($storeModel));
$storeModel->expects($this->any())->method('getId')->will($this->returnValue('1'));
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Category/ViewTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Category/ViewTest.php
index 9d282befff2f9..8820f76605746 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Category/ViewTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Category/ViewTest.php
@@ -3,27 +3,36 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Category;
-class ViewTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Block\Category\View;
+use Magento\Catalog\Model\Category;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ViewTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Category\View
+ * @var View
*/
protected $block;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $scopeConfigMock;
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->block = $objectManager->getObject(\Magento\Catalog\Block\Category\View::class, []);
+ $objectManager = new ObjectManager($this);
+ $this->block = $objectManager->getObject(View::class, []);
}
- protected function tearDown()
+ protected function tearDown(): void
{
$this->block = null;
}
@@ -31,7 +40,7 @@ protected function tearDown()
public function testGetIdentities()
{
$categoryTag = ['catalog_category_1'];
- $currentCategoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $currentCategoryMock = $this->createMock(Category::class);
$currentCategoryMock->expects($this->once())->method('getIdentities')->will($this->returnValue($categoryTag));
$this->block->setCurrentCategory($currentCategoryMock);
$this->assertEquals($categoryTag, $this->block->getIdentities());
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/FrontendStorageManagerTest.php b/app/code/Magento/Catalog/Test/Unit/Block/FrontendStorageManagerTest.php
index 92c3d1bfeb1b3..e2b4fe886c0ce 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/FrontendStorageManagerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/FrontendStorageManagerTest.php
@@ -3,38 +3,45 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block;
+use Magento\Catalog\Block\FrontendStorageManager;
use Magento\Catalog\Model\FrontendStorageConfigurationInterface;
+use Magento\Catalog\Model\FrontendStorageConfigurationPool;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\View\Element\Template\Context;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class FrontendStorageManagerTest extends \PHPUnit\Framework\TestCase
+class FrontendStorageManagerTest extends TestCase
{
- /** @var \Magento\Catalog\Block\FrontendStorageManager */
+ /** @var FrontendStorageManager */
protected $model;
/** @var ObjectManagerHelper */
protected $objectManagerHelper;
- /** @var \Magento\Framework\View\Element\Template\Context|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Context|MockObject */
protected $contextMock;
- /** @var \Magento\Catalog\Model\FrontendStorageConfigurationPool|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var FrontendStorageConfigurationPool|MockObject */
protected $frontendStorageConfigurationPoolMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class)
+ $this->contextMock = $this->getMockBuilder(Context::class)
->disableOriginalConstructor()
->getMock();
$this->frontendStorageConfigurationPoolMock = $this
- ->getMockBuilder(\Magento\Catalog\Model\FrontendStorageConfigurationPool::class)
+ ->getMockBuilder(FrontendStorageConfigurationPool::class)
->disableOriginalConstructor()
->getMock();
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Block\FrontendStorageManager::class,
+ FrontendStorageManager::class,
[
'context' => $this->contextMock,
'storageConfigurationPool' => $this->frontendStorageConfigurationPoolMock
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/NavigationTest.php b/app/code/Magento/Catalog/Test/Unit/Block/NavigationTest.php
index 48760968ede7a..3b0eb307ce259 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/NavigationTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/NavigationTest.php
@@ -3,45 +3,64 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block;
-class NavigationTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Block\Navigation;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\CategoryFactory;
+use Magento\Framework\App\Http\Context;
+use Magento\Framework\Registry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Design\ThemeInterface;
+use Magento\Framework\View\DesignInterface;
+use Magento\Store\Model\Group;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
+class NavigationTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Navigation
+ * @var Navigation
*/
protected $block;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registry;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManager;
/**
- * @var \Magento\Framework\View\DesignInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var DesignInterface|MockObject
*/
protected $design;
/**
- * @var \Magento\Framework\App\Http\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $httpContext;
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $categoryFactory = $this->createPartialMock(\Magento\Catalog\Model\CategoryFactory::class, ['create']);
- $this->registry = $this->createMock(\Magento\Framework\Registry::class);
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->design = $this->createMock(\Magento\Framework\View\DesignInterface::class);
- $this->httpContext = $this->createMock(\Magento\Framework\App\Http\Context::class);
+ $objectManager = new ObjectManager($this);
+ $categoryFactory = $this->createPartialMock(CategoryFactory::class, ['create']);
+ $this->registry = $this->createMock(Registry::class);
+ $this->storeManager = $this->createMock(StoreManagerInterface::class);
+ $this->design = $this->createMock(DesignInterface::class);
+ $this->httpContext = $this->createMock(Context::class);
$this->block = $objectManager->getObject(
- \Magento\Catalog\Block\Navigation::class,
+ Navigation::class,
[
'categoryFactory' => $categoryFactory,
'registry' => $this->registry,
@@ -55,7 +74,7 @@ protected function setUp()
public function testGetIdentities()
{
$this->assertEquals(
- [\Magento\Catalog\Model\Category::CACHE_TAG, \Magento\Store\Model\Group::CACHE_TAG],
+ [Category::CACHE_TAG, Group::CACHE_TAG],
$this->block->getIdentities()
);
}
@@ -63,7 +82,7 @@ public function testGetIdentities()
public function testGetCurrentCategoryKey()
{
$categoryKey = 101;
- $category = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $category = $this->createMock(Category::class);
$category->expects($this->any())->method('getPath')->willReturn($categoryKey);
$this->registry->expects($this->any())->method('registry')->with('current_category')->willReturn($category);
@@ -74,7 +93,7 @@ public function testGetCurrentCategoryKey()
public function testGetCurrentCategoryKeyFromRootCategory()
{
$categoryKey = 102;
- $store = $this->createMock(\Magento\Store\Model\Store::class);
+ $store = $this->createMock(Store::class);
$store->expects($this->any())->method('getRootCategoryId')->willReturn($categoryKey);
$this->storeManager->expects($this->any())->method('getStore')->willReturn($store);
@@ -84,13 +103,13 @@ public function testGetCurrentCategoryKeyFromRootCategory()
public function testGetCacheKeyInfo()
{
- $store = $this->createMock(\Magento\Store\Model\Store::class);
+ $store = $this->createMock(Store::class);
$store->expects($this->atLeastOnce())->method('getId')->willReturn(55);
$store->expects($this->atLeastOnce())->method('getRootCategoryId')->willReturn(60);
$this->storeManager->expects($this->atLeastOnce())->method('getStore')->willReturn($store);
- $theme = $this->createMock(\Magento\Framework\View\Design\ThemeInterface::class);
+ $theme = $this->createMock(ThemeInterface::class);
$theme->expects($this->atLeastOnce())->method('getId')->willReturn(65);
$this->design->expects($this->atLeastOnce())->method('getDesignTheme')->willReturn($theme);
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/AbstractProductTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/AbstractProductTest.php
index d003c6d01373f..1bd318e1fd444 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/AbstractProductTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/AbstractProductTest.php
@@ -3,40 +3,52 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Block\Product;
+use Magento\Catalog\Block\Product\Context;
use Magento\Catalog\Block\Product\Image;
use Magento\Catalog\Block\Product\ImageBuilder;
+use Magento\Catalog\Block\Product\View\Type\Simple;
use Magento\Catalog\Model\Product;
+use Magento\CatalogInventory\Api\Data\StockItemInterface;
+use Magento\CatalogInventory\Api\StockRegistryInterface;
+use Magento\Framework\Pricing\Render;
+use Magento\Framework\Stdlib\ArrayUtils;
+use Magento\Framework\View\Layout;
+use Magento\Framework\View\LayoutInterface;
+use Magento\Store\Model\Store;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class for testing methods of AbstractProduct
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class AbstractProductTest extends \PHPUnit\Framework\TestCase
+class AbstractProductTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Product\View\Type\Simple
+ * @var Simple
*/
protected $block;
/**
- * @var \Magento\Catalog\Block\Product\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $productContextMock;
/**
- * @var \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutInterface|MockObject
*/
protected $layoutMock;
/**
- * @var \Magento\CatalogInventory\Api\StockRegistryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StockRegistryInterface|MockObject
*/
protected $stockRegistryMock;
/**
- * @var ImageBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var ImageBuilder|MockObject
*/
protected $imageBuilder;
@@ -44,16 +56,16 @@ class AbstractProductTest extends \PHPUnit\Framework\TestCase
* Set up mocks and tested class
* Child class is used as the tested class is declared abstract
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->productContextMock = $this->createPartialMock(
- \Magento\Catalog\Block\Product\Context::class,
+ Context::class,
['getLayout', 'getStockRegistry', 'getImageBuilder']
);
- $arrayUtilsMock = $this->createMock(\Magento\Framework\Stdlib\ArrayUtils::class);
- $this->layoutMock = $this->createPartialMock(\Magento\Framework\View\Layout::class, ['getBlock']);
+ $arrayUtilsMock = $this->createMock(ArrayUtils::class);
+ $this->layoutMock = $this->createPartialMock(Layout::class, ['getBlock']);
$this->stockRegistryMock = $this->getMockForAbstractClass(
- \Magento\CatalogInventory\Api\StockRegistryInterface::class,
+ StockRegistryInterface::class,
[],
'',
false,
@@ -74,7 +86,7 @@ protected function setUp()
->method('getImageBuilder')
->will($this->returnValue($this->imageBuilder));
- $this->block = new \Magento\Catalog\Block\Product\View\Type\Simple(
+ $this->block = new Simple(
$this->productContextMock,
$arrayUtilsMock
);
@@ -89,7 +101,7 @@ protected function setUp()
public function testGetProductPrice()
{
$expectedPriceHtml = 'Expected Price html with price $30';
- $priceRenderBlock = $this->createPartialMock(\Magento\Framework\Pricing\Render::class, ['render']);
+ $priceRenderBlock = $this->createPartialMock(Render::class, ['render']);
$product = $this->createMock(Product::class);
$this->layoutMock->expects($this->once())
@@ -109,7 +121,7 @@ public function testGetProductPrice()
public function testGetProductPriceHtml()
{
$expectedPriceHtml = 'Expected Price html with price $30';
- $priceRenderBlock = $this->createPartialMock(\Magento\Framework\Pricing\Render::class, ['render']);
+ $priceRenderBlock = $this->createPartialMock(Render::class, ['render']);
$product = $this->createMock(Product::class);
$this->layoutMock->expects($this->once())
@@ -142,9 +154,9 @@ public function testGetMinimalQty($minSale, $result)
$websiteId = 99;
$productMock = $this->createPartialMock(Product::class, ['getId', 'getStore']);
- $storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getWebsiteId']);
+ $storeMock = $this->createPartialMock(Store::class, ['getWebsiteId']);
$stockItemMock = $this->getMockForAbstractClass(
- \Magento\CatalogInventory\Api\Data\StockItemInterface::class,
+ StockItemInterface::class,
[],
'',
false,
@@ -170,7 +182,7 @@ public function testGetMinimalQty($minSale, $result)
->method('getMinSaleQty')
->will($this->returnValue($minSale));
- /** @var Product|\PHPUnit_Framework_MockObject_MockObject $productMock */
+ /** @var Product|MockObject $productMock */
$this->assertEquals($result, $this->block->getMinimalQty($productMock));
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/Compare/ListCompareTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/Compare/ListCompareTest.php
index ec472e0a3366d..1b04ea0f59231 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/Compare/ListCompareTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/Compare/ListCompareTest.php
@@ -3,14 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product\Compare;
-use \Magento\Catalog\Block\Product\Compare\ListCompare;
+use Magento\Catalog\Block\Product\Compare\ListCompare;
+use Magento\Catalog\Block\Product\Context;
+use Magento\Catalog\Model\Product;
+use Magento\Framework\Pricing\Render;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Layout;
+use Magento\Framework\View\LayoutInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class ListCompareTest
- */
-class ListCompareTest extends \PHPUnit\Framework\TestCase
+class ListCompareTest extends TestCase
{
/**
* @var ListCompare
@@ -18,27 +25,27 @@ class ListCompareTest extends \PHPUnit\Framework\TestCase
protected $block;
/**
- * @var \Magento\Framework\View\LayoutInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutInterface|MockObject
*/
protected $layout;
- protected function setUp()
+ protected function setUp(): void
{
- $this->layout = $this->createPartialMock(\Magento\Framework\View\Layout::class, ['getBlock']);
+ $this->layout = $this->createPartialMock(Layout::class, ['getBlock']);
- $context = $this->createPartialMock(\Magento\Catalog\Block\Product\Context::class, ['getLayout']);
+ $context = $this->createPartialMock(Context::class, ['getLayout']);
$context->expects($this->any())
->method('getLayout')
->will($this->returnValue($this->layout));
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->block = $objectManager->getObject(
- \Magento\Catalog\Block\Product\Compare\ListCompare::class,
+ ListCompare::class,
['context' => $context]
);
}
- protected function tearDown()
+ protected function tearDown(): void
{
$this->block = null;
}
@@ -51,12 +58,12 @@ public function testGetProductPrice()
$productId = 1;
//Verification
- $product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getId', '__wakeup']);
+ $product = $this->createPartialMock(Product::class, ['getId', '__wakeup']);
$product->expects($this->once())
->method('getId')
->will($this->returnValue($productId));
- $blockMock = $this->createPartialMock(\Magento\Framework\Pricing\Render::class, ['render']);
+ $blockMock = $this->createPartialMock(Render::class, ['render']);
$blockMock->expects($this->once())
->method('render')
->with(
@@ -65,7 +72,7 @@ public function testGetProductPrice()
[
'price_id' => 'product-price-' . $productId . '-compare-list-top',
'display_minimal_price' => true,
- 'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST
+ 'zone' => Render::ZONE_ITEM_LIST
]
)
->will($this->returnValue($expectedResult));
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ContextTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ContextTest.php
index 1c05647df5792..c8564a4ab9a63 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ContextTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ContextTest.php
@@ -3,25 +3,31 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product;
-/**
- * Class ContextTest
- */
-class ContextTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Block\Product\Context;
+use Magento\Catalog\Block\Product\ImageBuilder;
+use Magento\CatalogInventory\Api\StockRegistryInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ContextTest extends TestCase
{
/**
- * @var \Magento\CatalogInventory\Api\StockRegistryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StockRegistryInterface|MockObject
*/
protected $stockRegistryMock;
/**
- * @var \Magento\Catalog\Block\Product\Context
+ * @var Context
*/
protected $context;
/**
- * @var \Magento\Catalog\Block\Product\ImageBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var ImageBuilder|MockObject
*/
protected $imageBuilder;
@@ -30,23 +36,23 @@ class ContextTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->stockRegistryMock = $this->getMockForAbstractClass(
- \Magento\CatalogInventory\Api\StockRegistryInterface::class,
+ StockRegistryInterface::class,
[],
'',
false
);
- $this->imageBuilder = $this->getMockBuilder(\Magento\Catalog\Block\Product\ImageBuilder::class)
+ $this->imageBuilder = $this->getMockBuilder(ImageBuilder::class)
->disableOriginalConstructor()
->getMock();
$this->context = $objectManager->getObject(
- \Magento\Catalog\Block\Product\Context::class,
+ Context::class,
[
'stockRegistry' => $this->stockRegistryMock,
'imageBuilder' => $this->imageBuilder,
@@ -66,6 +72,6 @@ public function testGetStockRegistry()
public function testGetImageBuilder()
{
- $this->assertInstanceOf(\Magento\Catalog\Block\Product\ImageBuilder::class, $this->context->getImageBuilder());
+ $this->assertInstanceOf(ImageBuilder::class, $this->context->getImageBuilder());
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ImageFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ImageFactoryTest.php
index 07395f1c81dd3..c69c67682eae3 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ImageFactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ImageFactoryTest.php
@@ -14,31 +14,33 @@
use Magento\Catalog\Model\View\Asset\Image as ViewAssetImage;
use Magento\Catalog\Model\View\Asset\ImageFactory as ViewAssetImageFactory;
use Magento\Framework\Config\View;
-use Magento\Framework\View\ConfigInterface;
use Magento\Framework\ObjectManager\ObjectManager;
+use Magento\Framework\View\ConfigInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ImageFactoryTest extends \PHPUnit\Framework\TestCase
+class ImageFactoryTest extends TestCase
{
- /** @var ParamsBuilder|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ParamsBuilder|MockObject */
private $paramsBuilder;
- /** @var View|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var View|MockObject */
private $viewConfig;
- /** @var ObjectManager|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ObjectManager|MockObject */
private $objectManager;
/**
- * @var ImageFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ImageFactory|MockObject
*/
private $model;
/**
- * @var ViewAssetImageFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ViewAssetImageFactory|MockObject
*/
private $viewAssetImageFactory;
- protected function setUp()
+ protected function setUp(): void
{
$this->viewConfig = $this->createMock(View::class);
$configInterface = $this->createMock(ConfigInterface::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php
index 4653934311938..10f406a28c8e6 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php
@@ -3,110 +3,126 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product;
use Magento\Catalog\Block\Product\Context;
+use Magento\Catalog\Block\Product\ListProduct;
+use Magento\Catalog\Block\Product\ProductList\Toolbar;
+use Magento\Catalog\Model\Layer;
+use Magento\Catalog\Model\Layer\Resolver;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Type\Simple;
+use Magento\Catalog\Model\ResourceModel\Category as CategoryResourceModel;
+use Magento\Catalog\Model\ResourceModel\Category\Collection;
+use Magento\Checkout\Helper\Cart;
+use Magento\Framework\Data\Helper\PostHelper;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Pricing\Render;
+use Magento\Framework\Registry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\Url\Helper\Data;
use Magento\Framework\View\LayoutInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ListProductTest extends \PHPUnit\Framework\TestCase
+class ListProductTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Product\ListProduct
+ * @var ListProduct
*/
protected $block;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $layerMock;
/**
- * @var \Magento\Framework\Data\Helper\PostHelper|\PHPUnit_Framework_MockObject_MockObject
+ * @var PostHelper|MockObject
*/
protected $postDataHelperMock;
/**
- * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
protected $productMock;
/**
- * @var \Magento\Checkout\Helper\Cart|\PHPUnit_Framework_MockObject_MockObject
+ * @var Cart|MockObject
*/
protected $cartHelperMock;
/**
- * @var \Magento\Catalog\Model\Product\Type\Simple|\PHPUnit_Framework_MockObject_MockObject
+ * @var Simple|MockObject
*/
protected $typeInstanceMock;
/**
- * @var Data | \PHPUnit_Framework_MockObject_MockObject
+ * @var Data|MockObject
*/
protected $urlHelperMock;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Category | \PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryResourceModel|MockObject
*/
protected $catCollectionMock;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product | \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Model\ResourceModel\Product|MockObject
*/
protected $prodCollectionMock;
/**
- * @var \Magento\Framework\View\LayoutInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutInterface|MockObject
*/
protected $layoutMock;
/**
- * @var \Magento\Catalog\Block\Product\ProductList\Toolbar | \PHPUnit_Framework_MockObject_MockObject
+ * @var Toolbar|MockObject
*/
protected $toolbarMock;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $context;
/**
- * @var Render|\PHPUnit_Framework_MockObject_MockObject
+ * @var Render|MockObject
*/
private $renderer;
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
- $this->layerMock = $this->createMock(\Magento\Catalog\Model\Layer::class);
- /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver $layerResolver */
- $layerResolver = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Resolver::class)
+ $objectManager = new ObjectManager($this);
+ $this->registryMock = $this->createMock(Registry::class);
+ $this->layerMock = $this->createMock(Layer::class);
+ /** @var MockObject|Resolver $layerResolver */
+ $layerResolver = $this->getMockBuilder(Resolver::class)
->disableOriginalConstructor()
->setMethods(['get', 'create'])
->getMock();
$layerResolver->expects($this->any())
->method($this->anything())
->will($this->returnValue($this->layerMock));
- $this->postDataHelperMock = $this->createMock(\Magento\Framework\Data\Helper\PostHelper::class);
- $this->typeInstanceMock = $this->createMock(\Magento\Catalog\Model\Product\Type\Simple::class);
- $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $this->cartHelperMock = $this->createMock(\Magento\Checkout\Helper\Cart::class);
- $this->catCollectionMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
+ $this->postDataHelperMock = $this->createMock(PostHelper::class);
+ $this->typeInstanceMock = $this->createMock(Simple::class);
+ $this->productMock = $this->createMock(Product::class);
+ $this->cartHelperMock = $this->createMock(Cart::class);
+ $this->catCollectionMock = $this->createMock(Collection::class);
$this->prodCollectionMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
- $this->layoutMock = $this->createMock(\Magento\Framework\View\LayoutInterface::class);
- $this->toolbarMock = $this->createMock(\Magento\Catalog\Block\Product\ProductList\Toolbar::class);
+ $this->layoutMock = $this->createMock(LayoutInterface::class);
+ $this->toolbarMock = $this->createMock(Toolbar::class);
$this->urlHelperMock = $this->getMockBuilder(Data::class)->disableOriginalConstructor()->getMock();
$this->context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
@@ -119,7 +135,7 @@ protected function setUp()
$this->context->expects($this->any())->method('getEventManager')->willReturn($eventManager);
$this->block = $objectManager->getObject(
- \Magento\Catalog\Block\Product\ListProduct::class,
+ ListProduct::class,
[
'registry' => $this->registryMock,
'context' => $this->context,
@@ -132,7 +148,7 @@ protected function setUp()
$this->block->setToolbarBlockName('mock');
}
- protected function tearDown()
+ protected function tearDown(): void
{
$this->block = null;
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListTest.php
index 52b84cc7d55e9..377edefd70f56 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListTest.php
@@ -3,15 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product;
-class ListTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Block\Product\ListProduct;
+use Magento\Framework\DataObject;
+use PHPUnit\Framework\TestCase;
+
+class ListTest extends TestCase
{
public function testGetMode()
{
- $childBlock = new \Magento\Framework\DataObject();
+ $childBlock = new DataObject();
- $block = $this->createPartialMock(\Magento\Catalog\Block\Product\ListProduct::class, ['getChildBlock']);
+ $block = $this->createPartialMock(ListProduct::class, ['getChildBlock']);
$block->expects(
$this->atLeastOnce()
)->method(
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/NewProductTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/NewProductTest.php
index 869416fbc1031..1ab7c246bd9a6 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/NewProductTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/NewProductTest.php
@@ -3,29 +3,37 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product;
-class NewProductTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Block\Product\ListProduct;
+use Magento\Catalog\Block\Product\NewProduct;
+use Magento\Catalog\Model\Product;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
+class NewProductTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Product\ListProduct
+ * @var ListProduct
*/
protected $block;
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->block = $objectManager->getObject(\Magento\Catalog\Block\Product\NewProduct::class);
+ $objectManager = new ObjectManager($this);
+ $this->block = $objectManager->getObject(NewProduct::class);
}
- protected function tearDown()
+ protected function tearDown(): void
{
$this->block = null;
}
public function testGetIdentities()
{
- $this->assertEquals([\Magento\Catalog\Model\Product::CACHE_TAG], $this->block->getIdentities());
+ $this->assertEquals([Product::CACHE_TAG], $this->block->getIdentities());
}
public function testScope()
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/PriceTest.php
index 99089344cbaf5..fec145e5f7949 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/PriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/PriceTest.php
@@ -3,22 +3,29 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product;
-class PriceTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Block\Product\Price;
+use Magento\Catalog\Model\Product;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
+class PriceTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Product\Price
+ * @var Price
*/
protected $block;
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->block = $objectManager->getObject(\Magento\Catalog\Block\Product\Price::class);
+ $objectManager = new ObjectManager($this);
+ $this->block = $objectManager->getObject(Price::class);
}
- protected function tearDown()
+ protected function tearDown(): void
{
$this->block = null;
}
@@ -26,7 +33,7 @@ protected function tearDown()
public function testGetIdentities()
{
$productTags = ['catalog_product_1'];
- $product = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $product = $this->createMock(Product::class);
$product->expects($this->once())->method('getIdentities')->will($this->returnValue($productTags));
$this->block->setProduct($product);
$this->assertEquals($productTags, $this->block->getIdentities());
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/RelatedTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/RelatedTest.php
index deb84b7b2d3c4..ec62d29869327 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/RelatedTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/RelatedTest.php
@@ -3,22 +3,29 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product\ProductList;
-class RelatedTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Block\Product\ProductList\Related;
+use Magento\Catalog\Model\Product;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
+class RelatedTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Product\ProductList\Related
+ * @var Related
*/
protected $block;
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->block = $objectManager->getObject(\Magento\Catalog\Block\Product\ProductList\Related::class);
+ $objectManager = new ObjectManager($this);
+ $this->block = $objectManager->getObject(Related::class);
}
- protected function tearDown()
+ protected function tearDown(): void
{
$this->block = null;
}
@@ -26,11 +33,11 @@ protected function tearDown()
public function testGetIdentities()
{
$productTag = ['compare_item_1'];
- $product = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $product = $this->createMock(Product::class);
$product->expects($this->once())->method('getIdentities')->will($this->returnValue($productTag));
$itemsCollection = new \ReflectionProperty(
- \Magento\Catalog\Block\Product\ProductList\Related::class,
+ Related::class,
'_itemCollection'
);
$itemsCollection->setAccessible(true);
@@ -52,7 +59,7 @@ public function testGetIdentities()
public function testCanItemsAddToCart($isComposite, $isSaleable, $hasRequiredOptions, $canItemsAddToCart)
{
$product = $this->createPartialMock(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
['isComposite', 'isSaleable', 'getRequiredOptions']
);
$product->expects($this->any())->method('isComposite')->willReturn($isComposite);
@@ -60,7 +67,7 @@ public function testCanItemsAddToCart($isComposite, $isSaleable, $hasRequiredOpt
$product->expects($this->any())->method('getRequiredOptions')->willReturn($hasRequiredOptions);
$itemsCollection = new \ReflectionProperty(
- \Magento\Catalog\Block\Product\ProductList\Related::class,
+ Related::class,
'_itemCollection'
);
$itemsCollection->setAccessible(true);
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php
index 884f4c543c8b8..9352c8a7397ef 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php
@@ -3,62 +3,80 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Block\Product\ProductList;
-class ToolbarTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Block\Product\ProductList\Toolbar;
+use Magento\Catalog\Helper\Product\ProductList;
+use Magento\Catalog\Model\Config;
+use Magento\Catalog\Model\Product\ProductList\ToolbarMemorizer;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\Url;
+use Magento\Framework\Url\EncoderInterface;
+use Magento\Framework\View\Element\Template\Context;
+use Magento\Framework\View\Layout;
+use Magento\Theme\Block\Html\Pager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
+class ToolbarTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Product\ProductList\Toolbar
+ * @var Toolbar
*/
protected $block;
/**
- * @var \Magento\Catalog\Model\Product\ProductList\Toolbar | \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Model\Product\ProductList\Toolbar|MockObject
*/
protected $model;
/**
- * @var \Magento\Catalog\Model\Product\ProductList\ToolbarMemorizer | \PHPUnit_Framework_MockObject_MockObject
+ * @var ToolbarMemorizer|MockObject
*/
private $memorizer;
/**
- * @var \Magento\Framework\Url | \PHPUnit_Framework_MockObject_MockObject
+ * @var Url|MockObject
*/
protected $urlBuilder;
/**
- * @var \Magento\Framework\Url\EncoderInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var EncoderInterface|MockObject
*/
protected $urlEncoder;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $scopeConfig;
/**
- * @var \Magento\Catalog\Model\Config | \PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
protected $catalogConfig;
/**
- * @var \Magento\Catalog\Helper\Product\ProductList|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductList|MockObject
*/
protected $productListHelper;
/**
- * @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject
+ * @var Layout|MockObject
*/
protected $layout;
/**
- * @var \Magento\Theme\Block\Html\Pager|\PHPUnit_Framework_MockObject_MockObject
+ * @var Pager|MockObject
*/
protected $pagerBlock;
- protected function setUp()
+ protected function setUp(): void
{
$this->model = $this->createPartialMock(\Magento\Catalog\Model\Product\ProductList\Toolbar::class, [
'getDirection',
@@ -68,7 +86,7 @@ protected function setUp()
'getCurrentPage'
]);
$this->memorizer = $this->createPartialMock(
- \Magento\Catalog\Model\Product\ProductList\ToolbarMemorizer::class,
+ ToolbarMemorizer::class,
[
'getDirection',
'getOrder',
@@ -77,8 +95,8 @@ protected function setUp()
'isMemorizingAllowed'
]
);
- $this->layout = $this->createPartialMock(\Magento\Framework\View\Layout::class, ['getChildName', 'getBlock']);
- $this->pagerBlock = $this->createPartialMock(\Magento\Theme\Block\Html\Pager::class, [
+ $this->layout = $this->createPartialMock(Layout::class, ['getChildName', 'getBlock']);
+ $this->pagerBlock = $this->createPartialMock(Pager::class, [
'setUseContainer',
'setShowPerPage',
'setShowAmounts',
@@ -88,12 +106,12 @@ protected function setUp()
'setCollection',
'toHtml'
]);
- $this->urlBuilder = $this->createPartialMock(\Magento\Framework\Url::class, ['getUrl']);
- $this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $this->urlBuilder = $this->createPartialMock(Url::class, ['getUrl']);
+ $this->scopeConfig = $this->createMock(ScopeConfigInterface::class);
$scopeConfig = [
- [\Magento\Catalog\Model\Config::XML_PATH_LIST_DEFAULT_SORT_BY, null, 'name'],
- [\Magento\Catalog\Helper\Product\ProductList::XML_PATH_LIST_MODE, null, 'grid-list'],
+ [Config::XML_PATH_LIST_DEFAULT_SORT_BY, null, 'name'],
+ [ProductList::XML_PATH_LIST_MODE, null, 'grid-list'],
['catalog/frontend/list_per_page_values', null, '10,20,30'],
['catalog/frontend/grid_per_page_values', null, '10,20,30'],
['catalog/frontend/list_allow_all', null, false]
@@ -104,12 +122,12 @@ protected function setUp()
->will($this->returnValueMap($scopeConfig));
$this->catalogConfig = $this->createPartialMock(
- \Magento\Catalog\Model\Config::class,
+ Config::class,
['getAttributeUsedForSortByArray']
);
$context = $this->createPartialMock(
- \Magento\Framework\View\Element\Template\Context::class,
+ Context::class,
['getUrlBuilder', 'getScopeConfig', 'getLayout']
);
$context->expects($this->any())
@@ -121,12 +139,12 @@ protected function setUp()
$context->expects($this->any())
->method('getlayout')
->will($this->returnValue($this->layout));
- $this->productListHelper = $this->createMock(\Magento\Catalog\Helper\Product\ProductList::class);
+ $this->productListHelper = $this->createMock(ProductList::class);
- $this->urlEncoder = $this->createPartialMock(\Magento\Framework\Url\EncoderInterface::class, ['encode']);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->urlEncoder = $this->createPartialMock(EncoderInterface::class, ['encode']);
+ $objectManager = new ObjectManager($this);
$this->block = $objectManager->getObject(
- \Magento\Catalog\Block\Product\ProductList\Toolbar::class,
+ Toolbar::class,
[
'context' => $context,
'catalogConfig' => $this->catalogConfig,
@@ -138,7 +156,7 @@ protected function setUp()
);
}
- protected function tearDown()
+ protected function tearDown(): void
{
$this->block = null;
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/UpsellTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/UpsellTest.php
index f3aa3f182d198..889b6e20e2f2e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/UpsellTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/UpsellTest.php
@@ -3,12 +3,16 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product\ProductList;
use Magento\Catalog\Block\Product\ProductList\Upsell as UpsellBlock;
use Magento\Catalog\Model\Product;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class UpsellTest extends \PHPUnit\Framework\TestCase
+class UpsellTest extends TestCase
{
const STUB_EMPTY_ARRAY = [];
/**
@@ -16,13 +20,13 @@ class UpsellTest extends \PHPUnit\Framework\TestCase
*/
protected $block;
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->block = $objectManager->getObject(UpsellBlock::class);
}
- protected function tearDown()
+ protected function tearDown(): void
{
$this->block = null;
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/AttributesTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/AttributesTest.php
index a596458f65e8e..5a38c13120207 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/AttributesTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/AttributesTest.php
@@ -3,17 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Block\Product\View;
-use \PHPUnit\Framework\TestCase;
-use \Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
-use \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
-use \Magento\Catalog\Model\Product;
-use \Magento\Framework\View\Element\Template\Context;
-use \Magento\Framework\Registry;
-use \Magento\Framework\Pricing\PriceCurrencyInterface;
-use \Magento\Catalog\Block\Product\View\Attributes as AttributesBlock;
+use Magento\Catalog\Block\Product\View\Attributes as AttributesBlock;
+use Magento\Catalog\Model\Product;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
+use Magento\Framework\Phrase;
+use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\Registry;
+use Magento\Framework\View\Element\Template\Context;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test class for \Magento\Catalog\Block\Product\View\Attributes
@@ -23,37 +26,37 @@
class AttributesTest extends TestCase
{
/**
- * @var \Magento\Framework\Phrase
+ * @var Phrase
*/
private $phrase;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Eav\Model\Entity\Attribute\AbstractAttribute
+ * @var MockObject|AbstractAttribute
*/
private $attribute;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend
+ * @var MockObject|AbstractFrontend
*/
private $frontendAttribute;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product
+ * @var MockObject|Product
*/
private $product;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\View\Element\Template\Context
+ * @var MockObject|Context
*/
private $context;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Registry
+ * @var MockObject|Registry
*/
private $registry;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Pricing\PriceCurrencyInterface
+ * @var MockObject|PriceCurrencyInterface
*/
private $priceCurrencyInterface;
@@ -62,7 +65,7 @@ class AttributesTest extends TestCase
*/
private $attributesBlock;
- protected function setUp()
+ protected function setUp(): void
{
$this->attribute = $this
->getMockBuilder(AbstractAttribute::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryOptionsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryOptionsTest.php
index 7ed8b13fce750..8480c4d280a34 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryOptionsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryOptionsTest.php
@@ -3,21 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product\View;
use Magento\Catalog\Block\Product\Context;
use Magento\Catalog\Block\Product\View\Gallery;
use Magento\Catalog\Block\Product\View\GalleryOptions;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Framework\Escaper;
-use Magento\Framework\View\Config;
use Magento\Framework\Config\View;
+use Magento\Framework\Escaper;
use Magento\Framework\Serialize\Serializer\Json;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Config;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class GalleryOptionsTest extends \PHPUnit\Framework\TestCase
+class GalleryOptionsTest extends TestCase
{
/**
* @var GalleryOptions
@@ -25,12 +29,12 @@ class GalleryOptionsTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var Gallery|\PHPUnit_Framework_MockObject_MockObject
+ * @var Gallery|MockObject
*/
private $gallery;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $context;
@@ -40,12 +44,12 @@ class GalleryOptionsTest extends \PHPUnit\Framework\TestCase
private $jsonSerializer;
/**
- * @var View|\PHPUnit_Framework_MockObject_MockObject
+ * @var View|MockObject
*/
private $configView;
/**
- * @var Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $viewConfig;
@@ -54,7 +58,7 @@ class GalleryOptionsTest extends \PHPUnit\Framework\TestCase
*/
private $escaper;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php
index a81d8b1c9fc3c..e1402cae90a79 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php
@@ -3,11 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product\View;
use Magento\Catalog\Block\Product\Context;
-use Magento\Catalog\Block\Product\ImageBuilder;
use Magento\Catalog\Block\Product\View\Gallery;
+use Magento\Catalog\Helper\Image;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Gallery\ImagesConfigFactoryInterface;
use Magento\Catalog\Model\Product\Image\UrlBuilder;
@@ -19,11 +21,13 @@
use Magento\Framework\Stdlib\ArrayUtils;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Store\Model\Store;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class GalleryTest extends \PHPUnit\Framework\TestCase
+class GalleryTest extends TestCase
{
/**
* @var Gallery
@@ -31,44 +35,44 @@ class GalleryTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $context;
/**
- * @var ArrayUtils|\PHPUnit_Framework_MockObject_MockObject
+ * @var ArrayUtils|MockObject
*/
protected $arrayUtils;
/**
- * @var \Magento\Catalog\Helper\Image|\PHPUnit_Framework_MockObject_MockObject
+ * @var Image|MockObject
*/
protected $imageHelper;
/**
- * @var Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registry;
/**
- * @var EncoderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var EncoderInterface|MockObject
*/
protected $jsonEncoderMock;
/**
- * @var ImagesConfigFactoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ImagesConfigFactoryInterface|MockObject
*/
protected $imagesConfigFactoryMock;
/**
- * @var Collection|\PHPUnit_Framework_MockObject_MockObject
+ * @var Collection|MockObject
*/
protected $galleryImagesConfigMock;
- /** @var UrlBuilder|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var UrlBuilder|MockObject */
private $urlBuilder;
- protected function setUp()
+ protected function setUp(): void
{
$this->registry = $this->createMock(Registry::class);
$this->context = $this->createConfiguredMock(
@@ -116,15 +120,15 @@ public function testGetGalleryImagesJsonWithoutLabel()
private function prepareGetGalleryImagesJsonMocks($hasLabel = true)
{
- $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class)
+ $storeMock = $this->getMockBuilder(Store::class)
->disableOriginalConstructor()
->getMock();
- $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
- $productTypeMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\AbstractType::class)
+ $productTypeMock = $this->getMockBuilder(AbstractType::class)
->disableOriginalConstructor()
->getMock();
$productTypeMock->expects($this->any())
@@ -147,7 +151,7 @@ private function prepareGetGalleryImagesJsonMocks($hasLabel = true)
->with('product')
->willReturn($productMock);
- $this->imageHelper = $this->getMockBuilder(\Magento\Catalog\Helper\Image::class)
+ $this->imageHelper = $this->getMockBuilder(Image::class)
->setMethods(['init', 'setImageFile', 'getUrl'])
->disableOriginalConstructor()
->getMock();
@@ -257,12 +261,12 @@ private function getGalleryImagesConfigItems()
*/
private function getImagesCollectionWithPopulatedDataObject($hasLabel)
{
- $collectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection::class)
+ $collectionMock = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
$items = [
- new \Magento\Framework\DataObject([
+ new DataObject([
'file' => 'test_file',
'label' => ($hasLabel ? 'test_label' : ''),
'position' => '2',
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/OptionsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/OptionsTest.php
index 5f80064d8ec9e..d00212ce37f7a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/OptionsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/OptionsTest.php
@@ -3,35 +3,51 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product\View;
+use Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Options as ProductOptions;
+use Magento\Catalog\Block\Product\View\Options;
+use Magento\Catalog\Model\CategoryFactory;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Configuration\Item\OptionFactory;
+use Magento\Catalog\Model\ProductFactory;
+use Magento\Catalog\Model\ResourceModel\Product\Option;
+use Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory;
+use Magento\Framework\Data\CollectionFactory;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Element\Template\Context;
+use Magento\Framework\View\Layout;
+use PHPUnit\Framework\TestCase;
+
/**
* Test class for \Magento\Catalog\Block\Product\View\Options
*
* @SuppressWarnings(PHPMD.LongVariable)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class OptionsTest extends \PHPUnit\Framework\TestCase
+class OptionsTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $_objectHelper;
/**
- * @var \Magento\Catalog\Block\Product\View\Options
+ * @var Options
*/
protected $_optionsBlock;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Option
+ * @var Option
*/
protected $_optionResource;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->_optionResource = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Option::class);
+ $this->_objectHelper = new ObjectManager($this);
+ $this->_optionResource = $this->createMock(Option::class);
}
/**
@@ -41,23 +57,20 @@ protected function setUp()
public function testGetOptionHtml()
{
$layout = $this->createPartialMock(
- \Magento\Framework\View\Layout::class,
+ Layout::class,
['getChildName', 'getBlock', 'renderElement']
);
$context = $this->_objectHelper->getObject(
- \Magento\Framework\View\Element\Template\Context::class,
+ Context::class,
['layout' => $layout]
);
- $optValFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Option\ValueFactory::class,
- ['create']
- );
+ $optValFactoryMock = $this->createPartialMock('\Magento\Catalog\Model\Product\Option\ValueFactory', ['create']);
$option = $this->_objectHelper->getObject(
\Magento\Catalog\Model\Product\Option::class,
['resource' => $this->_optionResource, 'optionValueFactory' => $optValFactoryMock]
);
- $dateBlock = $this->getMockBuilder(\Magento\Backend\Block\Catalog\Product\Composite\Fieldset\Options::class)
+ $dateBlock = $this->getMockBuilder(ProductOptions::class)
->setMethods(['setProduct', 'setOption'])
->setConstructorArgs(['context' => $context, 'option' => $option])
->disableOriginalConstructor()
@@ -69,25 +82,22 @@ public function testGetOptionHtml()
$layout->expects($this->any())->method('renderElement')->with('date', false)->will($this->returnValue('html'));
$this->_optionsBlock = $this->_objectHelper->getObject(
- \Magento\Catalog\Block\Product\View\Options::class,
+ Options::class,
['context' => $context, 'option' => $option]
);
- $itemOptFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Configuration\Item\OptionFactory::class,
- ['create']
- );
+ $itemOptFactoryMock = $this->createPartialMock(OptionFactory::class, ['create']);
$stockItemFactoryMock = $this->createPartialMock(
- \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory::class,
+ StockItemInterfaceFactory::class,
['create']
);
- $productFactoryMock = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']);
- $categoryFactoryMock = $this->createPartialMock(\Magento\Catalog\Model\CategoryFactory::class, ['create']);
+ $productFactoryMock = $this->createPartialMock(ProductFactory::class, ['create']);
+ $categoryFactoryMock = $this->createPartialMock(CategoryFactory::class, ['create']);
$this->_optionsBlock->setProduct(
$this->_objectHelper->getObject(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
[
- 'collectionFactory' => $this->createMock(\Magento\Framework\Data\CollectionFactory::class),
+ 'collectionFactory' => $this->createMock(CollectionFactory::class),
'itemOptionFactory' => $itemOptFactoryMock,
'stockItemFactory' => $stockItemFactoryMock,
'productFactory' => $productFactoryMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/TabsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/TabsTest.php
index 1278e45fae2e2..199cdc27b3378 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/TabsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/TabsTest.php
@@ -3,20 +3,28 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product\View;
-class TabsTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Block\Product\View\Tabs;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Element\Template;
+use Magento\Framework\View\Layout;
+use PHPUnit\Framework\TestCase;
+
+class TabsTest extends TestCase
{
public function testAddTab()
{
- $tabBlock = $this->createMock(\Magento\Framework\View\Element\Template::class);
+ $tabBlock = $this->createMock(Template::class);
$tabBlock->expects($this->once())->method('setTemplate')->with('template')->will($this->returnSelf());
- $layout = $this->createMock(\Magento\Framework\View\Layout::class);
+ $layout = $this->createMock(Layout::class);
$layout->expects($this->once())->method('createBlock')->with('block')->will($this->returnValue($tabBlock));
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $block = $helper->getObject(\Magento\Catalog\Block\Product\View\Tabs::class, ['layout' => $layout]);
+ $helper = new ObjectManager($this);
+ $block = $helper->getObject(Tabs::class, ['layout' => $layout]);
$block->addTab('alias', 'title', 'block', 'template', 'header');
$expectedTabs = [['alias' => 'alias', 'title' => 'title', 'header' => 'header']];
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php
index 6563bdeb149e1..20fde3da125c1 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php
@@ -1,4 +1,4 @@
-productTypeConfig = $this->createMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class);
- $this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
+ $helper = new ObjectManager($this);
+ $this->productTypeConfig = $this->createMock(ConfigInterface::class);
+ $this->registryMock = $this->createMock(Registry::class);
$this->view = $helper->getObject(
- \Magento\Catalog\Block\Product\View::class,
+ View::class,
['productTypeConfig' => $this->productTypeConfig, 'registry' => $this->registryMock]
);
}
@@ -47,7 +52,7 @@ protected function setUp()
*/
public function testShouldRenderQuantity()
{
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $productMock = $this->createMock(Product::class);
$this->registryMock->expects(
$this->any()
)->method(
@@ -76,7 +81,7 @@ public function testShouldRenderQuantity()
public function testGetIdentities()
{
$productTags = ['cat_p_1'];
- $product = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $product = $this->createMock(Product::class);
$product->expects($this->once())
->method('getIdentities')
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php
index 9868213967f7f..d075d9e653922 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php
@@ -3,75 +3,91 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Product\Widget;
+use Magento\Catalog\Block\Product\Context as ProductBlockContext;
use Magento\Catalog\Block\Product\Widget\NewWidget;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use Magento\Framework\App\Cache\State;
+use Magento\Framework\App\Config;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\Event\Manager;
+use Magento\Framework\Pricing\Render;
+use Magento\Framework\Stdlib\DateTime\Timezone;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\View\Layout;
+use Magento\Framework\View\LayoutInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class NewWidgetTest extends \PHPUnit\Framework\TestCase
+class NewWidgetTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Product\Widget\NewWidget|\PHPUnit_Framework_MockObject_MockObject
+ * @var NewWidget|MockObject
*/
protected $block;
/**
- * @var \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutInterface|MockObject
*/
protected $layout;
/**
- * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $requestMock;
- /** @var \Magento\Backend\Block\Context|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Backend\Block\Context|MockObject */
protected $context;
/** @var ObjectManagerHelper */
protected $objectManager;
- /** @var \Magento\Framework\Event\Manager|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Manager|MockObject */
protected $eventManager;
- /** @var \Magento\Framework\App\Config|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Config|MockObject */
protected $scopeConfig;
- /** @var \Magento\Framework\App\Cache\State|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var State|MockObject */
protected $cacheState;
- /** @var \Magento\Catalog\Model\Config|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Catalog\Model\Config|MockObject */
protected $catalogConfig;
- /** @var \Magento\Framework\Stdlib\DateTime\Timezone|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Timezone|MockObject */
protected $localDate;
- /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Collection|MockObject */
protected $productCollection;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManagerHelper($this);
- $this->eventManager = $this->createPartialMock(\Magento\Framework\Event\Manager::class, ['dispatch']);
- $this->scopeConfig = $this->createMock(\Magento\Framework\App\Config::class);
- $this->cacheState = $this->createPartialMock(\Magento\Framework\App\Cache\State::class, ['isEnabled']);
- $this->localDate = $this->createMock(\Magento\Framework\Stdlib\DateTime\Timezone::class);
+ $this->eventManager = $this->createPartialMock(Manager::class, ['dispatch']);
+ $this->scopeConfig = $this->createMock(Config::class);
+ $this->cacheState = $this->createPartialMock(State::class, ['isEnabled']);
+ $this->localDate = $this->createMock(Timezone::class);
$this->catalogConfig = $this->getMockBuilder(\Magento\Catalog\Model\Config::class)
->setMethods(['getProductAttributes'])
->disableOriginalConstructor()
->getMock();
- $this->layout = $this->createMock(\Magento\Framework\View\Layout::class);
- $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
+ $this->layout = $this->createMock(Layout::class);
+ $this->requestMock = $this->getMockBuilder(RequestInterface::class)
->disableOriginalConstructor()
->getMock();
- $this->context = $this->getMockBuilder(\Magento\Catalog\Block\Product\Context::class)
+ $this->context = $this->getMockBuilder(ProductBlockContext::class)
->setMethods(
[
'getEventManager', 'getScopeConfig', 'getLayout',
@@ -91,7 +107,7 @@ protected function setUp()
->willReturn($this->requestMock);
$this->block = $this->objectManager->getObject(
- \Magento\Catalog\Block\Product\Widget\NewWidget::class,
+ NewWidget::class,
[
'context' => $this->context
]
@@ -101,7 +117,7 @@ protected function setUp()
/**
* @inheritdoc
*/
- protected function tearDown()
+ protected function tearDown(): void
{
$this->block = null;
}
@@ -116,7 +132,7 @@ public function testGetProductPriceHtml()
';
$type = 'widget-new-list';
- $productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getId']);
+ $productMock = $this->createPartialMock(Product::class, ['getId']);
$productMock->expects($this->once())
->method('getId')
->willReturn($id);
@@ -124,10 +140,10 @@ public function testGetProductPriceHtml()
'price_id' => 'old-price-' . $id . '-' . $type,
'display_minimal_price' => true,
'include_container' => true,
- 'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
+ 'zone' => Render::ZONE_ITEM_LIST,
];
- $priceBoxMock = $this->createPartialMock(\Magento\Framework\Pricing\Render::class, ['render']);
+ $priceBoxMock = $this->createPartialMock(Render::class, ['render']);
$this->layout->expects($this->once())
->method('getBlock')
@@ -201,7 +217,7 @@ protected function generalGetProductCollection()
$this->context->expects($this->once())->method('getCatalogConfig')->willReturn($this->catalogConfig);
$this->context->expects($this->once())->method('getLocaleDate')->willReturn($this->localDate);
- $this->productCollection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class)
+ $this->productCollection = $this->getMockBuilder(Collection::class)
->setMethods(
[
'setVisibility', 'addMinimalPrice', 'addFinalPrice',
@@ -243,14 +259,14 @@ protected function generalGetProductCollection()
protected function startTestGetProductCollection($displayType, $pagerEnable, $productsCount, $productsPerPage)
{
$productCollectionFactory = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
$productCollectionFactory->expects($this->atLeastOnce())->method('create')
->willReturn($this->productCollection);
$this->block = $this->objectManager->getObject(
- \Magento\Catalog\Block\Product\Widget\NewWidget::class,
+ NewWidget::class,
[
'context' => $this->context,
'productCollectionFactory' => $productCollectionFactory
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Rss/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Rss/CategoryTest.php
index 978ebe944d7ed..528817d2df729 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Rss/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Rss/CategoryTest.php
@@ -3,84 +3,106 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Block\Rss;
+use Magento\Catalog\Api\CategoryRepositoryInterface;
+use Magento\Catalog\Block\Rss\Category;
+use Magento\Catalog\Helper\Data;
+use Magento\Catalog\Helper\Image;
+use Magento\Catalog\Model\CategoryFactory;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ResourceModel\Category\Collection;
+use Magento\Catalog\Model\ResourceModel\Category\Tree;
+use Magento\Customer\Model\Session;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\Http\Context;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\App\Rss\UrlBuilderInterface;
+use Magento\Framework\Config\View;
+use Magento\Framework\Data\Tree\Node;
+use Magento\Framework\DataObject;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\View\ConfigInterface;
+use Magento\Store\Model\ScopeInterface;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class CategoryTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CategoryTest extends \PHPUnit\Framework\TestCase
+class CategoryTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Rss\Category
+ * @var Category
*/
protected $block;
/**
- * @var \Magento\Framework\App\Http\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $httpContext;
/**
- * @var \Magento\Catalog\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var Data|MockObject
*/
protected $catalogHelper;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $categoryFactory;
/**
- * @var \Magento\Catalog\Model\Rss\Category|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Model\Rss\Category|MockObject
*/
protected $rssModel;
/**
- * @var \Magento\Framework\App\Rss\UrlBuilderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlBuilderInterface|MockObject
*/
protected $rssUrlBuilder;
/**
- * @var \Magento\Catalog\Helper\Image|\PHPUnit_Framework_MockObject_MockObject
+ * @var Image|MockObject
*/
protected $imageHelper;
/**
- * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject
+ * @var Session|MockObject
*/
protected $customerSession;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManager;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $scopeConfig;
/**
- * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $request;
/**
- * @var \Magento\Catalog\Api\CategoryRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryRepositoryInterface|MockObject
*/
protected $categoryRepository;
/**
- * @var \Magento\Framework\View\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConfigInterface|MockObject
*/
protected $viewConfig;
/**
- * @var \Magento\Framework\Config\View
+ * @var View
*/
protected $configView;
@@ -100,37 +122,37 @@ class CategoryTest extends \PHPUnit\Framework\TestCase
],
];
- protected function setUp()
+ protected function setUp(): void
{
- $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class);
+ $this->request = $this->createMock(RequestInterface::class);
$this->request->expects($this->at(0))->method('getParam')->with('cid')->will($this->returnValue(1));
$this->request->expects($this->at(1))->method('getParam')->with('store_id')->will($this->returnValue(null));
- $this->httpContext = $this->createMock(\Magento\Framework\App\Http\Context::class);
- $this->catalogHelper = $this->createMock(\Magento\Catalog\Helper\Data::class);
- $this->categoryFactory = $this->getMockBuilder(\Magento\Catalog\Model\CategoryFactory::class)
+ $this->httpContext = $this->createMock(Context::class);
+ $this->catalogHelper = $this->createMock(Data::class);
+ $this->categoryFactory = $this->getMockBuilder(CategoryFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()->getMock();
$this->rssModel = $this->createPartialMock(
\Magento\Catalog\Model\Rss\Category::class,
['getProductCollection']
);
- $this->rssUrlBuilder = $this->createMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class);
- $this->imageHelper = $this->createMock(\Magento\Catalog\Helper\Image::class);
- $this->customerSession = $this->createPartialMock(\Magento\Customer\Model\Session::class, ['getId']);
+ $this->rssUrlBuilder = $this->createMock(UrlBuilderInterface::class);
+ $this->imageHelper = $this->createMock(Image::class);
+ $this->customerSession = $this->createPartialMock(Session::class, ['getId']);
$this->customerSession->expects($this->any())->method('getId')->will($this->returnValue(1));
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
+ $this->storeManager = $this->createMock(StoreManagerInterface::class);
+ $store = $this->getMockBuilder(Store::class)
->setMethods(['getId', '__wakeup'])->disableOriginalConstructor()->getMock();
$store->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
- $this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
- $this->categoryRepository = $this->createMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class);
- $this->viewConfig = $this->getMockBuilder(\Magento\Framework\View\ConfigInterface::class)
+ $this->scopeConfig = $this->createMock(ScopeConfigInterface::class);
+ $this->categoryRepository = $this->createMock(CategoryRepositoryInterface::class);
+ $this->viewConfig = $this->getMockBuilder(ConfigInterface::class)
->getMockForAbstractClass();
$objectManagerHelper = new ObjectManagerHelper($this);
$this->block = $objectManagerHelper->getObject(
- \Magento\Catalog\Block\Rss\Category::class,
+ Category::class,
[
'request' => $this->request,
'scopeConfig' => $this->scopeConfig,
@@ -159,7 +181,7 @@ public function testGetRssData()
$this->categoryRepository->expects($this->once())->method('get')->will($this->returnValue($category));
- $configViewMock = $this->getMockBuilder(\Magento\Framework\Config\View::class)
+ $configViewMock = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
->getMock();
@@ -167,7 +189,7 @@ public function testGetRssData()
->method('getViewConfig')
->willReturn($configViewMock);
- $product = $this->getMockBuilder(\Magento\catalog\Model\Product::class)
+ $product = $this->getMockBuilder(Product::class)
->setMethods(
[
'__sleep',
@@ -221,7 +243,7 @@ public function testGetCacheLifetime()
public function testIsAllowed()
{
$this->scopeConfig->expects($this->once())->method('isSetFlag')
- ->with('rss/catalog/category', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
+ ->with('rss/catalog/category', ScopeInterface::SCOPE_STORE)
->will($this->returnValue(true));
$this->assertEquals(true, $this->block->isAllowed());
}
@@ -229,14 +251,14 @@ public function testIsAllowed()
public function testGetFeeds()
{
$this->scopeConfig->expects($this->once())->method('isSetFlag')
- ->with('rss/catalog/category', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
+ ->with('rss/catalog/category', ScopeInterface::SCOPE_STORE)
->will($this->returnValue(true));
$category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
->setMethods(['__sleep', '__wakeup', 'getTreeModel', 'getResourceCollection', 'getId', 'getName'])
->disableOriginalConstructor()->getMock();
- $collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category\Collection::class)
+ $collection = $this->getMockBuilder(Collection::class)
->setMethods(
[
'addIdFilter',
@@ -259,12 +281,12 @@ public function testGetFeeds()
$category->expects($this->once())->method('getResourceCollection')->will($this->returnValue($collection));
$this->categoryFactory->expects($this->once())->method('create')->will($this->returnValue($category));
- $node = new \Magento\Framework\DataObject(['id' => 1]);
- $nodes = $this->getMockBuilder(\Magento\Framework\Data\Tree\Node::class)
+ $node = new DataObject(['id' => 1]);
+ $nodes = $this->getMockBuilder(Node::class)
->setMethods(['getChildren'])->disableOriginalConstructor()->getMock();
$nodes->expects($this->once())->method('getChildren')->will($this->returnValue([$node]));
- $tree = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category\Tree::class)
+ $tree = $this->getMockBuilder(Tree::class)
->setMethods(['loadChildren', 'loadNode'])->disableOriginalConstructor()->getMock();
$tree->expects($this->once())->method('loadNode')->will($this->returnSelf());
$tree->expects($this->once())->method('loadChildren')->will($this->returnValue($nodes));
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/NewProductsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/NewProductsTest.php
index 129dea37b185e..9b037398ebd93 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/NewProductsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/NewProductsTest.php
@@ -3,19 +3,31 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Rss\Product;
+use Magento\Catalog\Block\Rss\Product\NewProducts;
+use Magento\Catalog\Helper\Image;
+use Magento\Catalog\Model\Product;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\App\Rss\UrlBuilderInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\View\Element\Template\Context;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManager;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class NewProductsTest
- * @package Magento\Catalog\Block\Rss\Product
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class NewProductsTest extends \PHPUnit\Framework\TestCase
+class NewProductsTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Rss\Product\NewProducts
+ * @var NewProducts
*/
protected $block;
@@ -25,53 +37,53 @@ class NewProductsTest extends \PHPUnit\Framework\TestCase
protected $objectManagerHelper;
/**
- * @var \Magento\Framework\View\Element\Template\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $context;
/**
- * @var \Magento\Catalog\Helper\Image|\PHPUnit_Framework_MockObject_MockObject
+ * @var Image|MockObject
*/
protected $imageHelper;
/**
- * @var \Magento\Catalog\Model\Rss\Product\NewProducts|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Model\Rss\Product\NewProducts|MockObject
*/
protected $newProducts;
/**
- * @var \Magento\Framework\App\Rss\UrlBuilderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlBuilderInterface|MockObject
*/
protected $rssUrlBuilder;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManager;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $scopeConfig;
/**
- * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $request;
- protected function setUp()
+ protected function setUp(): void
{
- $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class);
+ $this->request = $this->createMock(RequestInterface::class);
$this->request->expects($this->any())->method('getParam')->with('store_id')->will($this->returnValue(null));
- $this->context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class);
- $this->imageHelper = $this->createMock(\Magento\Catalog\Helper\Image::class);
+ $this->context = $this->createMock(Context::class);
+ $this->imageHelper = $this->createMock(Image::class);
$this->newProducts = $this->createMock(\Magento\Catalog\Model\Rss\Product\NewProducts::class);
- $this->rssUrlBuilder = $this->createMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class);
- $this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $this->rssUrlBuilder = $this->createMock(UrlBuilderInterface::class);
+ $this->scopeConfig = $this->createMock(ScopeConfigInterface::class);
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class);
- $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
+ $this->storeManager = $this->createMock(StoreManager::class);
+ $store = $this->getMockBuilder(Store::class)
->setMethods(['getId', 'getFrontendName', '__wakeup'])->disableOriginalConstructor()->getMock();
$store->expects($this->any())->method('getId')->will($this->returnValue(1));
$store->expects($this->any())->method('getFrontendName')->will($this->returnValue('Store 1'));
@@ -79,7 +91,7 @@ protected function setUp()
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->block = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Block\Rss\Product\NewProducts::class,
+ NewProducts::class,
[
'request' => $this->request,
'imageHelper' => $this->imageHelper,
@@ -112,7 +124,7 @@ public function testIsAllowed($configValue, $expectedResult)
}
/**
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
protected function getItemMock()
{
@@ -126,7 +138,7 @@ protected function getItemMock()
'getName',
'__wakeup',
];
- $item = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $methods);
+ $item = $this->createPartialMock(Product::class, $methods);
$item->expects($this->once())->method('setAllowedInRss')->with(true);
$item->expects($this->once())->method('setAllowedPriceInRss')->with(true);
$item->expects($this->once())->method('getAllowedPriceInRss')->will($this->returnValue(true));
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/SpecialTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/SpecialTest.php
index 3c9f19d61d16a..1b73d7c1888ab 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/SpecialTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/SpecialTest.php
@@ -3,15 +3,32 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Rss\Product;
+use Magento\Catalog\Helper\Image;
+use Magento\Catalog\Helper\Output;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Rss\Product\Special;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\Http\Context;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\App\Rss\UrlBuilderInterface;
+use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Msrp\Helper\Data as MsrpHelper;
+use Magento\Store\Model\ScopeInterface;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class SpecialTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class SpecialTest extends \PHPUnit\Framework\TestCase
+class SpecialTest extends TestCase
{
/**
* @var \Magento\Catalog\Block\Rss\Product\Special
@@ -19,88 +36,88 @@ class SpecialTest extends \PHPUnit\Framework\TestCase
protected $block;
/**
- * @var \Magento\Framework\App\Http\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $httpContext;
/**
- * @var \Magento\Catalog\Helper\Image|\PHPUnit_Framework_MockObject_MockObject
+ * @var Image|MockObject
*/
protected $imageHelper;
/**
- * @var \Magento\Catalog\Helper\Output|\PHPUnit_Framework_MockObject_MockObject
+ * @var Output|MockObject
*/
protected $outputHelper;
/**
- * @var \Magento\Catalog\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Helper\Data|MockObject
*/
protected $msrpHelper;
/**
- * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceCurrencyInterface|MockObject
*/
protected $priceCurrency;
/**
- * @var \Magento\Catalog\Model\Rss\Product\Special|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Model\Rss\Product\Special|MockObject
*/
protected $rssModel;
/**
- * @var \Magento\Framework\App\Rss\UrlBuilderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlBuilderInterface|MockObject
*/
protected $rssUrlBuilder;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManager;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $scopeConfig;
/**
- * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var TimezoneInterface|MockObject
*/
protected $localeDate;
/**
- * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $request;
- protected function setUp()
+ protected function setUp(): void
{
- $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class);
+ $this->request = $this->createMock(RequestInterface::class);
$this->request->expects($this->at(0))->method('getParam')->with('store_id')->will($this->returnValue(null));
$this->request->expects($this->at(1))->method('getParam')->with('cid')->will($this->returnValue(null));
- $this->httpContext = $this->getMockBuilder(\Magento\Framework\App\Http\Context::class)
+ $this->httpContext = $this->getMockBuilder(Context::class)
->setMethods(['getValue'])->disableOriginalConstructor()->getMock();
$this->httpContext->expects($this->any())->method('getValue')->will($this->returnValue(1));
- $this->imageHelper = $this->createMock(\Magento\Catalog\Helper\Image::class);
- $this->outputHelper = $this->createPartialMock(\Magento\Catalog\Helper\Output::class, ['productAttribute']);
- $this->msrpHelper = $this->createPartialMock(\Magento\Msrp\Helper\Data::class, ['canApplyMsrp']);
- $this->priceCurrency = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class);
- $this->rssModel = $this->createMock(\Magento\Catalog\Model\Rss\Product\Special::class);
- $this->rssUrlBuilder = $this->createMock(\Magento\Framework\App\Rss\UrlBuilderInterface::class);
+ $this->imageHelper = $this->createMock(Image::class);
+ $this->outputHelper = $this->createPartialMock(Output::class, ['productAttribute']);
+ $this->msrpHelper = $this->createPartialMock(MsrpHelper::class, ['canApplyMsrp']);
+ $this->priceCurrency = $this->createMock(PriceCurrencyInterface::class);
+ $this->rssModel = $this->createMock(Special::class);
+ $this->rssUrlBuilder = $this->createMock(UrlBuilderInterface::class);
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
+ $this->storeManager = $this->createMock(StoreManagerInterface::class);
+ $store = $this->getMockBuilder(Store::class)
->setMethods(['getId', 'getFrontendName', '__wakeup'])->disableOriginalConstructor()->getMock();
$store->expects($this->any())->method('getId')->will($this->returnValue(1));
$store->expects($this->any())->method('getFrontendName')->will($this->returnValue('Store 1'));
$this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
- $this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $this->scopeConfig = $this->createMock(ScopeConfigInterface::class);
$this->scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue('en_US'));
- $this->localeDate = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
+ $this->localeDate = $this->createMock(TimezoneInterface::class);
$objectManagerHelper = new ObjectManagerHelper($this);
$this->block = $objectManagerHelper->getObject(
@@ -168,11 +185,11 @@ public function testGetRssData()
}
/**
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
protected function getItemMock()
{
- $item = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $item = $this->getMockBuilder(Product::class)
->setMethods([
'__wakeup',
'__sleep',
@@ -204,7 +221,7 @@ protected function getItemMock()
public function testIsAllowed()
{
$this->scopeConfig->expects($this->once())->method('isSetFlag')
- ->with('rss/catalog/special', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
+ ->with('rss/catalog/special', ScopeInterface::SCOPE_STORE)
->will($this->returnValue(true));
$this->assertEquals(true, $this->block->isAllowed());
}
@@ -217,7 +234,7 @@ public function testGetCacheLifetime()
public function testGetFeeds()
{
$this->scopeConfig->expects($this->once())->method('isSetFlag')
- ->with('rss/catalog/special', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
+ ->with('rss/catalog/special', ScopeInterface::SCOPE_STORE)
->will($this->returnValue(true));
$this->rssUrlBuilder->expects($this->once())->method('getUrl')
->with(['type' => 'special_products'])
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Ui/ProductViewCounterTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Ui/ProductViewCounterTest.php
index 85ab52384740d..d7b4acc6ece74 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Ui/ProductViewCounterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Ui/ProductViewCounterTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Block\Ui;
@@ -20,68 +21,70 @@
use Magento\Framework\View\Element\Template\Context;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ProductViewCounterTest extends \PHPUnit\Framework\TestCase
+class ProductViewCounterTest extends TestCase
{
/**
- * @var \Magento\Catalog\Block\Ui\ProductViewCounter|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductViewCounter|MockObject
*/
private $productViewCounter;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $contextMock;
/**
- * @var ProductRepository|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductRepository|MockObject
*/
private $productRepositoryMock;
/**
- * @var ProductRenderCollectorComposite|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductRenderCollectorComposite|MockObject
*/
private $productRenderCollectorCompositeMock;
/**
- * @var Hydrator|\PHPUnit_Framework_MockObject_MockObject
+ * @var Hydrator|MockObject
*/
private $hydratorMock;
/**
- * @var SerializerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var SerializerInterface|MockObject
*/
private $serializeMock;
/**
- * @var Url|\PHPUnit_Framework_MockObject_MockObject
+ * @var Url|MockObject
*/
private $urlMock;
/**
- * @var Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
private $registryMock;
/**
- * @var StoreManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManager|MockObject
*/
private $storeManagerMock;
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $scopeConfigMock;
/**
- * @var ProductRenderFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductRenderFactory|MockObject
*/
private $productRenderFactoryMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->contextMock = $this->getMockBuilder(Context::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Widget/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Widget/LinkTest.php
index dcbd3161733aa..f8ce6b94034ed 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Widget/LinkTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Widget/LinkTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Block\Widget;
use Exception;
@@ -18,10 +20,9 @@
use Magento\Store\Model\StoreManagerInterface;
use Magento\UrlRewrite\Model\UrlFinderInterface;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
-use PHPUnit_Framework_MockObject_MockObject;
use ReflectionClass;
-use RuntimeException;
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -31,12 +32,12 @@
class LinkTest extends TestCase
{
/**
- * @var PHPUnit_Framework_MockObject_MockObject|StoreManagerInterface
+ * @var MockObject|StoreManagerInterface
*/
protected $storeManager;
/**
- * @var PHPUnit_Framework_MockObject_MockObject|UrlFinderInterface
+ * @var MockObject|UrlFinderInterface
*/
protected $urlFinder;
@@ -46,14 +47,14 @@ class LinkTest extends TestCase
protected $block;
/**
- * @var AbstractResource|PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractResource|MockObject
*/
protected $entityResource;
/**
* @inheritDoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->storeManager = $this->createMock(StoreManagerInterface::class);
$this->urlFinder = $this->createMock(UrlFinderInterface::class);
@@ -78,34 +79,31 @@ protected function setUp()
/**
* Tests getHref with wrong id_path
- *
- * @expectedException RuntimeException
- * @expectedExceptionMessage Parameter id_path is not set.
*/
public function testGetHrefWithoutSetIdPath()
{
+ $this->expectException('RuntimeException');
+ $this->expectExceptionMessage('Parameter id_path is not set.');
$this->block->getHref();
}
/**
* Tests getHref with wrong id_path
- *
- * @expectedException RuntimeException
- * @expectedExceptionMessage Wrong id_path structure.
*/
public function testGetHrefIfSetWrongIdPath()
{
+ $this->expectException('RuntimeException');
+ $this->expectExceptionMessage('Wrong id_path structure.');
$this->block->setData('id_path', 'wrong_id_path');
$this->block->getHref();
}
/**
* Tests getHref with wrong store ID
- *
- * @expectedException Exception
*/
public function testGetHrefWithSetStoreId()
{
+ $this->expectException('Exception');
$this->block->setData('id_path', 'type/id');
$this->block->setData('store_id', 'store_id');
$this->storeManager->expects($this->once())
@@ -197,7 +195,7 @@ public function testStoreCodeShouldBeIncludedInURLOnlyIfItIsConfiguredSo(
->willReturnCallback(
function ($route, $params) use ($storeId) {
$baseUrl = rtrim($this->storeManager->getStore($storeId)->getBaseUrl(), '/');
- return $baseUrl .'/' . ltrim($params['_direct'], '/');
+ return $baseUrl . '/' . ltrim($params['_direct'], '/');
}
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/DeleteTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/DeleteTest.php
index 196b4df5b47c0..5c8153ef7642f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/DeleteTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/DeleteTest.php
@@ -3,40 +3,54 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\Auth;
+use Magento\Backend\Model\Auth\StorageInterface;
+use Magento\Backend\Model\View\Result\Redirect;
+use Magento\Backend\Model\View\Result\RedirectFactory;
+use Magento\Catalog\Api\CategoryRepositoryInterface;
+use Magento\Catalog\Controller\Adminhtml\Category\Delete;
+use Magento\Catalog\Model\Category;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\App\ResponseInterface;
+use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class DeleteTest extends \PHPUnit\Framework\TestCase
+class DeleteTest extends TestCase
{
- /** @var \Magento\Catalog\Controller\Adminhtml\Category\Delete */
+ /** @var Delete */
protected $unit;
- /** @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Redirect|MockObject */
protected $resultRedirect;
- /** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var RequestInterface|MockObject */
protected $request;
- /** @var \Magento\Catalog\Api\CategoryRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var CategoryRepositoryInterface|MockObject */
protected $categoryRepository;
- /** @var \Magento\Backend\Model\Auth\StorageInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var StorageInterface|MockObject */
protected $authStorage;
- protected function setUp()
+ protected function setUp(): void
{
- $context = $this->createMock(\Magento\Backend\App\Action\Context::class);
+ $context = $this->createMock(Context::class);
$resultRedirectFactory = $this->createPartialMock(
- \Magento\Backend\Model\View\Result\RedirectFactory::class,
+ RedirectFactory::class,
['create']
);
$this->request = $this->getMockForAbstractClass(
- \Magento\Framework\App\RequestInterface::class,
+ RequestInterface::class,
[],
'',
false,
@@ -44,13 +58,13 @@ protected function setUp()
true,
['getParam', 'getPost']
);
- $auth = $this->createPartialMock(\Magento\Backend\Model\Auth::class, ['getAuthStorage']);
+ $auth = $this->createPartialMock(Auth::class, ['getAuthStorage']);
$this->authStorage = $this->createPartialMock(
- \Magento\Backend\Model\Auth\StorageInterface::class,
+ StorageInterface::class,
['processLogin', 'processLogout', 'isLoggedIn', 'prolong', 'setDeletedPath']
);
$eventManager = $this->getMockForAbstractClass(
- \Magento\Framework\Event\ManagerInterface::class,
+ ManagerInterface::class,
[],
'',
false,
@@ -59,7 +73,7 @@ protected function setUp()
['dispatch']
);
$response = $this->getMockForAbstractClass(
- \Magento\Framework\App\ResponseInterface::class,
+ ResponseInterface::class,
[],
'',
false
@@ -73,7 +87,7 @@ protected function setUp()
true,
['addSuccessMessage']
);
- $this->categoryRepository = $this->createMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class);
+ $this->categoryRepository = $this->createMock(CategoryRepositoryInterface::class);
$context->expects($this->any())
->method('getRequest')
->will($this->returnValue($this->request));
@@ -94,11 +108,11 @@ protected function setUp()
->method('getAuthStorage')
->will($this->returnValue($this->authStorage));
- $this->resultRedirect = $this->createMock(\Magento\Backend\Model\View\Result\Redirect::class);
+ $this->resultRedirect = $this->createMock(Redirect::class);
$resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
$this->unit = (new ObjectManagerHelper($this))->getObject(
- \Magento\Catalog\Controller\Adminhtml\Category\Delete::class,
+ Delete::class,
[
'context' => $context,
'categoryRepository' => $this->categoryRepository
@@ -121,7 +135,7 @@ public function testDelete()
$categoryId = 5;
$parentId = 7;
$this->request->expects($this->any())->method('getParam')->with('id')->willReturn($categoryId);
- $category = $this->createPartialMock(\Magento\Catalog\Model\Category::class, ['getParentId', 'getPath']);
+ $category = $this->createPartialMock(Category::class, ['getParentId', 'getPath']);
$category->expects($this->once())->method('getParentId')->willReturn($parentId);
$category->expects($this->once())->method('getPath')->willReturn('category-path');
$this->categoryRepository->expects($this->once())->method('get')->with($categoryId)->willReturn($category);
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/EditTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/EditTest.php
index 7d4fa86cd6901..d089d35b72ca9 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/EditTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/EditTest.php
@@ -3,86 +3,106 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\Session;
+use Magento\Backend\Model\View\Result\RedirectFactory;
+use Magento\Catalog\Controller\Adminhtml\Category\Edit;
+use Magento\Catalog\Model\Category;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\App\ResponseInterface;
+use Magento\Framework\Controller\Result\JsonFactory;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\LayoutFactory;
+use Magento\Framework\View\Page\Title;
+use Magento\Framework\View\Result\Page as ResultPage;
+use Magento\Framework\View\Result\PageFactory;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
- * Class EditTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class EditTest extends \PHPUnit\Framework\TestCase
+class EditTest extends TestCase
{
/**
- * @var \Magento\Backend\Model\View\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var RedirectFactory|MockObject
*/
protected $resultRedirectFactoryMock;
/**
- * @var \Magento\Backend\Model\View\Result\PageFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Backend\Model\View\Result\PageFactory|MockObject
*/
protected $resultPageFactoryMock;
/**
- * @var \Magento\Backend\Model\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Backend\Model\View\Result\Page|MockObject
*/
protected $resultPageMock;
/**
- * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var JsonFactory|MockObject
*/
protected $resultJsonFactoryMock;
/**
- * @var \Magento\Framework\View\LayoutFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutFactory|MockObject
*/
protected $storeManagerInterfaceMock;
/**
- * @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $contextMock;
/**
- * @var \Magento\Framework\View\Page\Title|\PHPUnit_Framework_MockObject_MockObject
+ * @var Title|MockObject
*/
protected $titleMock;
/**
- * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $requestMock;
/**
- * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
protected $objectManagerMock;
/**
- * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
protected $eventManagerMock;
/**
- * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResponseInterface|MockObject
*/
protected $responseMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManager;
/**
- * @var \Magento\Catalog\Controller\Adminhtml\Category\Edit
+ * @var Edit
*/
protected $edit;
/**
- * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject
+ * @var Session|MockObject
*/
protected $sessionMock;
/**
- * @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject
+ * @var Category|MockObject
*/
protected $categoryMock;
@@ -92,12 +112,12 @@ class EditTest extends \PHPUnit\Framework\TestCase
* @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
$this->categoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\Category::class,
+ Category::class,
[
'getPath',
'addData',
@@ -110,7 +130,7 @@ protected function setUp()
);
$this->contextMock = $this->createPartialMock(
- \Magento\Backend\App\Action\Context::class,
+ Context::class,
[
'getTitle',
'getRequest',
@@ -124,12 +144,12 @@ protected function setUp()
);
$this->resultRedirectFactoryMock = $this->createPartialMock(
- \Magento\Backend\Model\View\Result\RedirectFactory::class,
+ RedirectFactory::class,
['create']
);
$this->resultPageMock = $this->createPartialMock(
- \Magento\Framework\View\Result\Page::class,
+ ResultPage::class,
['setActiveMenu', 'getConfig', 'addBreadcrumb', 'getLayout', 'getBlock', 'getTitle', 'prepend']
);
$this->resultPageMock->expects($this->any())
@@ -140,7 +160,7 @@ protected function setUp()
->will($this->returnSelf());
$this->resultPageFactoryMock = $this->createPartialMock(
- \Magento\Framework\View\Result\PageFactory::class,
+ PageFactory::class,
['create']
);
$this->resultPageFactoryMock->expects($this->any())
@@ -148,11 +168,11 @@ protected function setUp()
->willReturn($this->resultPageMock);
$this->resultJsonFactoryMock = $this->createPartialMock(
- \Magento\Framework\Controller\Result\JsonFactory::class,
+ JsonFactory::class,
['create']
);
$this->storeManagerInterfaceMock = $this->getMockForAbstractClass(
- \Magento\Store\Model\StoreManagerInterface::class,
+ StoreManagerInterface::class,
[],
'',
false,
@@ -161,7 +181,7 @@ protected function setUp()
['getStore', 'getDefaultStoreView', 'getRootCategoryId', 'getCode']
);
$this->requestMock = $this->getMockForAbstractClass(
- \Magento\Framework\App\RequestInterface::class,
+ RequestInterface::class,
[],
'',
false,
@@ -169,11 +189,11 @@ protected function setUp()
true,
['getParam', 'getPost', 'getPostValue', 'getQuery', 'setParam']
);
- $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)
+ $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
->disableOriginalConstructor()
->getMock();
$this->eventManagerMock = $this->getMockForAbstractClass(
- \Magento\Framework\Event\ManagerInterface::class,
+ ManagerInterface::class,
[],
'',
false,
@@ -181,7 +201,7 @@ protected function setUp()
true,
['dispatch']
);
- $this->sessionMock = $this->createPartialMock(\Magento\Backend\Model\Session::class, ['__call']);
+ $this->sessionMock = $this->createPartialMock(Session::class, ['__call']);
$this->contextMock->expects($this->any())->method('getTitle')->willReturn($this->titleMock);
$this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
@@ -194,7 +214,7 @@ protected function setUp()
->willReturn($this->resultRedirectFactoryMock);
$this->edit = $this->objectManager->getObject(
- \Magento\Catalog\Controller\Adminhtml\Category\Edit::class,
+ Edit::class,
[
'context' => $this->contextMock,
'resultPageFactory' => $this->resultPageFactoryMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Image/UploadTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Image/UploadTest.php
index e2cd01fd1c23a..7aa2aee64b800 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Image/UploadTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Image/UploadTest.php
@@ -3,24 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category\Image;
use Magento\Catalog\Controller\Adminhtml\Category\Image\Upload as Model;
-use Magento\Framework\App\Request\Http as Request;
use Magento\Catalog\Model\ImageUploader;
+use Magento\Framework\App\Request\Http as Request;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\DataObject;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-/**
- * Class UploadTest
- */
-class UploadTest extends \PHPUnit\Framework\TestCase
+class UploadTest extends TestCase
{
private $objectManager;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
}
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php
index da58943bb3722..1d6637bfa2c09 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php
@@ -3,71 +3,86 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category;
+use Magento\Backend\App\Action\Context;
use Magento\Catalog\Controller\Adminhtml\Category\Move;
+use Magento\Catalog\Model\Category;
+use Magento\Cms\Model\Wysiwyg\Config;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\Controller\Result\Json;
+use Magento\Framework\Controller\Result\JsonFactory;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Message\Collection;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Registry;
+use Magento\Framework\View\Element\Messages;
+use Magento\Framework\View\LayoutFactory;
+use Magento\Framework\View\LayoutInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
/**
- * Class MoveTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class MoveTest extends \PHPUnit\Framework\TestCase
+class MoveTest extends TestCase
{
/**
- * @var \Magento\Framework\Controller\Result\JsonFactory | \PHPUnit_Framework_MockObject_MockObject
+ * @var JsonFactory|MockObject
*/
private $resultJsonFactoryMock;
/**
- * @var \Magento\Framework\View\LayoutFactory | \PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutFactory|MockObject
*/
private $layoutFactoryMock;
/**
- * @var \Psr\Log\LoggerInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
private $loggerMock;
/**
- * @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $context;
/**
- * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
private $request;
/**
- * @var \Magento\Catalog\Controller\Adminhtml\Category\Move
+ * @var Move
*/
private $moveController;
/**
- * @var ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
private $objectManager;
/**
- * @var ManagerInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
private $messageManager;
- public function setUp()
+ public function setUp(): void
{
- $this->resultJsonFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class)
+ $this->resultJsonFactoryMock = $this->getMockBuilder(JsonFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
- $this->layoutFactoryMock = $this->getMockBuilder(\Magento\Framework\View\LayoutFactory::class)
+ $this->layoutFactoryMock = $this->getMockBuilder(LayoutFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
- $this->context = $this->createMock(\Magento\Backend\App\Action\Context::class);
- $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class);
+ $this->context = $this->createMock(Context::class);
+ $this->loggerMock = $this->createMock(LoggerInterface::class);
$this->fillContext();
$this->moveController = new Move(
@@ -82,7 +97,7 @@ public function setUp()
private function fillContext()
{
$this->request = $this
- ->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
+ ->getMockBuilder(RequestInterface::class)
->setMethods(['getPost'])
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -102,26 +117,26 @@ private function initObjectManager()
public function testExecuteWithGenericException()
{
- $messagesCollection = $this->getMockBuilder(\Magento\Framework\Message\Collection::class)
+ $messagesCollection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
- $messageBlock = $this->getMockBuilder(\Magento\Framework\View\Element\Messages::class)
+ $messageBlock = $this->getMockBuilder(Messages::class)
->disableOriginalConstructor()
->getMock();
- $layoutMock = $this->createMock(\Magento\Framework\View\LayoutInterface::class);
+ $layoutMock = $this->createMock(LayoutInterface::class);
$this->layoutFactoryMock->expects($this->once())
->method('create')
->willReturn($layoutMock);
$layoutMock->expects($this->once())
->method('getMessagesBlock')
->willReturn($messageBlock);
- $wysiwygConfig = $this->getMockBuilder(\Magento\Cms\Model\Wysiwyg\Config::class)
+ $wysiwygConfig = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
$registry = $this->getMockBuilder(Registry::class)
->disableOriginalConstructor()
->getMock();
- $categoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $categoryMock = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->getMock();
$this->request->expects($this->exactly(2))
@@ -130,14 +145,14 @@ public function testExecuteWithGenericException()
->willReturnMap([['pid', false, 2], ['aid', false, 1]]);
$this->objectManager->expects($this->once())
->method('create')
- ->with(\Magento\Catalog\Model\Category::class)
+ ->with(Category::class)
->willReturn($categoryMock);
$this->objectManager->expects($this->any())
->method('get')
- ->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfig]]);
+ ->willReturnMap([[Registry::class, $registry], [Config::class, $wysiwygConfig]]);
$categoryMock->expects($this->once())
->method('move')
- ->willThrowException(new \Exception(__('Some exception')));
+ ->willThrowException(new \Exception('Some exception'));
$this->messageManager->expects($this->once())
->method('addErrorMessage')
->with(__('There was a category move error.'));
@@ -148,7 +163,7 @@ public function testExecuteWithGenericException()
$messageBlock->expects($this->once())
->method('setMessages')
->with($messagesCollection);
- $resultJsonMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class)
+ $resultJsonMock = $this->getMockBuilder(Json::class)
->disableOriginalConstructor()
->getMock();
$messageBlock->expects($this->once())
@@ -173,26 +188,26 @@ public function testExecuteWithGenericException()
public function testExecuteWithLocalizedException()
{
$exceptionMessage = 'Sorry, but we can\'t find the new category you selected.';
- $messagesCollection = $this->getMockBuilder(\Magento\Framework\Message\Collection::class)
+ $messagesCollection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
- $messageBlock = $this->getMockBuilder(\Magento\Framework\View\Element\Messages::class)
+ $messageBlock = $this->getMockBuilder(Messages::class)
->disableOriginalConstructor()
->getMock();
- $layoutMock = $this->createMock(\Magento\Framework\View\LayoutInterface::class);
+ $layoutMock = $this->createMock(LayoutInterface::class);
$this->layoutFactoryMock->expects($this->once())
->method('create')
->willReturn($layoutMock);
$layoutMock->expects($this->once())
->method('getMessagesBlock')
->willReturn($messageBlock);
- $wysiwygConfig = $this->getMockBuilder(\Magento\Cms\Model\Wysiwyg\Config::class)
+ $wysiwygConfig = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
$registry = $this->getMockBuilder(Registry::class)
->disableOriginalConstructor()
->getMock();
- $categoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $categoryMock = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->getMock();
$this->request->expects($this->exactly(2))
@@ -201,11 +216,11 @@ public function testExecuteWithLocalizedException()
->willReturnMap([['pid', false, 2], ['aid', false, 1]]);
$this->objectManager->expects($this->once())
->method('create')
- ->with(\Magento\Catalog\Model\Category::class)
+ ->with(Category::class)
->willReturn($categoryMock);
$this->objectManager->expects($this->any())
->method('get')
- ->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfig]]);
+ ->willReturnMap([[Registry::class, $registry], [Config::class, $wysiwygConfig]]);
$this->messageManager->expects($this->once())
->method('addExceptionMessage');
$this->messageManager->expects($this->once())
@@ -215,7 +230,7 @@ public function testExecuteWithLocalizedException()
$messageBlock->expects($this->once())
->method('setMessages')
->with($messagesCollection);
- $resultJsonMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class)
+ $resultJsonMock = $this->getMockBuilder(Json::class)
->disableOriginalConstructor()
->getMock();
$messageBlock->expects($this->once())
@@ -232,7 +247,7 @@ public function testExecuteWithLocalizedException()
->willReturn(true);
$categoryMock->expects($this->once())
->method('move')
- ->willThrowException(new \Magento\Framework\Exception\LocalizedException(__($exceptionMessage)));
+ ->willThrowException(new LocalizedException(__($exceptionMessage)));
$this->resultJsonFactoryMock
->expects($this->once())
->method('create')
@@ -242,26 +257,26 @@ public function testExecuteWithLocalizedException()
public function testSuccessfulCategorySave()
{
- $messagesCollection = $this->getMockBuilder(\Magento\Framework\Message\Collection::class)
+ $messagesCollection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
- $messageBlock = $this->getMockBuilder(\Magento\Framework\View\Element\Messages::class)
+ $messageBlock = $this->getMockBuilder(Messages::class)
->disableOriginalConstructor()
->getMock();
- $layoutMock = $this->createMock(\Magento\Framework\View\LayoutInterface::class);
+ $layoutMock = $this->createMock(LayoutInterface::class);
$this->layoutFactoryMock->expects($this->once())
->method('create')
->willReturn($layoutMock);
$layoutMock->expects($this->once())
->method('getMessagesBlock')
->willReturn($messageBlock);
- $wysiwygConfig = $this->getMockBuilder(\Magento\Cms\Model\Wysiwyg\Config::class)
+ $wysiwygConfig = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
$registry = $this->getMockBuilder(Registry::class)
->disableOriginalConstructor()
->getMock();
- $categoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $categoryMock = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->getMock();
$this->request->expects($this->exactly(2))
@@ -270,11 +285,11 @@ public function testSuccessfulCategorySave()
->willReturnMap([['pid', false, 2], ['aid', false, 1]]);
$this->objectManager->expects($this->once())
->method('create')
- ->with(\Magento\Catalog\Model\Category::class)
+ ->with(Category::class)
->willReturn($categoryMock);
$this->objectManager->expects($this->any())
->method('get')
- ->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfig]]);
+ ->willReturnMap([[Registry::class, $registry], [Config::class, $wysiwygConfig]]);
$this->messageManager->expects($this->once())
->method('getMessages')
->with(true)
@@ -282,7 +297,7 @@ public function testSuccessfulCategorySave()
$messageBlock->expects($this->once())
->method('setMessages')
->with($messagesCollection);
- $resultJsonMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class)
+ $resultJsonMock = $this->getMockBuilder(Json::class)
->disableOriginalConstructor()
->getMock();
$messageBlock->expects($this->once())
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/RefreshPathTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/RefreshPathTest.php
index adf00333721ba..d7f0f5383212e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/RefreshPathTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/RefreshPathTest.php
@@ -8,30 +8,34 @@
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category;
-use Magento\Framework\Controller\Result\JsonFactory;
-use Magento\Catalog\Controller\Adminhtml\Category\RefreshPath;
use Magento\Backend\App\Action\Context;
+use Magento\Catalog\Controller\Adminhtml\Category\RefreshPath;
+use Magento\Catalog\Model\Category;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test for class Magento\Catalog\Controller\Adminhtml\Category\RefreshPath.
*/
-class RefreshPathTest extends \PHPUnit\Framework\TestCase
+class RefreshPathTest extends TestCase
{
/**
- * @var JsonFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var JsonFactory|MockObject
*/
private $resultJsonFactoryMock;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $contextMock;
/**
* @inheritDoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->resultJsonFactoryMock = $this->getMockBuilder(JsonFactory::class)
->disableOriginalConstructor()
@@ -69,7 +73,7 @@ public function testExecute() : void
$value = ['id' => 3, 'path' => '1/2/3', 'parentId' => 2, 'level' => 2];
$result = '{"id":3,"path":"1/2/3","parentId":"2","level":"2"}';
- $requestMock = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class);
+ $requestMock = $this->getMockForAbstractClass(RequestInterface::class);
$refreshPath = $this->getMockBuilder(RefreshPath::class)
->setMethods(['getRequest', 'create'])
@@ -81,7 +85,7 @@ public function testExecute() : void
$refreshPath->expects($this->any())->method('getRequest')->willReturn($requestMock);
$requestMock->expects($this->any())->method('getParam')->with('id')->willReturn($value['id']);
- $categoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $categoryMock = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->setMethods(['getPath', 'getParentId', 'getResource'])
->getMock();
@@ -101,7 +105,7 @@ public function testExecute() : void
$objectManagerMock->expects($this->once())
->method('create')
- ->with(\Magento\Catalog\Model\Category::class)
+ ->with(Category::class)
->willReturn($categoryMock);
$this->resultJsonFactoryMock->expects($this->any())->method('create')->willReturnSelf();
@@ -118,7 +122,7 @@ public function testExecute() : void
*/
public function testExecuteWithoutCategoryId() : void
{
- $requestMock = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class);
+ $requestMock = $this->getMockForAbstractClass(RequestInterface::class);
$refreshPath = $this->getMockBuilder(RefreshPath::class)
->setMethods(['getRequest', 'create'])
@@ -139,7 +143,7 @@ public function testExecuteWithoutCategoryId() : void
$objectManagerMock->expects($this->never())
->method('create')
- ->with(\Magento\Catalog\Model\Category::class)
+ ->with(Category::class)
->willReturnSelf();
$refreshPath->execute();
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php
index 74173dc926d97..dd91b85a1610d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php
@@ -3,56 +3,81 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category;
+use Magento\Backend\Model\Auth\Session;
+use Magento\Backend\Model\View\Result\Redirect;
+use Magento\Backend\Model\View\Result\RedirectFactory;
+use Magento\Catalog\Api\Data\CategoryAttributeInterface;
+use Magento\Catalog\Controller\Adminhtml\Category\Save;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Category\Attribute\Backend\Image;
+use Magento\Cms\Model\Wysiwyg\Config;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\Controller\Result\Json;
+use Magento\Framework\Controller\Result\JsonFactory;
+use Magento\Framework\DataObject;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\Message\Collection;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\Registry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Element\Messages;
+use Magento\Framework\View\Layout;
+use Magento\Framework\View\LayoutFactory;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
- * Class SaveTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class SaveTest extends \PHPUnit\Framework\TestCase
+class SaveTest extends TestCase
{
/**
- * @var \Magento\Backend\Model\View\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var RedirectFactory|MockObject
*/
private $resultRedirectFactoryMock;
/**
- * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var JsonFactory|MockObject
*/
private $resultJsonFactoryMock;
/**
- * @var \Magento\Framework\View\LayoutFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutFactory|MockObject
*/
private $layoutFactoryMock;
/**
- * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
private $requestMock;
/**
- * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
private $objectManagerMock;
/**
- * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
private $eventManagerMock;
/**
- * @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\Message\ManagerInterface|MockObject
*/
private $messageManagerMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManager;
/**
- * @var \Magento\Catalog\Controller\Adminhtml\Category\Save
+ * @var Save
*/
private $save;
@@ -62,20 +87,20 @@ class SaveTest extends \PHPUnit\Framework\TestCase
* @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
$this->resultRedirectFactoryMock = $this->createPartialMock(
- \Magento\Backend\Model\View\Result\RedirectFactory::class,
+ RedirectFactory::class,
['create']
);
$this->resultJsonFactoryMock = $this->createPartialMock(
- \Magento\Framework\Controller\Result\JsonFactory::class,
+ JsonFactory::class,
['create']
);
- $this->layoutFactoryMock = $this->createPartialMock(\Magento\Framework\View\LayoutFactory::class, ['create']);
+ $this->layoutFactoryMock = $this->createPartialMock(LayoutFactory::class, ['create']);
$this->requestMock = $this->getMockForAbstractClass(
- \Magento\Framework\App\RequestInterface::class,
+ RequestInterface::class,
[],
'',
false,
@@ -83,11 +108,11 @@ protected function setUp()
true,
['getParam', 'getPost', 'getPostValue']
);
- $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)
+ $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
->disableOriginalConstructor()
->getMock();
$this->eventManagerMock = $this->getMockForAbstractClass(
- \Magento\Framework\Event\ManagerInterface::class,
+ ManagerInterface::class,
[],
'',
false,
@@ -106,7 +131,7 @@ protected function setUp()
);
$this->save = $this->objectManager->getObject(
- \Magento\Catalog\Controller\Adminhtml\Category\Save::class,
+ Save::class,
[
'request' => $this->requestMock,
'eventManager' => $this->eventManagerMock,
@@ -133,7 +158,7 @@ public function testExecute($categoryId, $storeId, $parentId)
{
$this->markTestSkipped('Due to MAGETWO-48956');
- $rootCategoryId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
+ $rootCategoryId = Category::TREE_ROOT_ID;
$products = [['any_product']];
$postData = [
'general-data',
@@ -145,23 +170,20 @@ public function testExecute($categoryId, $storeId, $parentId)
$postData['store_id'] = $storeId;
}
/**
- * @var \Magento\Backend\Model\View\Result\Redirect
- * |\PHPUnit_Framework_MockObject_MockObject $resultRedirectMock
+ * @var Redirect|MockObject $resultRedirectMock
*/
- $resultRedirectMock = $this->createMock(\Magento\Backend\Model\View\Result\Redirect::class);
+ $resultRedirectMock = $this->createMock(Redirect::class);
/**
- * @var \Magento\Framework\View\Element\Messages
- * |\PHPUnit_Framework_MockObject_MockObject $blockMock
+ * @var Messages|MockObject $blockMock
*/
$blockMock = $this->createPartialMock(
- \Magento\Framework\View\Element\Messages::class,
+ Messages::class,
['setMessages', 'getGroupedHtml']
);
/**
- * @var \Magento\Catalog\Model\Category
- * |\PHPUnit_Framework_MockObject_MockObject $categoryMock
+ * @var \Magento\Catalog\Model\Category|MockObject $categoryMock
*/
- $categoryMock = $this->createPartialMock(\Magento\Catalog\Model\Category::class, [
+ $categoryMock = $this->createPartialMock(Category::class, [
'setStoreId',
'load',
'getPath',
@@ -181,10 +203,9 @@ public function testExecute($categoryId, $storeId, $parentId)
'toArray'
]);
/**
- * @var \Magento\Catalog\Model\Category
- * |\PHPUnit_Framework_MockObject_MockObject $parentCategoryMock
+ * @var \Magento\Catalog\Model\Category|MockObject $parentCategoryMock
*/
- $parentCategoryMock = $this->createPartialMock(\Magento\Catalog\Model\Category::class, [
+ $parentCategoryMock = $this->createPartialMock(Category::class, [
'setStoreId',
'load',
'getPath',
@@ -199,26 +220,22 @@ public function testExecute($categoryId, $storeId, $parentId)
'getId'
]);
/**
- * @var \Magento\Backend\Model\Auth\Session
- * |\PHPUnit_Framework_MockObject_MockObject $sessionMock
+ * @var Session|MockObject $sessionMock
*/
- $sessionMock = $this->createMock(\Magento\Backend\Model\Auth\Session::class);
+ $sessionMock = $this->createMock(Session::class);
/**
- * @var \Magento\Framework\Registry
- * |\PHPUnit_Framework_MockObject_MockObject $registryMock
+ * @var Registry|MockObject $registryMock
*/
- $registryMock = $this->createPartialMock(\Magento\Framework\Registry::class, ['register']);
+ $registryMock = $this->createPartialMock(Registry::class, ['register']);
/**
- * @var \Magento\Cms\Model\Wysiwyg\Config
- * |\PHPUnit_Framework_MockObject_MockObject $wysiwygConfigMock
+ * @var Config|MockObject $wysiwygConfigMock
*/
- $wysiwygConfigMock = $this->createPartialMock(\Magento\Cms\Model\Wysiwyg\Config::class, ['setStoreId']);
+ $wysiwygConfigMock = $this->createPartialMock(Config::class, ['setStoreId']);
/**
- * @var \Magento\Store\Model\StoreManagerInterface
- * |\PHPUnit_Framework_MockObject_MockObject $storeManagerMock
+ * @var StoreManagerInterface|MockObject $storeManagerMock
*/
$storeManagerMock = $this->getMockForAbstractClass(
- \Magento\Store\Model\StoreManagerInterface::class,
+ StoreManagerInterface::class,
[],
'',
false,
@@ -227,11 +244,10 @@ public function testExecute($categoryId, $storeId, $parentId)
['getStore', 'getRootCategoryId']
);
/**
- * @var \Magento\Framework\View\Layout
- * |\PHPUnit_Framework_MockObject_MockObject $layoutMock
+ * @var Layout|MockObject $layoutMock
*/
$layoutMock = $this->getMockForAbstractClass(
- \Magento\Framework\View\Layout::class,
+ Layout::class,
[],
'',
false,
@@ -240,15 +256,13 @@ public function testExecute($categoryId, $storeId, $parentId)
['getMessagesBlock']
);
/**
- * @var \Magento\Framework\Controller\Result\Json
- * |\PHPUnit_Framework_MockObject_MockObject $resultJsonMock
+ * @var Json|MockObject $resultJsonMock
*/
- $resultJsonMock = $this->createPartialMock(\Magento\Cms\Model\Wysiwyg\Config::class, ['setData']);
+ $resultJsonMock = $this->createPartialMock(Config::class, ['setData']);
/**
- * @var \Magento\Framework\Message\Collection
- * |\PHPUnit_Framework_MockObject_MockObject $messagesMock
+ * @var Collection|MockObject $messagesMock
*/
- $messagesMock = $this->createMock(\Magento\Framework\Message\Collection::class);
+ $messagesMock = $this->createMock(Collection::class);
$messagesMock->expects($this->once())
->method('getCountByType')
@@ -276,10 +290,10 @@ public function testExecute($categoryId, $storeId, $parentId)
->will(
$this->returnValueMap(
[
- [\Magento\Backend\Model\Auth\Session::class, $sessionMock],
- [\Magento\Framework\Registry::class, $registryMock],
- [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfigMock],
- [\Magento\Store\Model\StoreManagerInterface::class, $storeManagerMock],
+ [Session::class, $sessionMock],
+ [Registry::class, $registryMock],
+ [Config::class, $wysiwygConfigMock],
+ [StoreManagerInterface::class, $storeManagerMock],
]
)
);
@@ -494,30 +508,30 @@ public function testImagePreprocessing($data, $expected)
$eavConfig = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityType']);
$imageBackendModel = $this->objectManager->getObject(
- \Magento\Catalog\Model\Category\Attribute\Backend\Image::class
+ Image::class
);
- $collection = new \Magento\Framework\DataObject(['attribute_collection' => [
- new \Magento\Framework\DataObject([
+ $collection = new DataObject(['attribute_collection' => [
+ new DataObject([
'attribute_code' => 'image',
'backend' => $imageBackendModel
]),
- new \Magento\Framework\DataObject([
+ new DataObject([
'attribute_code' => 'name',
- 'backend' => new \Magento\Framework\DataObject()
+ 'backend' => new DataObject()
]),
- new \Magento\Framework\DataObject([
+ new DataObject([
'attribute_code' => 'level',
- 'backend' => new \Magento\Framework\DataObject()
+ 'backend' => new DataObject()
]),
]]);
$eavConfig->expects($this->once())
->method('getEntityType')
- ->with(\Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE)
+ ->with(CategoryAttributeInterface::ENTITY_TYPE_CODE)
->will($this->returnValue($collection));
- $model = $this->objectManager->getObject(\Magento\Catalog\Controller\Adminhtml\Category\Save::class, [
+ $model = $this->objectManager->getObject(Save::class, [
'eavConfig' => $eavConfig
]);
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php
index 96084d3d6005f..a40ed23c34bc8 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php
@@ -4,72 +4,89 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category\Widget;
+use Magento\Backend\App\Action\Context;
+use Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser;
+use Magento\Catalog\Controller\Adminhtml\Category\Widget;
+use Magento\Catalog\Controller\Adminhtml\Category\Widget\CategoriesJson;
+use Magento\Catalog\Model\Category;
+use Magento\Framework\App\Response\Http;
+use Magento\Framework\App\View;
+use Magento\Framework\Controller\Result\Json;
+use Magento\Framework\Controller\Result\JsonFactory;
+use Magento\Framework\Registry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Layout;
+use Magento\Framework\View\LayoutFactory;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CategoriesJsonTest extends \PHPUnit\Framework\TestCase
+class CategoriesJsonTest extends TestCase
{
/**
- * @var \Magento\Catalog\Controller\Adminhtml\Category\Widget
+ * @var Widget
*/
protected $controller;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registryMock;
/**
- * @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject
+ * @var Http|MockObject
*/
protected $responseMock;
/**
- * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\App\Request\Http|MockObject
*/
protected $requestMock;
/**
- * @var \Magento\Framework\App\View|\PHPUnit_Framework_MockObject_MockObject
+ * @var View|MockObject
*/
protected $viewMock;
/**
- * @var \Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser|\PHPUnit_Framework_MockObject_MockObject
+ * @var Chooser|MockObject
*/
protected $chooserBlockMock;
/**
- * @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject
+ * @var Layout|MockObject
*/
protected $layoutMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager |\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManager|MockObject
*/
protected $objectManagerMock;
/**
- * @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject
+ * @var Json|MockObject
*/
protected $resultJson;
- protected function setUp()
+ protected function setUp(): void
{
- $this->responseMock = $this->createMock(\Magento\Framework\App\Response\Http::class);
+ $this->responseMock = $this->createMock(Http::class);
$this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class);
- $this->viewMock = $this->createPartialMock(\Magento\Framework\App\View::class, ['getLayout']);
+ $this->viewMock = $this->createPartialMock(View::class, ['getLayout']);
$this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class);
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $helper = new ObjectManager($this);
- $context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class)
+ $context = $this->getMockBuilder(Context::class)
->setMethods(['getRequest', 'getResponse', 'getMessageManager', 'getSession'])
->setConstructorArgs(
$helper->getConstructArguments(
- \Magento\Backend\App\Action\Context::class,
+ Context::class,
[
'response' => $this->responseMock,
'request' => $this->requestMock,
@@ -80,10 +97,10 @@ protected function setUp()
)
->getMock();
- $this->resultJson = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class)
+ $this->resultJson = $this->getMockBuilder(Json::class)
->disableOriginalConstructor()
->getMock();
- $resultJsonFactory = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class)
+ $resultJsonFactory = $this->getMockBuilder(JsonFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
@@ -91,9 +108,9 @@ protected function setUp()
->method('create')
->willReturn($this->resultJson);
- $this->layoutMock = $this->createPartialMock(\Magento\Framework\View\Layout::class, ['createBlock']);
+ $this->layoutMock = $this->createPartialMock(Layout::class, ['createBlock']);
- $layoutFactory = $this->getMockBuilder(\Magento\Framework\View\LayoutFactory::class)
+ $layoutFactory = $this->getMockBuilder(LayoutFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
@@ -103,8 +120,8 @@ protected function setUp()
$context->expects($this->once())->method('getRequest')->will($this->returnValue($this->requestMock));
$context->expects($this->once())->method('getResponse')->will($this->returnValue($this->responseMock));
- $this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
- $this->controller = new \Magento\Catalog\Controller\Adminhtml\Category\Widget\CategoriesJson(
+ $this->registryMock = $this->createMock(Registry::class);
+ $this->controller = new CategoriesJson(
$context,
$layoutFactory,
$resultJsonFactory,
@@ -114,7 +131,7 @@ protected function setUp()
protected function _getTreeBlock()
{
- $this->chooserBlockMock = $this->createMock(\Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser::class);
+ $this->chooserBlockMock = $this->createMock(Chooser::class);
$this->layoutMock->expects($this->once())->method('createBlock')->will(
$this->returnValue($this->chooserBlockMock)
);
@@ -126,11 +143,11 @@ public function testExecute()
$testCategoryId = 1;
$this->requestMock->expects($this->any())->method('getPost')->will($this->returnValue($testCategoryId));
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(Category::class);
$categoryMock->expects($this->once())->method('load')->will($this->returnValue($categoryMock));
$categoryMock->expects($this->once())->method('getId')->will($this->returnValue($testCategoryId));
$this->objectManagerMock->expects($this->once())->method('create')
- ->with($this->equalTo(\Magento\Catalog\Model\Category::class))->will($this->returnValue($categoryMock));
+ ->with($this->equalTo(Category::class))->will($this->returnValue($categoryMock));
$this->chooserBlockMock->expects($this->once())->method('setSelectedCategories')->will(
$this->returnValue($this->chooserBlockMock)
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/ChooserTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/ChooserTest.php
index e4fc9af7e83de..fb1a55d7218f3 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/ChooserTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/ChooserTest.php
@@ -4,67 +4,81 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category\Widget;
+use Magento\Backend\App\Action\Context;
+use Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser;
+use Magento\Catalog\Controller\Adminhtml\Category\Widget;
+use Magento\Framework\App\Response\Http;
+use Magento\Framework\App\View;
+use Magento\Framework\Controller\Result\Raw;
+use Magento\Framework\Controller\Result\RawFactory;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Layout;
+use Magento\Framework\View\LayoutFactory;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ChooserTest extends \PHPUnit\Framework\TestCase
+class ChooserTest extends TestCase
{
/**
- * @var \Magento\Catalog\Controller\Adminhtml\Category\Widget
+ * @var Widget
*/
protected $controller;
/**
- * @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject
+ * @var Http|MockObject
*/
protected $responseMock;
/**
- * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\App\Request\Http|MockObject
*/
protected $requestMock;
/**
- * @var \Magento\Framework\App\View|\PHPUnit_Framework_MockObject_MockObject
+ * @var View|MockObject
*/
protected $viewMock;
/**
- * @var \Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser|\PHPUnit_Framework_MockObject_MockObject
+ * @var Chooser|MockObject
*/
protected $chooserBlockMock;
/**
- * @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject
+ * @var Layout|MockObject
*/
protected $layoutMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager |\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManager|MockObject
*/
protected $objectManagerMock;
/**
- * @var \Magento\Framework\Controller\Result\Raw|\PHPUnit_Framework_MockObject_MockObject
+ * @var Raw|MockObject
*/
protected $resultRaw;
- protected function setUp()
+ protected function setUp(): void
{
- $this->responseMock = $this->createMock(\Magento\Framework\App\Response\Http::class);
+ $this->responseMock = $this->createMock(Http::class);
$this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class);
- $this->viewMock = $this->createPartialMock(\Magento\Framework\App\View::class, ['getLayout']);
+ $this->viewMock = $this->createPartialMock(View::class, ['getLayout']);
$this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class);
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $helper = new ObjectManager($this);
- $context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class)
+ $context = $this->getMockBuilder(Context::class)
->setMethods(['getRequest', 'getResponse', 'getMessageManager', 'getSession'])
->setConstructorArgs(
$helper->getConstructArguments(
- \Magento\Backend\App\Action\Context::class,
+ Context::class,
[
'response' => $this->responseMock,
'request' => $this->requestMock,
@@ -75,10 +89,10 @@ protected function setUp()
)
->getMock();
- $this->resultRaw = $this->getMockBuilder(\Magento\Framework\Controller\Result\Raw::class)
+ $this->resultRaw = $this->getMockBuilder(Raw::class)
->disableOriginalConstructor()
->getMock();
- $resultRawFactory = $this->getMockBuilder(\Magento\Framework\Controller\Result\RawFactory::class)
+ $resultRawFactory = $this->getMockBuilder(RawFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
@@ -86,8 +100,8 @@ protected function setUp()
->method('create')
->willReturn($this->resultRaw);
- $this->layoutMock = $this->createPartialMock(\Magento\Framework\View\Layout::class, ['createBlock']);
- $layoutFactory = $this->getMockBuilder(\Magento\Framework\View\LayoutFactory::class)
+ $this->layoutMock = $this->createPartialMock(Layout::class, ['createBlock']);
+ $layoutFactory = $this->getMockBuilder(LayoutFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
@@ -106,7 +120,7 @@ protected function setUp()
protected function _getTreeBlock()
{
- $this->chooserBlockMock = $this->createMock(\Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser::class);
+ $this->chooserBlockMock = $this->createMock(Chooser::class);
$this->layoutMock->expects($this->once())->method('createBlock')->will(
$this->returnValue($this->chooserBlockMock)
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/EditTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/EditTest.php
index 0ddd89afeac22..bf833b6691610 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/EditTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/EditTest.php
@@ -4,66 +4,89 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Action\Attribute;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\View\Result\Redirect;
+use Magento\Backend\Model\View\Result\RedirectFactory;
+use Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Edit;
+use Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save;
+use Magento\Catalog\Helper\Product\Edit\Action\Attribute;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\Message\ManagerInterface;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Page\Config;
+use Magento\Framework\View\Page\Title;
+use Magento\Framework\View\Result\Page;
+use Magento\Framework\View\Result\PageFactory;
+use Magento\Ui\Component\MassAction\Filter;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class EditTest extends \PHPUnit\Framework\TestCase
+class EditTest extends TestCase
{
- /** @var \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save */
+ /** @var Save */
private $object;
- /** @var \Magento\Catalog\Helper\Product\Edit\Action\Attribute|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Attribute|MockObject */
private $attributeHelper;
- /** @var \Magento\Backend\Model\View\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var RedirectFactory|MockObject */
private $resultRedirectFactory;
- /** @var \Magento\Ui\Component\MassAction\Filter|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Filter|MockObject */
private $filter;
- /** @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Context|MockObject */
private $context;
- /** @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var CollectionFactory|MockObject */
private $collectionFactory;
- /** @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Page|MockObject */
private $resultPage;
- /** @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Http|MockObject */
private $request;
- protected function setUp()
+ protected function setUp(): void
{
- $this->attributeHelper = $this->getMockBuilder(\Magento\Catalog\Helper\Product\Edit\Action\Attribute::class)
+ $this->attributeHelper = $this->getMockBuilder(Attribute::class)
->setMethods(['getProductIds', 'setProductIds'])
->disableOriginalConstructor()->getMock();
- $this->resultRedirectFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\RedirectFactory::class)
+ $this->resultRedirectFactory = $this->getMockBuilder(RedirectFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->filter = $this->getMockBuilder(\Magento\Ui\Component\MassAction\Filter::class)
+ $this->filter = $this->getMockBuilder(Filter::class)
->setMethods(['getCollection'])->disableOriginalConstructor()->getMock();
$this->collectionFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class
+ CollectionFactory::class
)->setMethods(['create'])->disableOriginalConstructor()->getMock();
- $this->resultPage = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class)
+ $this->resultPage = $this->getMockBuilder(Page::class)
->setMethods(['getConfig'])->disableOriginalConstructor()->getMock();
- $resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class)
+ $resultPageFactory = $this->getMockBuilder(PageFactory::class)
->setMethods(['create'])->disableOriginalConstructor()->getMock();
$resultPageFactory->expects($this->any())->method('create')->willReturn($this->resultPage);
$this->prepareContext();
- $this->object = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject(
- \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Edit::class,
+ $this->object = (new ObjectManager($this))->getObject(
+ Edit::class,
[
'context' => $this->context,
'attributeHelper' => $this->attributeHelper,
@@ -76,12 +99,12 @@ protected function setUp()
private function prepareContext()
{
- $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
+ $this->request = $this->getMockBuilder(Http::class)
->setMethods(['getParam', 'getParams', 'setParams'])
->disableOriginalConstructor()->getMock();
- $objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
- $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $objectManager = $this->createMock(ObjectManagerInterface::class);
+ $product = $this->getMockBuilder(Product::class)
->setMethods(['isProductsHasSku'])
->disableOriginalConstructor()->getMock();
$product->expects($this->any())->method('isProductsHasSku')
@@ -89,13 +112,13 @@ private function prepareContext()
->willReturn(true);
$objectManager->expects($this->any())
->method('create')
- ->with(\Magento\Catalog\Model\Product::class)
+ ->with(Product::class)
->willReturn($product);
- $messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class)
+ $messageManager = $this->getMockBuilder(ManagerInterface::class)
->setMethods([])
->disableOriginalConstructor()->getMock();
$messageManager->expects($this->any())->method('addErrorMessage')->willReturn(true);
- $this->context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class)
+ $this->context = $this->getMockBuilder(Context::class)
->setMethods(['getRequest', 'getObjectManager', 'getMessageManager', 'getResultRedirectFactory'])
->disableOriginalConstructor()->getMock();
$this->context->expects($this->any())->method('getRequest')->willReturn($this->request);
@@ -119,17 +142,17 @@ public function testExecutePageRequested()
$this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn([1, 2, 3]);
$this->attributeHelper->expects($this->any())->method('setProductIds')->with([1, 2, 3]);
- $collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class)
+ $collection = $this->getMockBuilder(Collection::class)
->setMethods(['getAllIds'])
->disableOriginalConstructor()->getMock();
$collection->expects($this->any())->method('getAllIds')->willReturn([1, 2, 3]);
$this->filter->expects($this->any())->method('getCollection')->with($collection)->willReturn($collection);
$this->collectionFactory->expects($this->any())->method('create')->willReturn($collection);
- $title = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class)
+ $title = $this->getMockBuilder(Title::class)
->setMethods(['prepend'])
->disableOriginalConstructor()->getMock();
- $config = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class)
+ $config = $this->getMockBuilder(Config::class)
->setMethods(['getTitle'])
->disableOriginalConstructor()->getMock();
$config->expects($this->any())->method('getTitle')->willReturn($title);
@@ -146,10 +169,10 @@ public function testExecutePageReload()
$this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn([1, 2, 3]);
$this->attributeHelper->expects($this->any())->method('setProductIds')->with([1, 2, 3]);
- $title = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class)
+ $title = $this->getMockBuilder(Title::class)
->setMethods(['prepend'])
->disableOriginalConstructor()->getMock();
- $config = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class)
+ $config = $this->getMockBuilder(Config::class)
->setMethods(['getTitle'])
->disableOriginalConstructor()->getMock();
$config->expects($this->any())->method('getTitle')->willReturn($title);
@@ -164,7 +187,7 @@ public function testExecutePageDirectAccess()
$this->request->expects($this->any())->method('getParams')->willReturn([]);
$this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn(null);
- $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class)
+ $resultRedirect = $this->getMockBuilder(Redirect::class)
->setMethods(['setPath'])
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/AddAttributeToTemplateTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/AddAttributeToTemplateTest.php
index a29336a8dca54..34cdfa6c32dd2 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/AddAttributeToTemplateTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/AddAttributeToTemplateTest.php
@@ -3,29 +3,33 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product;
-use Magento\Catalog\Controller\Adminhtml\Product\AddAttributeToTemplate;
-use Magento\Framework\Exception\LocalizedException;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Backend\App\Action\Context;
-use Magento\Catalog\Controller\Adminhtml\Product\Builder as ProductBuilder;
-use Magento\Framework\Controller\Result\JsonFactory;
-use Magento\Framework\App\RequestInterface;
use Magento\Catalog\Api\AttributeSetRepositoryInterface;
-use Magento\Eav\Api\Data\AttributeSetInterface;
-use Magento\Framework\Api\SearchCriteriaBuilder;
-use Magento\Framework\Api\SearchCriteria;
+use Magento\Catalog\Controller\Adminhtml\Product\AddAttributeToTemplate;
+use Magento\Catalog\Controller\Adminhtml\Product\Builder as ProductBuilder;
use Magento\Eav\Api\AttributeGroupRepositoryInterface;
-use Magento\Eav\Api\Data\AttributeGroupSearchResultsInterface;
-use Magento\Eav\Api\Data\AttributeGroupInterfaceFactory;
use Magento\Eav\Api\Data\AttributeGroupInterface;
+use Magento\Eav\Api\Data\AttributeGroupInterfaceFactory;
+use Magento\Eav\Api\Data\AttributeGroupSearchResultsInterface;
+use Magento\Eav\Api\Data\AttributeSetInterface;
+use Magento\Framework\Api\SearchCriteria;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\Result\Json;
+use Magento\Framework\Controller\Result\JsonFactory;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class AddAttributeToTemplateTest extends \PHPUnit\Framework\TestCase
+class AddAttributeToTemplateTest extends TestCase
{
/**
* @var ObjectManager
@@ -38,71 +42,71 @@ class AddAttributeToTemplateTest extends \PHPUnit\Framework\TestCase
private $controller;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $contextMock;
/**
- * @var ProductBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductBuilder|MockObject
*/
private $productBuilderMock;
/**
- * @var JsonFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var JsonFactory|MockObject
*/
private $resultJsonFactoryMock;
/**
- * @var RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
private $requestMock;
/**
- * @var AttributeSetRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeSetRepositoryInterface|MockObject
*/
private $attributeSetRepositoryMock;
/**
- * @var AttributeSetInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeSetInterface|MockObject
*/
private $attributeSetInterfaceMock;
/**
- * @var SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var SearchCriteriaBuilder|MockObject
*/
private $searchCriteriaBuilderMock;
/**
- * @var SearchCriteria|\PHPUnit_Framework_MockObject_MockObject
+ * @var SearchCriteria|MockObject
*/
private $searchCriteriaMock;
/**
- * @var AttributeGroupRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeGroupRepositoryInterface|MockObject
*/
private $attributeGroupRepositoryMock;
/**
- * @var AttributeGroupSearchResultsInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeGroupSearchResultsInterface|MockObject
*/
private $attributeGroupSearchResultsMock;
/**
- * @var AttributeGroupInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeGroupInterfaceFactory|MockObject
*/
private $attributeGroupInterfaceFactoryMock;
/**
- * @var AttributeGroupInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeGroupInterface|MockObject
*/
private $attributeGroupInterfaceMock;
/**
- * @var Json|\PHPUnit_Framework_MockObject_MockObject
+ * @var Json|MockObject
*/
private $jsonMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
$this->contextMock = $this->getMockBuilder(Context::class)
@@ -115,7 +119,7 @@ protected function setUp()
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
+ $this->requestMock = $this->getMockBuilder(RequestInterface::class)
->setMethods(['getParam', 'setParam'])
->getMockForAbstractClass();
$this->contextMock->expects($this->once())
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/EditTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/EditTest.php
index 858860337c5c1..59ec96c223fc5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/EditTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/EditTest.php
@@ -3,143 +3,161 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Attribute;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Block\Template;
+use Magento\Backend\Model\Session;
+use Magento\Backend\Model\View\Result\Page;
+use Magento\Catalog\Controller\Adminhtml\Product\Attribute\Edit;
+use Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Page\Config;
+use Magento\Framework\View\Page\Title;
+use Magento\Framework\View\Result\Layout;
+use Magento\Framework\View\Result\PageFactory;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class EditTest extends \PHPUnit\Framework\TestCase
+class EditTest extends TestCase
{
/**
- * @var \Magento\Catalog\Controller\Adminhtml\Product\Attribute\Edit
+ * @var Edit
*/
protected $editController;
/**
- * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $request;
/**
- * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
protected $objectManagerMock;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var Attribute|MockObject
*/
protected $eavAttribute;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registry;
/**
- * @var \Magento\Backend\Model\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject
+ * @var Page|MockObject
*/
protected $resultPage;
/**
- * @var \Magento\Framework\View\Result\Layout|\PHPUnit_Framework_MockObject_MockObject
+ * @var Layout|MockObject
*/
protected $resultLayout;
/**
- * @var \Magento\Framework\View\Page\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
protected $pageConfig;
/**
- * @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\View\Layout|MockObject
*/
protected $layout;
/**
- * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject
+ * @var Session|MockObject
*/
protected $session;
/**
- * @var \Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation|\PHPUnit_Framework_MockObject_MockObject
+ * @var Presentation|MockObject
*/
protected $presentation;
/**
- * @var \Magento\Framework\View\Page\Title|\PHPUnit_Framework_MockObject_MockObject
+ * @var Title|MockObject
*/
protected $pageTitle;
/**
- * @var \Magento\Backend\Block\Template|\PHPUnit_Framework_MockObject_MockObject
+ * @var Template|MockObject
*/
protected $blockTemplate;
/**
- * @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $context;
/**
- * @var \Magento\Framework\View\Result\PageFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var PageFactory|MockObject
*/
protected $resultPageFactory;
- protected function setUp()
+ protected function setUp(): void
{
- $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)->getMock();
+ $this->request = $this->getMockBuilder(RequestInterface::class)->getMock();
- $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)->getMock();
+ $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)->getMock();
$this->eavAttribute = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class,
+ Attribute::class,
['setEntityTypeId', 'load', 'getId', 'getEntityTypeId', 'addData', 'getName']
);
- $this->registry = $this->createMock(\Magento\Framework\Registry::class);
+ $this->registry = $this->createMock(Registry::class);
- $this->resultPage = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class)
+ $this->resultPage = $this->getMockBuilder(Page::class)
->disableOriginalConstructor()
->setMethods(['setActiveMenu', 'getConfig', 'addBreadcrumb', 'addHandle', 'getLayout'])
->getMock();
- $this->resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class)
+ $this->resultPageFactory = $this->getMockBuilder(PageFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->resultLayout = $this->getMockBuilder(\Magento\Framework\View\Result\Layout::class)
+ $this->resultLayout = $this->getMockBuilder(Layout::class)
->disableOriginalConstructor()
->getMock();
- $this->pageConfig = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class)
+ $this->pageConfig = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
- $this->pageTitle = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class)
+ $this->pageTitle = $this->getMockBuilder(Title::class)
->disableOriginalConstructor()
->getMock();
$this->layout = $this->createPartialMock(\Magento\Framework\View\Layout::class, ['getBlock']);
- $this->session = $this->getMockBuilder(\Magento\Backend\Model\Session::class)
+ $this->session = $this->getMockBuilder(Session::class)
->disableOriginalConstructor()
->getMock();
$this->presentation = $this->getMockBuilder(
- \Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation::class
+ Presentation::class
)->disableOriginalConstructor()
->getMock();
- $this->blockTemplate = $this->getMockBuilder(\Magento\Backend\Block\Template::class)
+ $this->blockTemplate = $this->getMockBuilder(Template::class)
->setMethods(['setIsPopup'])
->disableOriginalConstructor()
->getMock();
$this->context = $this->createPartialMock(
- \Magento\Backend\App\Action\Context::class,
+ Context::class,
['getRequest', 'getObjectManager', 'getResultPageFactory', 'getSession']
);
$this->context->expects($this->any())->method('getRequest')->willReturn($this->request);
@@ -149,7 +167,7 @@ protected function setUp()
$objectManager = new ObjectManager($this);
$this->editController = $objectManager->getObject(
- \Magento\Catalog\Controller\Adminhtml\Product\Attribute\Edit::class,
+ Edit::class,
[
'context' => $this->context,
'resultPageFactory' => $this->resultPageFactory
@@ -171,12 +189,12 @@ public function testExecutePopup()
);
$this->objectManagerMock->expects($this->any())->method('create')
- ->with(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
+ ->with(Attribute::class)
->willReturn($this->eavAttribute);
$this->objectManagerMock->expects($this->any())->method('get')
->willReturnMap([
- [\Magento\Backend\Model\Session::class, $this->session],
- [\Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation::class, $this->presentation]
+ [Session::class, $this->session],
+ [Presentation::class, $this->presentation]
]);
$this->eavAttribute->expects($this->once())->method('setEntityTypeId')->willReturnSelf();
$this->eavAttribute->expects($this->once())->method('addData')->with($attributesData)->willReturnSelf();
@@ -222,12 +240,12 @@ public function testExecuteNoPopup()
);
$this->objectManagerMock->expects($this->any())->method('create')
- ->with(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
+ ->with(Attribute::class)
->willReturn($this->eavAttribute);
$this->objectManagerMock->expects($this->any())->method('get')
->willReturnMap([
- [\Magento\Backend\Model\Session::class, $this->session],
- [\Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation::class, $this->presentation]
+ [Session::class, $this->session],
+ [Presentation::class, $this->presentation]
]);
$this->eavAttribute->expects($this->once())->method('setEntityTypeId')->willReturnSelf();
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/SaveTest.php
index 30d3503e4640e..4a1ffd694d1af 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/SaveTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/SaveTest.php
@@ -3,27 +3,31 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Attribute;
+use Magento\Backend\Model\View\Result\Redirect as ResultRedirect;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save;
-use Magento\Eav\Model\Validator\Attribute\Code as AttributeCodeValidator;
-use Magento\Framework\Serialize\Serializer\FormData;
-use Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\AttributeTest;
-use Magento\Catalog\Model\Product\AttributeSet\BuildFactory;
+use Magento\Catalog\Helper\Product as ProductHelper;
use Magento\Catalog\Model\Product\AttributeSet\Build;
+use Magento\Catalog\Model\Product\AttributeSet\BuildFactory;
use Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory;
+use Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\AttributeTest;
use Magento\Eav\Api\Data\AttributeSetInterface;
+use Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\Validator as InputTypeValidator;
use Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory;
+use Magento\Eav\Model\Validator\Attribute\Code as AttributeCodeValidator;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\Filter\FilterManager;
-use Magento\Catalog\Helper\Product as ProductHelper;
+use Magento\Framework\Serialize\Serializer\FormData;
use Magento\Framework\View\Element\Messages;
use Magento\Framework\View\LayoutFactory;
-use Magento\Backend\Model\View\Result\Redirect as ResultRedirect;
-use Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\Validator as InputTypeValidator;
use Magento\Framework\View\LayoutInterface;
+use PHPUnit\Framework\MockObject\MockObject;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -31,76 +35,76 @@
class SaveTest extends AttributeTest
{
/**
- * @var BuildFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var BuildFactory|MockObject
*/
protected $buildFactoryMock;
/**
- * @var FilterManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var FilterManager|MockObject
*/
protected $filterManagerMock;
/**
- * @var ProductHelper|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductHelper|MockObject
*/
protected $productHelperMock;
/**
- * @var AttributeFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeFactory|MockObject
*/
protected $attributeFactoryMock;
/**
- * @var ValidatorFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ValidatorFactory|MockObject
*/
protected $validatorFactoryMock;
/**
- * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
protected $groupCollectionFactoryMock;
/**
- * @var LayoutFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutFactory|MockObject
*/
protected $layoutFactoryMock;
/**
- * @var ResultRedirect|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResultRedirect|MockObject
*/
protected $redirectMock;
/**
- * @var AttributeSet|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeSet|MockObject
*/
protected $attributeSetMock;
/**
- * @var Build|\PHPUnit_Framework_MockObject_MockObject
+ * @var Build|MockObject
*/
protected $builderMock;
/**
- * @var InputTypeValidator|\PHPUnit_Framework_MockObject_MockObject
+ * @var InputTypeValidator|MockObject
*/
protected $inputTypeValidatorMock;
/**
- * @var FormData|\PHPUnit_Framework_MockObject_MockObject
+ * @var FormData|MockObject
*/
private $formDataSerializerMock;
/**
- * @var ProductAttributeInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductAttributeInterface|MockObject
*/
private $productAttributeMock;
/**
- * @var AttributeCodeValidator|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeCodeValidator|MockObject
*/
private $attributeCodeValidatorMock;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->buildFactoryMock = $this->getMockBuilder(BuildFactory::class)
@@ -273,7 +277,7 @@ public function testExecute()
}
/**
- * @throws \Magento\Framework\Exception\NotFoundException
+ * @throws NotFoundException
*/
public function testExecuteWithOptionsDataError()
{
@@ -305,7 +309,6 @@ public function testExecuteWithOptionsDataError()
* @param string $path
* @param array $params
* @param array $response
- * @return mixed
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
private function addReturnResultConditions(string $path = '', array $params = [], array $response = [])
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php
index 856f8a20b9daf..f8b9a1217824a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php
@@ -3,20 +3,24 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Attribute;
use Magento\Catalog\Controller\Adminhtml\Product\Attribute\Validate;
-use Magento\Eav\Model\Validator\Attribute\Code as AttributeCodeValidator;
-use Magento\Framework\Serialize\Serializer\FormData;
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\AttributeTest;
use Magento\Eav\Model\Entity\Attribute\Set as AttributeSet;
+use Magento\Eav\Model\Validator\Attribute\Code as AttributeCodeValidator;
use Magento\Framework\Controller\Result\Json as ResultJson;
use Magento\Framework\Controller\Result\JsonFactory as ResultJsonFactory;
use Magento\Framework\Escaper;
+use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\Serialize\Serializer\FormData;
use Magento\Framework\View\LayoutFactory;
use Magento\Framework\View\LayoutInterface;
+use PHPUnit\Framework\MockObject\MockObject;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -24,56 +28,56 @@
class ValidateTest extends AttributeTest
{
/**
- * @var ResultJsonFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResultJsonFactory|MockObject
*/
protected $resultJsonFactoryMock;
/**
- * @var ResultJson|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResultJson|MockObject
*/
protected $resultJson;
/**
- * @var LayoutFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutFactory|MockObject
*/
protected $layoutFactoryMock;
/**
- * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
protected $objectManagerMock;
/**
- * @var Attribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var Attribute|MockObject
*/
protected $attributeMock;
/**
- * @var AttributeSet|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeSet|MockObject
*/
protected $attributeSetMock;
/**
- * @var Escaper|\PHPUnit_Framework_MockObject_MockObject
+ * @var Escaper|MockObject
*/
protected $escaperMock;
/**
- * @var LayoutInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutInterface|MockObject
*/
protected $layoutMock;
/**
- * @var FormData|\PHPUnit_Framework_MockObject_MockObject
+ * @var FormData|MockObject
*/
private $formDataSerializerMock;
/**
- * @var AttributeCodeValidator|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeCodeValidator|MockObject
*/
private $attributeCodeValidatorMock;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->resultJsonFactoryMock = $this->getMockBuilder(ResultJsonFactory::class)
@@ -148,7 +152,7 @@ public function testExecute()
->method('create')
->willReturnMap(
[
- [\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], $this->attributeMock],
+ [Attribute::class, [], $this->attributeMock],
[\Magento\Eav\Model\Entity\Attribute\Set::class, [], $this->attributeSetMock]
]
);
@@ -188,7 +192,7 @@ public function testExecute()
* @dataProvider provideUniqueData
* @param array $options
* @param boolean $isError
- * @throws \Magento\Framework\Exception\NotFoundException
+ * @throws NotFoundException
*/
public function testUniqueValidation(array $options, $isError)
{
@@ -330,7 +334,7 @@ public function provideUniqueData()
*
* @dataProvider provideEmptyOption
* @param array $options
- * @throws \Magento\Framework\Exception\NotFoundException
+ * @throws NotFoundException
*/
public function testEmptyOption(array $options, $result)
{
@@ -453,7 +457,7 @@ public function provideEmptyOption()
* @dataProvider provideWhitespaceOption
* @param array $options
* @param $result
- * @throws \Magento\Framework\Exception\NotFoundException
+ * @throws NotFoundException
*/
public function testWhitespaceOption(array $options, $result)
{
@@ -571,7 +575,7 @@ public function provideWhitespaceOption()
}
/**
- * @throws \Magento\Framework\Exception\NotFoundException
+ * @throws NotFoundException
*/
public function testExecuteWithOptionsDataError()
{
@@ -600,7 +604,7 @@ public function testExecuteWithOptionsDataError()
->method('create')
->willReturnMap(
[
- [\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], $this->attributeMock],
+ [Attribute::class, [], $this->attributeMock],
[\Magento\Eav\Model\Entity\Attribute\Set::class, [], $this->attributeSetMock]
]
);
@@ -639,7 +643,7 @@ public function testExecuteWithOptionsDataError()
* @dataProvider provideInvalidAttributeCodes
* @param string $attributeCode
* @param $result
- * @throws \Magento\Framework\Exception\NotFoundException
+ * @throws NotFoundException
*/
public function testExecuteWithInvalidAttributeCode($attributeCode, $result)
{
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/AttributeTest.php
index 2a75773754fca..2ef7e1d189567 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/AttributeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/AttributeTest.php
@@ -3,23 +3,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product;
use Magento\Backend\App\Action\Context;
use Magento\Catalog\Controller\Adminhtml\Product\Attribute;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Cache\FrontendInterface;
+use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Message\ManagerInterface;
-use Magento\Framework\ObjectManager\ObjectManager;
use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Framework\View\Result\PageFactory;
-use Magento\Framework\Controller\ResultFactory;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class AttributeTest
- */
-class AttributeTest extends \PHPUnit\Framework\TestCase
+class AttributeTest extends TestCase
{
/**
* @var ObjectManagerHelper
@@ -27,41 +27,41 @@ class AttributeTest extends \PHPUnit\Framework\TestCase
protected $objectManager;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $contextMock;
/**
- * @var Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $coreRegistryMock;
/**
- * @var FrontendInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var FrontendInterface|MockObject
*/
protected $attributeLabelCacheMock;
/**
- * @var PageFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var PageFactory|MockObject
*/
protected $resultPageFactoryMock;
/**
- * @var RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $requestMock;
/**
- * @var ResultFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResultFactory|MockObject
*/
protected $resultFactoryMock;
/**
- * @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
protected $messageManager;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManagerHelper($this);
$this->contextMock = $this->getMockBuilder(Context::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php
index c71fa90fb02dd..0afc0fb7af0a0 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php
@@ -3,27 +3,30 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product;
-use \Magento\Catalog\Controller\Adminhtml\Product\Builder;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Store\Api\Data\StoreInterface;
-use Magento\Store\Model\StoreFactory;
-use Psr\Log\LoggerInterface;
+use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Controller\Adminhtml\Product\Builder;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Type as ProductTypes;
use Magento\Catalog\Model\ProductFactory;
-use Magento\Framework\Registry;
use Magento\Cms\Model\Wysiwyg\Config as WysiwygConfig;
use Magento\Framework\App\Request\Http;
-use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\Exception\NoSuchEntityException;
-use Magento\Catalog\Model\Product\Type as ProductTypes;
+use Magento\Framework\Registry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Model\StoreFactory;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
/**
- * Class BuilderTest
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class BuilderTest extends \PHPUnit\Framework\TestCase
+class BuilderTest extends TestCase
{
/**
* @var ObjectManager
@@ -36,51 +39,51 @@ class BuilderTest extends \PHPUnit\Framework\TestCase
protected $builder;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $loggerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $registryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $wysiwygConfigMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $requestMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productMock;
/**
- * @var StoreFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreFactory|MockObject
*/
protected $storeFactoryMock;
/**
- * @var ProductRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductRepositoryInterface|MockObject
*/
protected $productRepositoryMock;
/**
- * @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreInterface|MockObject
*/
protected $storeMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
$this->loggerMock = $this->createMock(LoggerInterface::class);
@@ -89,7 +92,7 @@ protected function setUp()
$this->wysiwygConfigMock = $this->createPartialMock(WysiwygConfig::class, ['setStoreId']);
$this->requestMock = $this->createMock(Http::class);
$methods = ['setStoreId', 'setData', 'load', '__wakeup', 'setAttributeSetId', 'setTypeId'];
- $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $methods);
+ $this->productMock = $this->createPartialMock(Product::class, $methods);
$this->storeFactoryMock = $this->getMockBuilder(StoreFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/AttributeFilterTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/AttributeFilterTest.php
index 424427b871456..2560b56a04e84 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/AttributeFilterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/AttributeFilterTest.php
@@ -3,15 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Initialization\Helper;
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeFilter;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class AttributeFilterTest extends \PHPUnit\Framework\TestCase
+class AttributeFilterTest extends TestCase
{
/**
* @var AttributeFilter
@@ -28,9 +31,9 @@ class AttributeFilterTest extends \PHPUnit\Framework\TestCase
*/
protected $productMock;
- protected function setUp()
+ protected function setUp(): void
{
- $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectHelper = new ObjectManager($this);
$this->model = $objectHelper->getObject(AttributeFilter::class);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php
index 53d2770f19cc8..4296c42a5de54 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php
@@ -3,11 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Initialization\Helper;
-use \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerFactory;
+use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerFactory;
+use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface;
+use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Handler\Composite;
+use Magento\Framework\DataObject;
+use Magento\Framework\ObjectManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class HandlerFactoryTest extends \PHPUnit\Framework\TestCase
+class HandlerFactoryTest extends TestCase
{
/**
* @var HandlerFactory
@@ -15,23 +23,23 @@ class HandlerFactoryTest extends \PHPUnit\Framework\TestCase
protected $_model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_objectManagerMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
+ $this->_objectManagerMock = $this->createMock(ObjectManagerInterface::class);
$this->_model = new HandlerFactory($this->_objectManagerMock);
}
public function testCreateWithInvalidType()
{
$this->expectException('\InvalidArgumentException');
- $this->expectExceptionMessage(\Magento\Framework\DataObject::class . ' does not implement ' .
- \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface::class);
+ $this->expectExceptionMessage(DataObject::class . ' does not implement ' .
+ HandlerInterface::class);
$this->_objectManagerMock->expects($this->never())->method('create');
- $this->_model->create(\Magento\Framework\DataObject::class);
+ $this->_model->create(DataObject::class);
}
public function testCreateWithValidType()
@@ -41,14 +49,14 @@ public function testCreateWithValidType()
)->method(
'create'
)->with(
- \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Handler\Composite::class
+ Composite::class
)->will(
$this->returnValue('object')
);
$this->assertEquals(
'object',
$this->_model->create(
- \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Handler\Composite::class
+ Composite::class
)
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Handler/CompositeTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Handler/CompositeTest.php
index b3ad1e0302722..b662bf298b2c3 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Handler/CompositeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Handler/CompositeTest.php
@@ -3,20 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Handler;
+use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerFactory;
+use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface;
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Handler\Composite;
+use Magento\Catalog\Model\Product;
+use PHPUnit\Framework\TestCase;
-class CompositeTest extends \PHPUnit\Framework\TestCase
+class CompositeTest extends TestCase
{
public function testHandle()
{
$factoryMock = $this->createMock(
- \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerFactory::class
+ HandlerFactory::class
);
$constructorMock = $this->createMock(
- \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface::class
+ HandlerInterface::class
);
$factoryMock->expects(
@@ -29,7 +35,7 @@ public function testHandle()
$this->returnValue($constructorMock)
);
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $productMock = $this->createMock(Product::class);
$constructorMock->expects($this->exactly(2))->method('handle')->with($productMock);
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php
index 2aea34244437d..c7a61ae70c15c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php
@@ -3,27 +3,34 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Initialization;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory;
+use Magento\Catalog\Api\Data\ProductLinkInterfaceFactory;
+use Magento\Catalog\Api\Data\ProductLinkTypeInterface;
use Magento\Catalog\Api\ProductRepositoryInterface as ProductRepository;
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper;
+use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeFilter;
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Filter\DateTime;
+use Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks;
+use Magento\Catalog\Model\Product\Link\Resolver;
+use Magento\Catalog\Model\Product\LinkTypeProvider;
use Magento\Catalog\Model\Product\Option;
+use Magento\Catalog\Model\ProductLink\Link as ProductLink;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Eav\Model\Entity\Attribute\Backend\DefaultBackend;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Locale\Format;
use Magento\Framework\Locale\FormatInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Store\Api\Data\WebsiteInterface;
use Magento\Store\Model\StoreManagerInterface;
-use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory;
-use Magento\Catalog\Api\Data\ProductLinkInterfaceFactory;
-use Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks;
-use Magento\Catalog\Model\Product\LinkTypeProvider;
-use Magento\Catalog\Api\Data\ProductLinkTypeInterface;
-use Magento\Catalog\Model\ProductLink\Link as ProductLink;
-use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeFilter;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -31,7 +38,7 @@
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.TooManyFields)
*/
-class HelperTest extends \PHPUnit\Framework\TestCase
+class HelperTest extends TestCase
{
/**
* @var ObjectManager
@@ -44,74 +51,74 @@ class HelperTest extends \PHPUnit\Framework\TestCase
protected $helper;
/**
- * @var ProductLinkInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductLinkInterfaceFactory|MockObject
*/
protected $productLinkFactoryMock;
/**
- * @var RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $requestMock;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManagerMock;
/**
- * @var StockDataFilter|\PHPUnit_Framework_MockObject_MockObject
+ * @var StockDataFilter|MockObject
*/
protected $stockFilterMock;
/**
- * @var Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
protected $productMock;
/**
- * @var ProductRepository|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductRepository|MockObject
*/
protected $productRepositoryMock;
/**
- * @var ProductCustomOptionInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductCustomOptionInterfaceFactory|MockObject
*/
protected $customOptionFactoryMock;
/**
- * @var \Magento\Catalog\Model\Product\Link\Resolver|\PHPUnit_Framework_MockObject_MockObject
+ * @var Resolver|MockObject
*/
protected $linkResolverMock;
/**
- * @var \Magento\Catalog\Model\Product\LinkTypeProvider|\PHPUnit_Framework_MockObject_MockObject
+ * @var LinkTypeProvider|MockObject
*/
protected $linkTypeProviderMock;
/**
- * @var ProductLinks|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductLinks|MockObject
*/
protected $productLinksMock;
/**
- * @var AttributeFilter|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeFilter|MockObject
*/
protected $attributeFilterMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $dateTimeFilterMock;
/**
- * @var FormatInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var FormatInterface|MockObject
*/
protected $localeFormatMock;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
$this->productLinkFactoryMock = $this->getMockBuilder(ProductLinkInterfaceFactory::class)
@@ -165,7 +172,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $this->dateTimeFilterMock = $this->createMock(\Magento\Catalog\Model\Product\Filter\DateTime::class);
+ $this->dateTimeFilterMock = $this->createMock(DateTime::class);
$this->helper = $this->objectManager->getObject(
Helper::class,
@@ -184,7 +191,7 @@ protected function setUp()
]
);
- $this->linkResolverMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Link\Resolver::class)
+ $this->linkResolverMock = $this->getMockBuilder(Resolver::class)
->disableOriginalConstructor()
->getMock();
$helperReflection = new \ReflectionClass(get_class($this->helper));
@@ -350,9 +357,9 @@ private function setProductAttributes(array $attributes): void
{
$attributesModels = [];
foreach ($attributes as $attribute) {
- $attributeModel = $this->createMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
+ $attributeModel = $this->createMock(Attribute::class);
$backendModel = $attribute['backend_model']
- ?? $this->createMock(\Magento\Eav\Model\Entity\Attribute\Backend\DefaultBackend::class);
+ ?? $this->createMock(DefaultBackend::class);
$attributeModel->expects($this->any())
->method('getBackend')
->willReturn($backendModel);
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/StockDataFilterTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/StockDataFilterTest.php
index 0214de8120bae..446ec744eddd7 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/StockDataFilterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/StockDataFilterTest.php
@@ -3,22 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Initialization;
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter;
+use Magento\CatalogInventory\Model\Configuration;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class StockDataFilterTest
- */
-class StockDataFilterTest extends \PHPUnit\Framework\TestCase
+class StockDataFilterTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $storeMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $scopeConfigMock;
@@ -27,17 +30,17 @@ class StockDataFilterTest extends \PHPUnit\Framework\TestCase
*/
protected $stockDataFilter;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
protected $stockConfiguration;
- protected function setUp()
+ protected function setUp(): void
{
- $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
$this->scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue(1));
$this->stockConfiguration = $this->createPartialMock(
- \Magento\CatalogInventory\Model\Configuration::class,
+ Configuration::class,
['getManageStock']
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php
index df96eff852d4e..2d04cb1ac9a08 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php
@@ -3,53 +3,61 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product;
-use Magento\Ui\Component\MassAction\Filter;
+use Magento\Backend\App\Action\Context;
use Magento\Backend\Model\View\Result\Redirect;
-use Magento\Catalog\Model\Indexer\Product\Price\Processor;
use Magento\Catalog\Controller\Adminhtml\Product\Builder;
-use Magento\Framework\Data\Collection\AbstractDb;
+use Magento\Catalog\Controller\Adminhtml\Product\MassStatus;
+use Magento\Catalog\Model\Indexer\Product\Price\Processor;
+use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Action;
+use Magento\Catalog\Model\Product\Attribute\Source\Status;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest;
+use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\Data\Collection\AbstractDb;
+use Magento\Ui\Component\MassAction\Filter;
+use PHPUnit\Framework\MockObject\MockObject;
/**
- * Class MassStatusTest
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class MassStatusTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest
+class MassStatusTest extends ProductTest
{
/**
- * @var Processor|\PHPUnit_Framework_MockObject_MockObject
+ * @var Processor|MockObject
*/
private $priceProcessorMock;
/**
- * @var Redirect|\PHPUnit_Framework_MockObject_MockObject
+ * @var Redirect|MockObject
*/
private $resultRedirectMock;
/**
- * @var Filter|\PHPUnit_Framework_MockObject_MockObject
+ * @var Filter|MockObject
*/
private $filterMock;
/**
- * @var Builder|\PHPUnit_Framework_MockObject_MockObject
+ * @var Builder|MockObject
*/
private $productBuilderMock;
/**
- * @var AbstractDb|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractDb|MockObject
*/
private $abstractDbMock;
/**
- * @var Action|\PHPUnit_Framework_MockObject_MockObject
+ * @var Action|MockObject
*/
private $actionMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->priceProcessorMock = $this->getMockBuilder(Processor::class)
->disableOriginalConstructor()->getMock();
@@ -58,7 +66,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->setMethods(['getTypeId', 'getStoreId', '__sleep', '__wakeup'])
->getMock();
@@ -72,23 +80,23 @@ protected function setUp()
->method('build')
->willReturn($productMock);
- $this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class)
+ $this->resultRedirectMock = $this->getMockBuilder(Redirect::class)
->disableOriginalConstructor()
->getMock();
- $resultFactory = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class)
+ $resultFactory = $this->getMockBuilder(ResultFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$resultFactory->expects($this->atLeastOnce())
->method('create')
- ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)
+ ->with(ResultFactory::TYPE_REDIRECT)
->willReturn($this->resultRedirectMock);
$this->abstractDbMock = $this->getMockBuilder(AbstractDb::class)
->disableOriginalConstructor()
->setMethods(['getAllIds', 'getResource'])
->getMock();
- $this->filterMock = $this->getMockBuilder(\Magento\Ui\Component\MassAction\Filter::class)
+ $this->filterMock = $this->getMockBuilder(Filter::class)
->disableOriginalConstructor()
->setMethods(['getCollection'])
->getMock();
@@ -97,7 +105,7 @@ protected function setUp()
->getMock();
$collectionFactoryMock =
- $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class)
+ $this->getMockBuilder(CollectionFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
@@ -108,10 +116,10 @@ protected function setUp()
$additionalParams = [
'resultFactory' => $resultFactory
];
- /** @var \Magento\Backend\App\Action\Context $context */
+ /** @var Context $context */
$context = $this->initContext($additionalParams);
- $this->action = new \Magento\Catalog\Controller\Adminhtml\Product\MassStatus(
+ $this->action = new MassStatus(
$context,
$this->productBuilderMock,
$this->priceProcessorMock,
@@ -124,7 +132,7 @@ protected function setUp()
public function testMassStatusAction()
{
$storeId = 2;
- $status = \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED;
+ $status = Status::STATUS_DISABLED;
$filters = [
'store_id' => 2,
];
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/NewActionTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/NewActionTest.php
index 888c8931bb206..8dd3adcf24fd4 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/NewActionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/NewActionTest.php
@@ -4,51 +4,61 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product;
+use Magento\Backend\Model\View\Result\Forward;
+use Magento\Backend\Model\View\Result\ForwardFactory;
+use Magento\Backend\Model\View\Result\Page;
+use Magento\Catalog\Controller\Adminhtml\Product\Builder;
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper;
use Magento\Catalog\Controller\Adminhtml\Product\NewAction;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Result\PageFactory;
+use PHPUnit\Framework\MockObject\MockObject;
-class NewActionTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest
+class NewActionTest extends ProductTest
{
/** @var NewAction */
protected $action;
- /** @var \Magento\Backend\Model\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Page|MockObject */
protected $resultPage;
- /** @var \Magento\Backend\Model\View\Result\Forward|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Forward|MockObject */
protected $resultForward;
- /** @var \Magento\Catalog\Controller\Adminhtml\Product\Builder|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Builder|MockObject */
protected $productBuilder;
- /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Product|MockObject */
protected $product;
/**
- * @var Helper|\PHPUnit_Framework_MockObject_MockObject
+ * @var Helper|MockObject
*/
protected $initializationHelper;
- protected function setUp()
+ protected function setUp(): void
{
$this->productBuilder = $this->createPartialMock(
- \Magento\Catalog\Controller\Adminhtml\Product\Builder::class,
+ Builder::class,
['build']
);
- $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()
+ $this->product = $this->getMockBuilder(Product::class)->disableOriginalConstructor()
->setMethods(['addData', 'getTypeId', 'getStoreId', '__sleep', '__wakeup'])->getMock();
$this->product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple'));
$this->product->expects($this->any())->method('getStoreId')->will($this->returnValue('1'));
$this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product));
- $this->resultPage = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class)
+ $this->resultPage = $this->getMockBuilder(Page::class)
->disableOriginalConstructor()
->getMock();
- $resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class)
+ $resultPageFactory = $this->getMockBuilder(PageFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
@@ -56,10 +66,10 @@ protected function setUp()
->method('create')
->willReturn($this->resultPage);
- $this->resultForward = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class)
+ $this->resultForward = $this->getMockBuilder(Forward::class)
->disableOriginalConstructor()
->getMock();
- $resultForwardFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\ForwardFactory::class)
+ $resultForwardFactory = $this->getMockBuilder(ForwardFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ReloadTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ReloadTest.php
index 16bda2c39ab85..6e64398230ce6 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ReloadTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ReloadTest.php
@@ -3,10 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product;
use Magento\Backend\App\Action\Context;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Controller\Adminhtml\Product\Builder;
use Magento\Catalog\Controller\Adminhtml\Product\Reload;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\ResultFactory;
@@ -14,15 +17,14 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\View\Layout\ProcessorInterface;
use Magento\Framework\View\LayoutInterface;
-use Magento\Catalog\Controller\Adminhtml\Product\Builder;
use Magento\Ui\Component\Wrapper\UiComponent;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class ReloadTest
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ReloadTest extends \PHPUnit\Framework\TestCase
+class ReloadTest extends TestCase
{
/**
* @var Reload
@@ -35,51 +37,51 @@ class ReloadTest extends \PHPUnit\Framework\TestCase
protected $objectManager;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $contextMock;
/**
- * @var ResultFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResultFactory|MockObject
*/
protected $resultFactoryMock;
/**
- * @var LayoutInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutInterface|MockObject
*/
protected $layoutMock;
/**
- * @var RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $requestMock;
/**
- * @var Builder|\PHPUnit_Framework_MockObject_MockObject
+ * @var Builder|MockObject
*/
protected $productBuilderMock;
/**
- * @var ResultInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResultInterface|MockObject
*/
protected $resultMock;
/**
- * @var ProductInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductInterface|MockObject
*/
protected $productMock;
/**
- * @var UiComponent|\PHPUnit_Framework_MockObject_MockObject
+ * @var UiComponent|MockObject
*/
protected $uiComponentMock;
/**
- * @var ProcessorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProcessorInterface|MockObject
*/
protected $processorMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php
index a10814371577e..af6ccf8749077 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php
@@ -3,76 +3,92 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product;
+use Magento\Backend\Model\View\Result\Forward;
+use Magento\Backend\Model\View\Result\ForwardFactory;
+use Magento\Backend\Model\View\Result\Page;
+use Magento\Backend\Model\View\Result\Redirect;
+use Magento\Backend\Model\View\Result\RedirectFactory;
+use Magento\Catalog\Controller\Adminhtml\Product\Builder;
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper;
+use Magento\Catalog\Controller\Adminhtml\Product\Save;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\View\Result\PageFactory;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class SaveTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest
+class SaveTest extends ProductTest
{
- /** @var \Magento\Catalog\Controller\Adminhtml\Product\Save */
+ /** @var Save */
protected $action;
- /** @var \Magento\Backend\Model\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Page|MockObject */
private $resultPage;
- /** @var \Magento\Backend\Model\View\Result\Forward|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Forward|MockObject */
private $resultForward;
- /** @var \Magento\Catalog\Controller\Adminhtml\Product\Builder|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Builder|MockObject */
private $productBuilder;
- /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Product|MockObject */
private $product;
- /** @var \Magento\Backend\Model\View\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var RedirectFactory|MockObject */
private $resultRedirectFactory;
- /** @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Redirect|MockObject */
private $resultRedirect;
- /** @var Helper|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Helper|MockObject */
private $initializationHelper;
- /** @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ManagerInterface|MockObject */
private $messageManagerMock;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->productBuilder = $this->createPartialMock(
- \Magento\Catalog\Controller\Adminhtml\Product\Builder::class,
+ Builder::class,
['build']
);
- $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()
+ $this->product = $this->getMockBuilder(Product::class)->disableOriginalConstructor()
->setMethods(['addData', 'getSku', 'getTypeId', 'getStoreId', '__sleep', '__wakeup'])->getMock();
$this->product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple'));
$this->product->expects($this->any())->method('getStoreId')->will($this->returnValue('1'));
$this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product));
$this->messageManagerMock = $this->getMockForAbstractClass(
- \Magento\Framework\Message\ManagerInterface::class
+ ManagerInterface::class
);
- $this->resultPage = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class)
+ $this->resultPage = $this->getMockBuilder(Page::class)
->disableOriginalConstructor()
->getMock();
- $resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class)
+ $resultPageFactory = $this->getMockBuilder(PageFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$resultPageFactory->expects($this->any())->method('create')->willReturn($this->resultPage);
- $this->resultForward = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class)
+ $this->resultForward = $this->getMockBuilder(Forward::class)
->disableOriginalConstructor()
->getMock();
- $resultForwardFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\ForwardFactory::class)
+ $resultForwardFactory = $this->getMockBuilder(ForwardFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
@@ -81,20 +97,20 @@ protected function setUp()
->willReturn($this->resultForward);
$this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->layout);
$this->resultRedirectFactory = $this->createPartialMock(
- \Magento\Backend\Model\View\Result\RedirectFactory::class,
+ RedirectFactory::class,
['create']
);
- $this->resultRedirect = $this->createMock(\Magento\Backend\Model\View\Result\Redirect::class);
+ $this->resultRedirect = $this->createMock(Redirect::class);
$this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
$this->initializationHelper = $this->createMock(
- \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::class
+ Helper::class
);
$additionalParams = ['resultRedirectFactory' => $this->resultRedirectFactory];
$storeManagerInterfaceMock = $this->getMockForAbstractClass(
- \Magento\Store\Model\StoreManagerInterface::class,
+ StoreManagerInterface::class,
[],
'',
false,
@@ -108,7 +124,7 @@ protected function setUp()
->will($this->returnSelf());
$this->action = (new ObjectManagerHelper($this))->getObject(
- \Magento\Catalog\Controller\Adminhtml\Product\Save::class,
+ Save::class,
[
'context' => $this->initContext($additionalParams),
'resultRedirectFactory' => $this->resultRedirectFactory,
@@ -123,19 +139,19 @@ protected function setUp()
}
/**
- * @param string $exceptionType
+ * @param \Exception $exception
* @param string $methodExpected
* @return void
* @dataProvider exceptionTypeDataProvider
*/
- public function testExecuteSetsProductDataToSessionAndRedirectsToNewActionOnError($exceptionType, $methodExpected)
+ public function testExecuteSetsProductDataToSessionAndRedirectsToNewActionOnError($exception, $methodExpected)
{
$productData = ['product' => ['name' => 'test-name']];
$this->request->expects($this->any())->method('getPostValue')->willReturn($productData);
$this->initializationHelper->expects($this->any())->method('initialize')
->willReturn($this->product);
- $this->product->expects($this->any())->method('getSku')->willThrowException(new $exceptionType(__('message')));
+ $this->product->expects($this->any())->method('getSku')->willThrowException($exception);
$this->resultRedirect->expects($this->once())->method('setPath')->with('catalog/*/new');
@@ -151,8 +167,8 @@ public function testExecuteSetsProductDataToSessionAndRedirectsToNewActionOnErro
public function exceptionTypeDataProvider()
{
return [
- [\Magento\Framework\Exception\LocalizedException::class, 'addExceptionMessage'],
- ['Exception', 'addErrorMessage']
+ [new LocalizedException(__('Message')), 'addExceptionMessage'],
+ [new \Exception('Message'), 'addErrorMessage']
];
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php
index 47a60a1916142..1d57630a58dd2 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php
@@ -3,36 +3,54 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Helper\Data;
+use Magento\Backend\Model\Session;
+use Magento\Catalog\Controller\Adminhtml\Product\Builder;
use Magento\Catalog\Controller\Adminhtml\Product\ShowUpdateResult;
+use Magento\Catalog\Helper\Product\Composite;
+use Magento\Catalog\Model\Product\Action;
+use Magento\Framework\App\ActionFlag;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\App\ResponseInterface;
+use Magento\Framework\DataObject;
+use Magento\Framework\Event\Manager;
+use Magento\Framework\Message\ManagerInterface;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\View\Layout;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ShowUpdateResultTest extends \PHPUnit\Framework\TestCase
+class ShowUpdateResultTest extends TestCase
{
- /** @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Context|MockObject */
protected $context;
- /** @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Layout|MockObject */
protected $layout;
- /** @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Session|MockObject */
protected $session;
- /** @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Http|MockObject */
protected $request;
/**
* Init session object
*
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
protected function getSession()
{
$session = $this->createPartialMock(
- \Magento\Backend\Model\Session::class,
+ Session::class,
['hasCompositeProductResult', 'getCompositeProductResult', 'unsCompositeProductResult']
);
$session->expects($this->once())
@@ -42,7 +60,7 @@ protected function getSession()
->method('unsCompositeProductResult');
$session->expects($this->atLeastOnce())
->method('getCompositeProductResult')
- ->willReturn(new \Magento\Framework\DataObject());
+ ->willReturn(new DataObject());
return $session;
}
@@ -50,17 +68,17 @@ protected function getSession()
/**
* Init context object
*
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
protected function getContext()
{
- $productActionMock = $this->createMock(\Magento\Catalog\Model\Product\Action::class);
- $objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class);
+ $productActionMock = $this->createMock(Action::class);
+ $objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
$objectManagerMock->expects($this->any())
->method('get')
->willReturn($productActionMock);
- $eventManager = $this->getMockBuilder(\Magento\Framework\Event\Manager::class)
+ $eventManager = $this->getMockBuilder(Manager::class)
->setMethods(['dispatch'])
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -70,20 +88,20 @@ protected function getContext()
->willReturnSelf();
$this->request = $this->createPartialMock(
- \Magento\Framework\App\Request\Http::class,
+ Http::class,
['getParam', 'getPost', 'getFullActionName', 'getPostValue']
);
$responseInterfaceMock = $this->createPartialMock(
- \Magento\Framework\App\ResponseInterface::class,
+ ResponseInterface::class,
['setRedirect', 'sendResponse']
);
- $managerInterfaceMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class);
+ $managerInterfaceMock = $this->createMock(ManagerInterface::class);
$this->session = $this->getSession();
- $actionFlagMock = $this->createMock(\Magento\Framework\App\ActionFlag::class);
- $helperDataMock = $this->createMock(\Magento\Backend\Helper\Data::class);
- $this->context = $this->createPartialMock(\Magento\Backend\App\Action\Context::class, [
+ $actionFlagMock = $this->createMock(ActionFlag::class);
+ $helperDataMock = $this->createMock(Data::class);
+ $this->context = $this->createPartialMock(Context::class, [
'getRequest',
'getResponse',
'getObjectManager',
@@ -128,14 +146,14 @@ protected function getContext()
public function testExecute()
{
- $productCompositeHelper = $this->createMock(\Magento\Catalog\Helper\Product\Composite::class);
+ $productCompositeHelper = $this->createMock(Composite::class);
$productCompositeHelper->expects($this->once())
->method('renderUpdateResult');
- $productBuilder = $this->createMock(\Magento\Catalog\Controller\Adminhtml\Product\Builder::class);
+ $productBuilder = $this->createMock(Builder::class);
$context = $this->getContext();
- /** @var \Magento\Catalog\Controller\Adminhtml\Product\ShowUpdateResult $controller */
+ /** @var ShowUpdateResult $controller */
$controller = new ShowUpdateResult($context, $productBuilder, $productCompositeHelper);
$controller->execute();
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php
index fc67a8ea815ee..43f33a02737be 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php
@@ -3,60 +3,77 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product;
+use Magento\Backend\Model\View\Result\Forward;
+use Magento\Backend\Model\View\Result\ForwardFactory;
+use Magento\Backend\Model\View\Result\Page;
+use Magento\Backend\Model\View\Result\Redirect;
+use Magento\Backend\Model\View\Result\RedirectFactory;
+use Magento\Catalog\Controller\Adminhtml\Product\Builder;
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper;
+use Magento\Catalog\Controller\Adminhtml\Product\Validate;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ProductFactory;
+use Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest;
+use Magento\Framework\Controller\Result\Json;
+use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\View\Result\PageFactory;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ValidateTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest
+class ValidateTest extends ProductTest
{
- /** @var \Magento\Catalog\Controller\Adminhtml\Product\Validate */
+ /** @var Validate */
protected $action;
- /** @var \Magento\Backend\Model\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Page|MockObject */
protected $resultPage;
- /** @var \Magento\Backend\Model\View\Result\Forward|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Forward|MockObject */
protected $resultForward;
- /** @var \Magento\Catalog\Controller\Adminhtml\Product\Builder|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Builder|MockObject */
protected $productBuilder;
- /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Product|MockObject */
protected $product;
- /** @var \Magento\Backend\Model\View\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var RedirectFactory|MockObject */
protected $resultRedirectFactory;
- /** @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Redirect|MockObject */
protected $resultRedirect;
- /** @var Helper|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Helper|MockObject */
protected $initializationHelper;
- /** @var \Magento\Catalog\Model\ProductFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ProductFactory|MockObject */
protected $productFactory;
- /** @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Json|MockObject */
protected $resultJson;
- /** @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var JsonFactory|MockObject */
protected $resultJsonFactory;
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->productBuilder = $this->createPartialMock(
- \Magento\Catalog\Controller\Adminhtml\Product\Builder::class,
+ Builder::class,
['build']
);
- $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()
+ $this->product = $this->getMockBuilder(Product::class)->disableOriginalConstructor()
->setMethods([
'addData', 'getSku', 'getTypeId', 'getStoreId', '__sleep', '__wakeup', 'getAttributes',
'setAttributeSetId',
@@ -67,20 +84,20 @@ protected function setUp()
$this->product->expects($this->any())->method('getAttributes')->will($this->returnValue([]));
$this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product));
- $this->resultPage = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Page::class)
+ $this->resultPage = $this->getMockBuilder(Page::class)
->disableOriginalConstructor()
->getMock();
- $resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class)
+ $resultPageFactory = $this->getMockBuilder(PageFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$resultPageFactory->expects($this->any())->method('create')->willReturn($this->resultPage);
- $this->resultForward = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Forward::class)
+ $this->resultForward = $this->getMockBuilder(Forward::class)
->disableOriginalConstructor()
->getMock();
- $resultForwardFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\ForwardFactory::class)
+ $resultForwardFactory = $this->getMockBuilder(ForwardFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
@@ -89,31 +106,31 @@ protected function setUp()
->willReturn($this->resultForward);
$this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->layout);
$this->resultRedirectFactory = $this->createPartialMock(
- \Magento\Backend\Model\View\Result\RedirectFactory::class,
+ RedirectFactory::class,
['create']
);
- $this->resultRedirect = $this->createMock(\Magento\Backend\Model\View\Result\Redirect::class);
+ $this->resultRedirect = $this->createMock(Redirect::class);
$this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
$this->initializationHelper = $this->createMock(
- \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::class
+ Helper::class
);
- $this->productFactory = $this->getMockBuilder(\Magento\Catalog\Model\ProductFactory::class)
+ $this->productFactory = $this->getMockBuilder(ProductFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$this->productFactory->expects($this->any())->method('create')->willReturn($this->product);
- $this->resultJson = $this->createMock(\Magento\Framework\Controller\Result\Json::class);
- $this->resultJsonFactory = $this->getMockBuilder(\Magento\Framework\Controller\Result\JsonFactory::class)
+ $this->resultJson = $this->createMock(Json::class);
+ $this->resultJsonFactory = $this->getMockBuilder(JsonFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$this->resultJsonFactory->expects($this->any())->method('create')->willReturn($this->resultJson);
$storeManagerInterfaceMock = $this->getMockForAbstractClass(
- \Magento\Store\Model\StoreManagerInterface::class,
+ StoreManagerInterface::class,
[],
'',
false,
@@ -128,7 +145,7 @@ protected function setUp()
$additionalParams = ['resultRedirectFactory' => $this->resultRedirectFactory];
$this->action = (new ObjectManagerHelper($this))->getObject(
- \Magento\Catalog\Controller\Adminhtml\Product\Validate::class,
+ Validate::class,
[
'context' => $this->initContext($additionalParams),
'productBuilder' => $this->productBuilder,
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php
index 5d08f80847da2..835bca927f83b 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php
@@ -3,30 +3,48 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Helper\Data;
+use Magento\Backend\Model\Session;
+use Magento\Catalog\Controller\Product;
+use Magento\Catalog\Model\Product\Action;
+use Magento\Framework\App\ActionFlag;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\App\ResponseInterface;
+use Magento\Framework\Event\Manager;
+use Magento\Framework\Message\ManagerInterface;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\View\Element\AbstractBlock;
+use Magento\Framework\View\Layout;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-abstract class ProductTest extends \PHPUnit\Framework\TestCase
+abstract class ProductTest extends TestCase
{
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
protected $context;
- /** @var \Magento\Catalog\Controller\Product */
+ /** @var Product */
protected $action;
- /** @var \Magento\Framework\View\Layout */
+ /** @var Layout */
protected $layout;
- /** @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Session|MockObject */
protected $session;
- /** @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Http|MockObject */
protected $request;
/**
- * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
private $objectManagerMock;
@@ -35,13 +53,13 @@ abstract class ProductTest extends \PHPUnit\Framework\TestCase
*
* @param array $additionalParams
* @param array $objectManagerMap Object Manager mappings
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
protected function initContext(array $additionalParams = [], array $objectManagerMap = [])
{
- $productActionMock = $this->createMock(\Magento\Catalog\Model\Product\Action::class);
+ $productActionMock = $this->createMock(Action::class);
- $this->objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class);
+ $this->objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
if ($objectManagerMap) {
$this->objectManagerMock->expects($this->any())
@@ -53,35 +71,32 @@ protected function initContext(array $additionalParams = [], array $objectManage
->method('get')
->willReturn($productActionMock);
- $block = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class)
+ $block = $this->getMockBuilder(AbstractBlock::class)
->disableOriginalConstructor()->getMockForAbstractClass();
- $this->layout = $this->getMockBuilder(\Magento\Framework\View\Layout::class)
+ $this->layout = $this->getMockBuilder(Layout::class)
->setMethods(['getBlock'])->disableOriginalConstructor()
->getMock();
$this->layout->expects($this->any())->method('getBlock')->will($this->returnValue($block));
- $eventManager = $this->getMockBuilder(\Magento\Framework\Event\Manager::class)
+ $eventManager = $this->getMockBuilder(Manager::class)
->setMethods(['dispatch'])->disableOriginalConstructor()->getMock();
$eventManager->expects($this->any())->method('dispatch')->will($this->returnSelf());
- $title = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class)
- ->setMethods(['add', 'prepend'])->disableOriginalConstructor()->getMock();
- $title->expects($this->any())->method('prepend')->withAnyParameters()->will($this->returnSelf());
- $requestInterfaceMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)->setMethods(
+ $requestInterfaceMock = $this->getMockBuilder(Http::class)->setMethods(
['getParam', 'getPost', 'getFullActionName', 'getPostValue']
)->disableOriginalConstructor()->getMock();
- $responseInterfaceMock = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class)->setMethods(
+ $responseInterfaceMock = $this->getMockBuilder(ResponseInterface::class)->setMethods(
['setRedirect', 'sendResponse']
)->getMock();
- $managerInterfaceMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class);
+ $managerInterfaceMock = $this->createMock(ManagerInterface::class);
$sessionMock = $this->createPartialMock(
- \Magento\Backend\Model\Session::class,
+ Session::class,
['getProductData', 'setProductData']
);
- $actionFlagMock = $this->createMock(\Magento\Framework\App\ActionFlag::class);
- $helperDataMock = $this->createMock(\Magento\Backend\Helper\Data::class);
- $this->context = $this->createPartialMock(\Magento\Backend\App\Action\Context::class, [
+ $actionFlagMock = $this->createMock(ActionFlag::class);
+ $helperDataMock = $this->createMock(Data::class);
+ $this->context = $this->createPartialMock(Context::class, [
'getRequest',
'getResponse',
'getObjectManager',
@@ -96,7 +111,6 @@ protected function initContext(array $additionalParams = [], array $objectManage
'getResultFactory'
]);
- $this->context->expects($this->any())->method('getTitle')->will($this->returnValue($title));
$this->context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager));
$this->context->expects($this->any())->method('getRequest')->will($this->returnValue($requestInterfaceMock));
$this->context->expects($this->any())->method('getResponse')->will($this->returnValue($responseInterfaceMock));
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php
index 595f81cc4ecd3..588c11e47dc4a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php
@@ -3,128 +3,151 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Category;
+use Magento\Backend\App\Action\Context;
+use Magento\Catalog\Api\CategoryRepositoryInterface;
+use Magento\Catalog\Controller\Category\View;
+use Magento\Catalog\Helper\Category;
+use Magento\Catalog\Model\Design;
use Magento\Framework\App\Action\Action;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\App\ResponseInterface;
+use Magento\Framework\App\ViewInterface;
+use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\DataObject;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Layout;
+use Magento\Framework\View\Layout\ProcessorInterface;
+use Magento\Framework\View\Page\Config;
+use Magento\Framework\View\Result\Page;
+use Magento\Framework\View\Result\PageFactory;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyFields)
*/
-class ViewTest extends \PHPUnit\Framework\TestCase
+class ViewTest extends TestCase
{
/**
- * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $request;
/**
- * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResponseInterface|MockObject
*/
protected $response;
/**
- * @var \Magento\Catalog\Helper\Category|\PHPUnit_Framework_MockObject_MockObject
+ * @var Category|MockObject
*/
protected $categoryHelper;
/**
- * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
protected $objectManager;
/**
- * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
protected $eventManager;
/**
- * @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\View\Layout|MockObject
*/
protected $layout;
/**
- * @var \Magento\Framework\View\Layout\ProcessorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProcessorInterface|MockObject
*/
protected $update;
/**
- * @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ViewInterface|MockObject
*/
protected $view;
/**
- * @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $context;
/**
- * @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Model\Category|MockObject
*/
protected $category;
/**
- * @var \Magento\Catalog\Api\CategoryRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryRepositoryInterface|MockObject
*/
protected $categoryRepository;
/**
- * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
+ * @var Store|MockObject
*/
protected $store;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManager;
/**
- * @var \Magento\Catalog\Model\Design|\PHPUnit_Framework_MockObject_MockObject
+ * @var Design|MockObject
*/
protected $catalogDesign;
/**
- * @var \Magento\Catalog\Controller\Category\View
+ * @var View
*/
protected $action;
/**
- * @var \Magento\Framework\Controller\ResultFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResultFactory|MockObject
*/
protected $resultFactory;
/**
- * @var \Magento\Framework\View\Page|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\View\Page|MockObject
*/
protected $page;
/**
- * @var \Magento\Framework\View\Page\Config
+ * @var Config
*/
protected $pageConfig;
/**
* Set up instances and mock objects
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class);
- $this->response = $this->createMock(\Magento\Framework\App\ResponseInterface::class);
+ $this->request = $this->createMock(RequestInterface::class);
+ $this->response = $this->createMock(ResponseInterface::class);
- $this->categoryHelper = $this->createMock(\Magento\Catalog\Helper\Category::class);
- $this->objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
- $this->eventManager = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
+ $this->categoryHelper = $this->createMock(Category::class);
+ $this->objectManager = $this->createMock(ObjectManagerInterface::class);
+ $this->eventManager = $this->createMock(ManagerInterface::class);
- $this->update = $this->createMock(\Magento\Framework\View\Layout\ProcessorInterface::class);
- $this->layout = $this->createMock(\Magento\Framework\View\Layout::class);
+ $this->update = $this->createMock(ProcessorInterface::class);
+ $this->layout = $this->createMock(Layout::class);
$this->layout->expects($this->any())->method('getUpdate')->will($this->returnValue($this->update));
- $this->pageConfig = $this->getMockBuilder(\Magento\Framework\View\Page\Config::class)
+ $this->pageConfig = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()->getMock();
$this->pageConfig->expects($this->any())->method('addBodyClass')->will($this->returnSelf());
- $this->page = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class)
+ $this->page = $this->getMockBuilder(Page::class)
->setMethods(['getConfig', 'initLayout', 'addPageLayoutHandles', 'getLayout', 'addUpdate'])
->disableOriginalConstructor()->getMock();
$this->page->expects($this->any())->method('getConfig')->will($this->returnValue($this->pageConfig));
@@ -132,13 +155,13 @@ protected function setUp()
$this->page->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout));
$this->page->expects($this->any())->method('addUpdate')->willReturnSelf();
- $this->view = $this->createMock(\Magento\Framework\App\ViewInterface::class);
+ $this->view = $this->createMock(ViewInterface::class);
$this->view->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout));
- $this->resultFactory = $this->createMock(\Magento\Framework\Controller\ResultFactory::class);
+ $this->resultFactory = $this->createMock(ResultFactory::class);
$this->resultFactory->expects($this->any())->method('create')->will($this->returnValue($this->page));
- $this->context = $this->createMock(\Magento\Backend\App\Action\Context::class);
+ $this->context = $this->createMock(Context::class);
$this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
$this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
$this->context->expects($this->any())->method('getObjectManager')
@@ -149,15 +172,15 @@ protected function setUp()
->will($this->returnValue($this->resultFactory));
$this->category = $this->createMock(\Magento\Catalog\Model\Category::class);
- $this->categoryRepository = $this->createMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class);
+ $this->categoryRepository = $this->createMock(CategoryRepositoryInterface::class);
- $this->store = $this->createMock(\Magento\Store\Model\Store::class);
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->store = $this->createMock(Store::class);
+ $this->storeManager = $this->createMock(StoreManagerInterface::class);
$this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
- $this->catalogDesign = $this->createMock(\Magento\Catalog\Model\Design::class);
+ $this->catalogDesign = $this->createMock(Design::class);
- $resultPageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class)
+ $resultPageFactory = $this->getMockBuilder(PageFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
@@ -166,7 +189,7 @@ protected function setUp()
->will($this->returnValue($this->page));
$this->action = (new ObjectManager($this))->getObject(
- \Magento\Catalog\Controller\Category\View::class,
+ View::class,
[
'context' => $this->context,
'catalogDesign' => $this->catalogDesign,
@@ -202,7 +225,7 @@ public function testApplyCustomLayoutUpdate(array $expectedData): void
$this->categoryHelper->expects($this->once())->method('canShow')->with($this->category)->willReturn(true);
$settings = $this->createPartialMock(
- \Magento\Framework\DataObject::class,
+ DataObject::class,
['getPageLayout', 'getLayoutUpdates']
);
$this->category->expects($this->at(1))
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Product/Compare/IndexTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Product/Compare/IndexTest.php
index a2e784eef9f1b..f762a999f7d6a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Product/Compare/IndexTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Product/Compare/IndexTest.php
@@ -4,77 +4,94 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Controller\Product\Compare;
+use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Controller\Product\Compare\Index;
-
+use Magento\Catalog\Model\Product\Compare\ItemFactory;
+use Magento\Catalog\Model\Product\Compare\ListCompare;
use Magento\Catalog\Model\ResourceModel\Product\Compare\Item;
+use Magento\Catalog\Model\ResourceModel\Product\Compare\Item\CollectionFactory;
+use Magento\Customer\Model\Session;
+use Magento\Customer\Model\Visitor;
+use Magento\Framework\App\Action\Context;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\App\ResponseInterface;
+use Magento\Framework\Controller\Result\RedirectFactory;
+use Magento\Framework\Data\Form\FormKey\Validator;
+use Magento\Framework\Url\DecoderInterface;
+use Magento\Framework\View\Result\PageFactory;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class IndexTest extends \PHPUnit\Framework\TestCase
+class IndexTest extends TestCase
{
- /** @var \Magento\Catalog\Controller\Product\Compare\Index */
+ /** @var Index */
protected $index;
- /** @var \Magento\Framework\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Context|MockObject */
protected $contextMock;
- /** @var \Magento\Catalog\Model\Product\Compare\ItemFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ItemFactory|MockObject */
protected $itemFactoryMock;
- /** @var Item\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Item\CollectionFactory|MockObject */
protected $collectionFactoryMock;
- /** @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Session|MockObject */
protected $sessionMock;
- /** @var \Magento\Customer\Model\Visitor|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Visitor|MockObject */
protected $visitorMock;
- /** @var \Magento\Catalog\Model\Product\Compare\ListCompare|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ListCompare|MockObject */
protected $listCompareMock;
- /** @var \Magento\Catalog\Model\Session|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Catalog\Model\Session|MockObject */
protected $catalogSession;
- /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var StoreManagerInterface|MockObject */
protected $storeManagerMock;
- /** @var \Magento\Framework\Data\Form\FormKey\Validator|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Validator|MockObject */
protected $formKeyValidatorMock;
- /** @var \Magento\Framework\Controller\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var RedirectFactory|MockObject */
protected $redirectFactoryMock;
- /** @var \Magento\Framework\View\Result\PageFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var PageFactory|MockObject */
protected $pageFactoryMock;
- /** @var \Magento\Catalog\Api\ProductRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ProductRepositoryInterface|MockObject */
protected $productRepositoryMock;
- /** @var \Magento\Framework\Url\DecoderInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var DecoderInterface|MockObject */
protected $decoderMock;
- /** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var RequestInterface|MockObject */
protected $request;
- /** @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ResponseInterface|MockObject */
protected $response;
- protected function setUp()
+ protected function setUp(): void
{
$this->contextMock = $this->createPartialMock(
- \Magento\Framework\App\Action\Context::class,
+ Context::class,
['getRequest', 'getResponse', 'getResultRedirectFactory']
);
- $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class);
- $this->response = $this->createMock(\Magento\Framework\App\ResponseInterface::class);
+ $this->request = $this->createMock(RequestInterface::class);
+ $this->response = $this->createMock(ResponseInterface::class);
$this->redirectFactoryMock = $this->createPartialMock(
- \Magento\Framework\Controller\Result\RedirectFactory::class,
+ RedirectFactory::class,
['create']
);
$this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->request);
@@ -84,27 +101,27 @@ protected function setUp()
->willReturn($this->redirectFactoryMock);
$this->itemFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Compare\ItemFactory::class,
+ ItemFactory::class,
['create']
);
$this->collectionFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\Compare\Item\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
- $this->sessionMock = $this->createMock(\Magento\Customer\Model\Session::class);
- $this->visitorMock = $this->createMock(\Magento\Customer\Model\Visitor::class);
- $this->listCompareMock = $this->createMock(\Magento\Catalog\Model\Product\Compare\ListCompare::class);
+ $this->sessionMock = $this->createMock(Session::class);
+ $this->visitorMock = $this->createMock(Visitor::class);
+ $this->listCompareMock = $this->createMock(ListCompare::class);
$this->catalogSession = $this->createPartialMock(
\Magento\Catalog\Model\Session::class,
['setBeforeCompareUrl']
);
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->formKeyValidatorMock = $this->getMockBuilder(\Magento\Framework\Data\Form\FormKey\Validator::class)
+ $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $this->formKeyValidatorMock = $this->getMockBuilder(Validator::class)
->disableOriginalConstructor()
->getMock();
- $this->pageFactoryMock = $this->createMock(\Magento\Framework\View\Result\PageFactory::class);
- $this->productRepositoryMock = $this->createMock(\Magento\Catalog\Api\ProductRepositoryInterface::class);
- $this->decoderMock = $this->createMock(\Magento\Framework\Url\DecoderInterface::class);
+ $this->pageFactoryMock = $this->createMock(PageFactory::class);
+ $this->productRepositoryMock = $this->createMock(ProductRepositoryInterface::class);
+ $this->decoderMock = $this->createMock(DecoderInterface::class);
$this->index = new Index(
$this->contextMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Product/Frontend/Action/SynchronizeTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Product/Frontend/Action/SynchronizeTest.php
index 4b7053765516d..f655c9cd2679b 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Product/Frontend/Action/SynchronizeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Product/Frontend/Action/SynchronizeTest.php
@@ -3,43 +3,49 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Controller\Product\Frontend\Action;
-use Magento\Framework\App\Action\Context;
+use Laminas\Http\AbstractMessage;
+use Laminas\Http\Response;
+use Magento\Catalog\Controller\Product\Frontend\Action\Synchronize;
use Magento\Catalog\Model\Product\ProductFrontendAction\Synchronizer;
-use Magento\Framework\Controller\Result\JsonFactory;
-use Magento\Framework\Controller\Result\Json;
+use Magento\Framework\App\Action\Context;
use Magento\Framework\App\RequestInterface;
-use Magento\Catalog\Controller\Product\Frontend\Action\Synchronize;
+use Magento\Framework\Controller\Result\Json;
+use Magento\Framework\Controller\Result\JsonFactory;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SynchronizeTest extends \PHPUnit\Framework\TestCase
+class SynchronizeTest extends TestCase
{
/**
- * @var \Magento\Catalog\Controller\Product\Frontend\Action\Synchronize
+ * @var Synchronize
*/
private $synchronize;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $contextMock;
/**
- * @var Synchronizer|\PHPUnit_Framework_MockObject_MockObject
+ * @var Synchronizer|MockObject
*/
private $synchronizerMock;
/**
- * @var RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
private $requestMock;
/**
- * @var JsonFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var JsonFactory|MockObject
*/
private $jsonFactoryMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->contextMock = $this->getMockBuilder(Context::class)
->disableOriginalConstructor()
@@ -101,7 +107,7 @@ public function testExecuteAction()
$this->synchronize->execute();
}
-
+
public function testExecuteActionException()
{
$data = [
@@ -128,13 +134,13 @@ public function testExecuteActionException()
$this->synchronizerMock->expects($this->once())
->method('syncActions')
- ->willThrowException(new \Exception);
+ ->willThrowException(new \Exception());
$jsonObject->expects($this->once())
->method('setStatusHeader')
->with(
- \Laminas\Http\Response::STATUS_CODE_400,
- \Laminas\Http\AbstractMessage::VERSION_11,
+ Response::STATUS_CODE_400,
+ AbstractMessage::VERSION_11,
'Bad Request'
);
$jsonObject->expects($this->once())
diff --git a/app/code/Magento/Catalog/Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php b/app/code/Magento/Catalog/Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php
index 1a9d7959dda9c..ddafaf25608bd 100644
--- a/app/code/Magento/Catalog/Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php
@@ -9,11 +9,13 @@
use Magento\Catalog\Cron\DeleteAbandonedStoreFlatTables;
use Magento\Catalog\Helper\Product\Flat\Indexer;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @covers \Magento\Catalog\Cron\DeleteAbandonedStoreFlatTables
*/
-class DeleteAbandonedStoreFlatTablesTest extends \PHPUnit\Framework\TestCase
+class DeleteAbandonedStoreFlatTablesTest extends TestCase
{
/**
* Testable Object
@@ -23,7 +25,7 @@ class DeleteAbandonedStoreFlatTablesTest extends \PHPUnit\Framework\TestCase
private $deleteAbandonedStoreFlatTables;
/**
- * @var Indexer|\PHPUnit_Framework_MockObject_MockObject
+ * @var Indexer|MockObject
*/
private $indexerMock;
@@ -32,7 +34,7 @@ class DeleteAbandonedStoreFlatTablesTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->indexerMock = $this->createMock(Indexer::class);
$this->deleteAbandonedStoreFlatTables = new DeleteAbandonedStoreFlatTables($this->indexerMock);
diff --git a/app/code/Magento/Catalog/Test/Unit/Cron/DeleteOutdatedPriceValuesTest.php b/app/code/Magento/Catalog/Test/Unit/Cron/DeleteOutdatedPriceValuesTest.php
index f1d0034c29580..3d27b31e3cc02 100644
--- a/app/code/Magento/Catalog/Test/Unit/Cron/DeleteOutdatedPriceValuesTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Cron/DeleteOutdatedPriceValuesTest.php
@@ -16,11 +16,13 @@
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Store\Model\Store;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @covers \Magento\Catalog\Cron\DeleteOutdatedPriceValues
*/
-class DeleteOutdatedPriceValuesTest extends \PHPUnit\Framework\TestCase
+class DeleteOutdatedPriceValuesTest extends TestCase
{
/**
* Testable Object
@@ -30,32 +32,32 @@ class DeleteOutdatedPriceValuesTest extends \PHPUnit\Framework\TestCase
private $deleteOutdatedPriceValues;
/**
- * @var AttributeRepository|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeRepository|MockObject
*/
private $attributeRepositoryMock;
/**
- * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceConnectionMock;
/**
- * @var ScopeConfig|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfig|MockObject
*/
private $scopeConfigMock;
/**
- * @var Attribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var Attribute|MockObject
*/
private $attributeMock;
/**
- * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $dbAdapterMock;
/**
- * @var BackendInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var BackendInterface|MockObject
*/
private $attributeBackendMock;
@@ -64,7 +66,7 @@ class DeleteOutdatedPriceValuesTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->resourceConnectionMock = $this->createMock(ResourceConnection::class);
$this->attributeRepositoryMock = $this->createMock(AttributeRepository::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Cron/FrontendActionsFlushTest.php b/app/code/Magento/Catalog/Test/Unit/Cron/FrontendActionsFlushTest.php
index 29d9736e02442..ee4b1eab41078 100644
--- a/app/code/Magento/Catalog/Test/Unit/Cron/FrontendActionsFlushTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Cron/FrontendActionsFlushTest.php
@@ -3,40 +3,50 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Cron;
+use Magento\Catalog\Cron\FrontendActionsFlush;
+use Magento\Catalog\Model\FrontendStorageConfigurationInterface;
+use Magento\Catalog\Model\FrontendStorageConfigurationPool;
+use Magento\Catalog\Model\ResourceModel\ProductFrontendAction;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class FrontendActionsFlushTest extends \PHPUnit\Framework\TestCase
+class FrontendActionsFlushTest extends TestCase
{
- /** @var \Magento\Catalog\Cron\FrontendActionsFlush */
+ /** @var FrontendActionsFlush */
protected $model;
/** @var ObjectManagerHelper */
protected $objectManagerHelper;
- /** @var \Magento\Catalog\Model\ResourceModel\ProductFrontendAction|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ProductFrontendAction|MockObject */
protected $productFrontendActionMock;
- /** @var \Magento\Catalog\Model\FrontendStorageConfigurationPool|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var FrontendStorageConfigurationPool|MockObject */
protected $frontendStorageConfigurationPoolMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->productFrontendActionMock = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\ProductFrontendAction::class
+ ProductFrontendAction::class
)
->disableOriginalConstructor()
->getMock();
$this->frontendStorageConfigurationPoolMock = $this->getMockBuilder(
- \Magento\Catalog\Model\FrontendStorageConfigurationPool::class
+ FrontendStorageConfigurationPool::class
)
->disableOriginalConstructor()
->getMock();
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Cron\FrontendActionsFlush::class,
+ FrontendActionsFlush::class,
[
'productFrontendActionResource' => $this->productFrontendActionMock,
'frontendStorageConfigurationPool' => $this->frontendStorageConfigurationPoolMock
@@ -46,9 +56,9 @@ protected function setUp()
public function testExecute()
{
- $connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
- $selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
- $frontendConfiguration = $this->createMock(\Magento\Catalog\Model\FrontendStorageConfigurationInterface::class);
+ $connectionMock = $this->createMock(AdapterInterface::class);
+ $selectMock = $this->createMock(Select::class);
+ $frontendConfiguration = $this->createMock(FrontendStorageConfigurationInterface::class);
$selectMock
->expects($this->once())
diff --git a/app/code/Magento/Catalog/Test/Unit/Cron/RefreshSpecialPricesTest.php b/app/code/Magento/Catalog/Test/Unit/Cron/RefreshSpecialPricesTest.php
index 458ed98ecf946..0f52745cde7e3 100644
--- a/app/code/Magento/Catalog/Test/Unit/Cron/RefreshSpecialPricesTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Cron/RefreshSpecialPricesTest.php
@@ -3,81 +3,98 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Cron;
+use Magento\Catalog\Cron\RefreshSpecialPrices;
+use Magento\Catalog\Model\Indexer\Product\Price\Processor;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use Magento\Framework\EntityManager\EntityMetadata;
use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Stdlib\DateTime;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Indexer\Model\Indexer;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class RefreshSpecialPricesTest extends \PHPUnit\Framework\TestCase
+class RefreshSpecialPricesTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $_objectManager;
/**
- * @var \Magento\Catalog\Cron\RefreshSpecialPrices
+ * @var RefreshSpecialPrices
*/
protected $_model;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $_storeManagerMock;
/**
- * @var Resource|\PHPUnit_Framework_MockObject_MockObject
+ * @var Resource|MockObject
*/
protected $_resourceMock;
/**
- * @var \Magento\Framework\Stdlib\DateTime|\PHPUnit_Framework_MockObject_MockObject
+ * @var DateTime|MockObject
*/
protected $_dateTimeMock;
/**
- * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var TimezoneInterface|MockObject
*/
protected $_localeDateMock;
/**
- * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
protected $_eavConfigMock;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor|\PHPUnit_Framework_MockObject_MockObject
+ * @var Processor|MockObject
*/
protected $_priceProcessorMock;
/**
- * @var MetadataPool|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataPool|MockObject
*/
protected $metadataPool;
/**
- * @var \Magento\Framework\EntityManager\EntityMetadata|\PHPUnit_Framework_MockObject_MockObject
+ * @var EntityMetadata|MockObject
*/
protected $metadataMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->_objectManager = new ObjectManager($this);
- $this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->_resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
- $this->_dateTimeMock = $this->createMock(\Magento\Framework\Stdlib\DateTime::class);
- $this->_localeDateMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
- $this->_eavConfigMock = $this->createMock(\Magento\Eav\Model\Config::class);
- $this->_priceProcessorMock = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Price\Processor::class);
+ $this->_storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $this->_resourceMock = $this->createMock(ResourceConnection::class);
+ $this->_dateTimeMock = $this->createMock(DateTime::class);
+ $this->_localeDateMock = $this->createMock(TimezoneInterface::class);
+ $this->_eavConfigMock = $this->createMock(Config::class);
+ $this->_priceProcessorMock = $this->createMock(Processor::class);
- $this->metadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class);
+ $this->metadataMock = $this->createMock(EntityMetadata::class);
$this->_model = $this->_objectManager->getObject(
- \Magento\Catalog\Cron\RefreshSpecialPrices::class,
+ RefreshSpecialPrices::class,
[
'storeManager' => $this->_storeManagerMock,
'resource' => $this->_resourceMock,
@@ -108,12 +125,12 @@ public function testRefreshSpecialPrices()
$this->metadataMock->expects($this->atLeastOnce())->method('getIdentifierField')->willReturn('entity_id');
- $selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
+ $selectMock = $this->createMock(Select::class);
$selectMock->expects($this->any())->method('from')->will($this->returnSelf());
$selectMock->expects($this->any())->method('joinLeft')->will($this->returnSelf());
$selectMock->expects($this->any())->method('where')->will($this->returnSelf());
- $connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
+ $connectionMock = $this->createMock(AdapterInterface::class);
$connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock));
$connectionMock->expects(
$this->any()
@@ -139,7 +156,7 @@ public function testRefreshSpecialPrices()
$this->returnValue('category')
);
- $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
+ $storeMock = $this->createMock(Store::class);
$storeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->_storeManagerMock->expects(
@@ -162,7 +179,7 @@ public function testRefreshSpecialPrices()
$this->returnValue(32000)
);
- $indexerMock = $this->createMock(\Magento\Indexer\Model\Indexer::class);
+ $indexerMock = $this->createMock(Indexer::class);
$indexerMock->expects($this->exactly(2))->method('reindexList');
$this->_priceProcessorMock->expects(
@@ -174,7 +191,7 @@ public function testRefreshSpecialPrices()
);
$attributeMock = $this->getMockForAbstractClass(
- \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
+ AbstractAttribute::class,
[],
'',
false,
diff --git a/app/code/Magento/Catalog/Test/Unit/Cron/SynchronizeWebsiteAttributesTest.php b/app/code/Magento/Catalog/Test/Unit/Cron/SynchronizeWebsiteAttributesTest.php
index fe41a3976929a..cc041a692089a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Cron/SynchronizeWebsiteAttributesTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Cron/SynchronizeWebsiteAttributesTest.php
@@ -3,17 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Cron;
use Magento\Catalog\Cron\SynchronizeWebsiteAttributes;
use Magento\Catalog\Model\ResourceModel\Attribute\WebsiteAttributesSynchronizer;
+use PHPUnit\Framework\TestCase;
-/**
- * Class SynchronizeWebsiteAttributesTest
- * @package Magento\Catalog\Test\Unit\Cron
- */
-class SynchronizeWebsiteAttributesTest extends \PHPUnit\Framework\TestCase
+class SynchronizeWebsiteAttributesTest extends TestCase
{
public function testExecuteSuccess()
{
diff --git a/app/code/Magento/Catalog/Test/Unit/CustomerData/CompareProductsTest.php b/app/code/Magento/Catalog/Test/Unit/CustomerData/CompareProductsTest.php
index 6f5d927e333ec..8b604e3488220 100644
--- a/app/code/Magento/Catalog/Test/Unit/CustomerData/CompareProductsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/CustomerData/CompareProductsTest.php
@@ -17,8 +17,10 @@
use Magento\Catalog\Model\ResourceModel\Product\Compare\Item\Collection;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CompareProductsTest extends \PHPUnit\Framework\TestCase
+class CompareProductsTest extends TestCase
{
/**
* @var CompareProducts
@@ -26,17 +28,17 @@ class CompareProductsTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var Compare|\PHPUnit_Framework_MockObject_MockObject
+ * @var Compare|MockObject
*/
private $helperMock;
/**
- * @var Url|\PHPUnit_Framework_MockObject_MockObject
+ * @var Url|MockObject
*/
private $productUrlMock;
/**
- * @var Output|\PHPUnit_Framework_MockObject_MockObject
+ * @var Output|MockObject
*/
private $outputHelperMock;
@@ -46,7 +48,7 @@ class CompareProductsTest extends \PHPUnit\Framework\TestCase
private $objectManagerHelper;
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $scopeConfigMock;
@@ -58,7 +60,7 @@ class CompareProductsTest extends \PHPUnit\Framework\TestCase
ProductInterface::NAME => 'getName'
];
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -92,9 +94,9 @@ protected function setUp()
* Prepare compare items collection.
*
* @param array $items
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
- private function getItemCollectionMock(array $items) : \PHPUnit_Framework_MockObject_MockObject
+ private function getItemCollectionMock(array $items) : MockObject
{
$itemCollectionMock = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
@@ -152,9 +154,9 @@ private function prepareProductsWithCorrespondingMocks(array $dataSet) : array
* Prepare mock of product object.
*
* @param array $data
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
- private function getProductMock(array $data) : \PHPUnit_Framework_MockObject_MockObject
+ private function getProductMock(array $data) : MockObject
{
$product = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/CustomerData/ProductFrontendActionSectionTest.php b/app/code/Magento/Catalog/Test/Unit/CustomerData/ProductFrontendActionSectionTest.php
index ffc82d002afcb..cf4ff22fbb5b8 100644
--- a/app/code/Magento/Catalog/Test/Unit/CustomerData/ProductFrontendActionSectionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/CustomerData/ProductFrontendActionSectionTest.php
@@ -3,40 +3,38 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\CustomerData;
use Magento\Catalog\Api\Data\ProductFrontendActionInterface;
+use Magento\Catalog\CustomerData\ProductFrontendActionSection;
use Magento\Catalog\Model\Product\ProductFrontendAction\Synchronizer;
use Magento\Framework\App\Config;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
-use Magento\Catalog\CustomerData\ProductFrontendActionSection;
-class ProductFrontendActionSectionTest extends \PHPUnit\Framework\TestCase
+class ProductFrontendActionSectionTest extends TestCase
{
- /** @var \Magento\Catalog\CustomerData\ProductFrontendActionSection */
+ /** @var ProductFrontendActionSection */
protected $model;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
protected $synchronizerMock;
- /** @var \SafeReflectionClass|\PHPUnit_Framework_MockObject_MockObject */
- protected $safeReflectionClassMock;
-
- /** @var Config|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Config|MockObject */
private $appConfigMock;
- /** @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var LoggerInterface|MockObject */
private $loggerMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->synchronizerMock = $this
->getMockBuilder(Synchronizer::class)
->disableOriginalConstructor()
->getMock();
- $this->safeReflectionClassMock = $this->getMockBuilder(\SafeReflectionClass::class)
- ->disableOriginalConstructor()
- ->getMock();
$this->appConfigMock = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/CustomerData/ProductsRenderInfoSectionTest.php b/app/code/Magento/Catalog/Test/Unit/CustomerData/ProductsRenderInfoSectionTest.php
index 3a954c9369089..dda3cb97e75f9 100644
--- a/app/code/Magento/Catalog/Test/Unit/CustomerData/ProductsRenderInfoSectionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/CustomerData/ProductsRenderInfoSectionTest.php
@@ -3,72 +3,83 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\CustomerData;
use Magento\Catalog\Api\Data\ProductFrontendActionInterface;
use Magento\Catalog\Api\Data\ProductRenderInterface;
use Magento\Catalog\Api\Data\ProductRenderSearchResultsInterface;
+use Magento\Catalog\CustomerData\ProductsRenderInfoSection;
+use Magento\Catalog\Model\Product\ProductFrontendAction\Synchronizer;
+use Magento\Catalog\Model\ProductRenderList;
use Magento\Framework\Api\Filter;
+use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\Search\SearchCriteria;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\EntityManager\Hydrator;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ProductsRenderInfoSectionTest extends \PHPUnit\Framework\TestCase
+class ProductsRenderInfoSectionTest extends TestCase
{
- /** @var \Magento\Catalog\CustomerData\ProductsRenderInfoSection */
+ /** @var ProductsRenderInfoSection */
protected $model;
/** @var ObjectManagerHelper */
protected $objectManagerHelper;
- /** @var \Magento\Store\Model\StoreManager|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var StoreManager|MockObject */
protected $storeManagerMock;
- /** @var \Magento\Framework\Api\SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var SearchCriteriaBuilder|MockObject */
protected $searchCriteriaBuilderMock;
- /** @var \Magento\Framework\Api\FilterBuilder|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var FilterBuilder|MockObject */
protected $filterBuilderMock;
- /** @var \Magento\Catalog\Model\ProductRenderList |\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ProductRenderList|MockObject */
protected $productRenderRepositoryMock;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
protected $synchronizerMock;
- /** @var \Magento\Framework\EntityManager\Hydrator|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Hydrator|MockObject */
protected $hydratorMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManager::class)
+ $this->storeManagerMock = $this->getMockBuilder(StoreManager::class)
->disableOriginalConstructor()
->getMock();
$this->searchCriteriaBuilderMock = $this
- ->getMockBuilder(\Magento\Framework\Api\SearchCriteriaBuilder::class)
+ ->getMockBuilder(SearchCriteriaBuilder::class)
->disableOriginalConstructor()
->getMock();
- $this->filterBuilderMock = $this->getMockBuilder(\Magento\Framework\Api\FilterBuilder::class)
+ $this->filterBuilderMock = $this->getMockBuilder(FilterBuilder::class)
->disableOriginalConstructor()
->getMock();
$this->productRenderRepositoryMock = $this
- ->getMockBuilder(\Magento\Catalog\Model\ProductRenderList::class)
+ ->getMockBuilder(ProductRenderList::class)
->disableOriginalConstructor()
->getMock();
$this->synchronizerMock = $this
- ->getMockBuilder(\Magento\Catalog\Model\Product\ProductFrontendAction\Synchronizer::class)
+ ->getMockBuilder(Synchronizer::class)
->disableOriginalConstructor()
->getMock();
- $this->hydratorMock = $this->getMockBuilder(\Magento\Framework\EntityManager\Hydrator::class)
+ $this->hydratorMock = $this->getMockBuilder(Hydrator::class)
->disableOriginalConstructor()
->getMock();
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $this->objectManagerHelper->getObject(
- \Magento\Catalog\CustomerData\ProductsRenderInfoSection::class,
+ ProductsRenderInfoSection::class,
[
'storeManager' => $this->storeManagerMock,
'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php
index f37192538655e..aa29972c91a62 100644
--- a/app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php
@@ -3,12 +3,27 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Helper;
use Magento\Catalog\Helper\Image;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\ImageFactory as ProductImageFactory;
+use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\Helper\Context;
+use Magento\Framework\Config\View;
+use Magento\Framework\View\Asset\Repository;
+use Magento\Framework\View\ConfigInterface;
+use Magento\Store\Model\ScopeInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ImageTest extends \PHPUnit\Framework\TestCase
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
+class ImageTest extends TestCase
{
/**
* @var Image
@@ -16,62 +31,62 @@ class ImageTest extends \PHPUnit\Framework\TestCase
protected $helper;
/**
- * @var \Magento\Framework\App\Helper\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $context;
/**
- * @var \Magento\Catalog\Block\Product\ImageFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Block\Product\ImageFactory|MockObject
*/
protected $imageFactory;
/**
- * @var \Magento\Framework\View\Asset\Repository|\PHPUnit_Framework_MockObject_MockObject
+ * @var Repository|MockObject
*/
protected $assetRepository;
/**
- * @var \Magento\Framework\Config\View|\PHPUnit\Framework\MockObject\MockObject
+ * @var View|MockObject
*/
protected $configView;
/**
- * @var \Magento\Framework\View\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConfigInterface|MockObject
*/
protected $viewConfig;
/**
- * @var \Magento\Catalog\Model\Product\Image|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Model\Product\Image|MockObject
*/
protected $image;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $scopeConfig;
/**
- * @var \Magento\Catalog\Model\View\Asset\PlaceholderFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var PlaceholderFactory|MockObject
*/
protected $placeholderFactory;
- protected function setUp()
+ protected function setUp(): void
{
$this->mockContext();
$this->mockImage();
- $this->assetRepository = $this->getMockBuilder(\Magento\Framework\View\Asset\Repository::class)
+ $this->assetRepository = $this->getMockBuilder(Repository::class)
->disableOriginalConstructor()
->getMock();
- $this->configView = $this->getMockBuilder(\Magento\Framework\Config\View::class)
+ $this->configView = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
->getMock();
- $this->viewConfig = $this->getMockBuilder(\Magento\Framework\View\ConfigInterface::class)
+ $this->viewConfig = $this->getMockBuilder(ConfigInterface::class)
->getMockForAbstractClass();
- $this->placeholderFactory = $this->getMockBuilder(\Magento\Catalog\Model\View\Asset\PlaceholderFactory::class)
+ $this->placeholderFactory = $this->getMockBuilder(PlaceholderFactory::class)
->disableOriginalConstructor()
->getMock();
@@ -86,11 +101,11 @@ protected function setUp()
protected function mockContext()
{
- $this->context = $this->getMockBuilder(\Magento\Framework\App\Helper\Context::class)
+ $this->context = $this->getMockBuilder(Context::class)
->disableOriginalConstructor()
->getMock();
- $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
+ $this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
->getMockForAbstractClass();
$this->context->expects($this->any())
->method('getScopeConfig')
@@ -99,7 +114,7 @@ protected function mockContext()
protected function mockImage()
{
- $this->imageFactory = $this->getMockBuilder(\Magento\Catalog\Model\Product\ImageFactory::class)
+ $this->imageFactory = $this->getMockBuilder(ProductImageFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
@@ -121,7 +136,7 @@ public function testInit($data)
$imageId = 'test_image_id';
$attributes = [];
- $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
@@ -172,7 +187,7 @@ public function testInitKeepFrame($data, $whiteBorders, $expectedKeepFrame)
$imageId = 'test_image_id';
$attributes = [];
- $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
@@ -300,25 +315,25 @@ protected function prepareWatermarkProperties($data)
[
[
'design/watermark/' . $data['type'] . '_image',
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
null,
$data['watermark']
],
[
'design/watermark/' . $data['type'] . '_imageOpacity',
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
null,
$data['watermark_opacity']
],
[
'design/watermark/' . $data['type'] . '_position',
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
null,
$data['watermark_position']
],
[
'design/watermark/' . $data['type'] . '_size',
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
null,
$data['watermark_size']
],
@@ -352,7 +367,7 @@ public function testGetType()
'type' => 'image',
];
- $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
@@ -371,7 +386,7 @@ public function testGetWidth()
'width' => 100,
];
- $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
@@ -390,7 +405,7 @@ public function testGetHeight($data)
$imageId = 'test_image_id';
$attributes = [];
- $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
@@ -432,7 +447,7 @@ public function testGetFrame($data)
$imageId = 'test_image_id';
$attributes = [];
- $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
@@ -469,7 +484,7 @@ public function testGetLabel($data, $expected)
$imageId = 'test_image_id';
$attributes = [];
- $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
@@ -531,7 +546,7 @@ public function testGetResizedImageInfo(
$isBaseFilePlaceholder,
$resizedImageInfo
) {
- $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php
index e6fbf2a46824d..3e090cdfae575 100644
--- a/app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php
@@ -3,15 +3,24 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Helper\Product;
+use Magento\Catalog\Helper\Product\Compare;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Session;
use Magento\Framework\App\Action\Action;
-
-/**
- * Class CompareTest
- */
-class CompareTest extends \PHPUnit\Framework\TestCase
+use Magento\Framework\App\Helper\Context;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\Data\Helper\PostHelper;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\Url;
+use Magento\Framework\Url\EncoderInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class CompareTest extends TestCase
{
/**
* @var \Magento\Catalog\Helper\Product\Compare
@@ -19,50 +28,50 @@ class CompareTest extends \PHPUnit\Framework\TestCase
protected $compareHelper;
/**
- * @var \Magento\Framework\App\Helper\Context | \PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $context;
/**
- * @var \Magento\Framework\Url | \PHPUnit_Framework_MockObject_MockObject
+ * @var Url|MockObject
*/
protected $urlBuilder;
/**
- * @var \Magento\Framework\Data\Helper\PostHelper | \PHPUnit_Framework_MockObject_MockObject
+ * @var PostHelper|MockObject
*/
protected $postDataHelper;
/**
- * @var \Magento\Framework\App\Request\Http | \PHPUnit_Framework_MockObject_MockObject
+ * @var Http|MockObject
*/
protected $request;
/**
- * @var \Magento\Framework\Url\EncoderInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var EncoderInterface|MockObject
*/
protected $urlEncoder;
/**
- * @var \Magento\Catalog\Model\Session | \PHPUnit_Framework_MockObject_MockObject
+ * @var Session|MockObject
*/
protected $catalogSessionMock;
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
- $this->urlBuilder = $this->createPartialMock(\Magento\Framework\Url::class, ['getUrl']);
+ $this->urlBuilder = $this->createPartialMock(Url::class, ['getUrl']);
$this->request = $this->createPartialMock(
- \Magento\Framework\App\Request\Http::class,
+ Http::class,
['getServer', 'isSecure']
);
- /** @var \Magento\Framework\App\Helper\Context $context */
+ /** @var Context $context */
$this->context = $this->createPartialMock(
- \Magento\Framework\App\Helper\Context::class,
+ Context::class,
['getUrlBuilder', 'getRequest', 'getUrlEncoder']
);
- $this->urlEncoder = $this->getMockBuilder(\Magento\Framework\Url\EncoderInterface::class)->getMock();
+ $this->urlEncoder = $this->getMockBuilder(EncoderInterface::class)->getMock();
$this->urlEncoder->expects($this->any())
->method('encode')
->willReturnCallback(
@@ -80,16 +89,16 @@ function ($url) {
->method('getUrlEncoder')
->will($this->returnValue($this->urlEncoder));
$this->postDataHelper = $this->createPartialMock(
- \Magento\Framework\Data\Helper\PostHelper::class,
+ PostHelper::class,
['getPostData']
);
$this->catalogSessionMock = $this->createPartialMock(
- \Magento\Catalog\Model\Session::class,
+ Session::class,
['getBeforeCompareUrl']
);
$this->compareHelper = $objectManager->getObject(
- \Magento\Catalog\Helper\Product\Compare::class,
+ Compare::class,
[
'context' => $this->context,
'postHelper' => $this->postDataHelper,
@@ -120,8 +129,8 @@ public function testGetPostDataRemove()
->with($removeUrl, $postParams)
->will($this->returnValue(true));
- /** @var \Magento\Catalog\Model\Product | \PHPUnit_Framework_MockObject_MockObject $product */
- $product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getId', '__wakeup']);
+ /** @var Product|MockObject $product */
+ $product = $this->createPartialMock(Product::class, ['getId', '__wakeup']);
$product->expects($this->once())
->method('getId')
->will($this->returnValue($productId));
@@ -179,7 +188,7 @@ public function testGetAddToCartUrl()
'_secure' => $isRequestSecure
];
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $productMock = $this->createMock(Product::class);
$this->catalogSessionMock->expects($this->once())->method('getBeforeCompareUrl')->willReturn($beforeCompareUrl);
$productMock->expects($this->once())->method('getId')->willReturn($productId);
$this->urlEncoder->expects($this->once())->method('encode')->with($beforeCompareUrl)
diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationPoolTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationPoolTest.php
index 3882db06fc0b6..1b90d8fab17b4 100644
--- a/app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationPoolTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationPoolTest.php
@@ -3,9 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Helper\Product;
-class ConfigurationPoolTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Helper\Product\ConfigurationPool;
+use Magento\Framework\ObjectManagerInterface;
+use PHPUnit\Framework\TestCase;
+
+class ConfigurationPoolTest extends TestCase
{
/**
* @var array
@@ -13,16 +19,16 @@ class ConfigurationPoolTest extends \PHPUnit\Framework\TestCase
protected $instancesType;
/**
- * @var \Magento\Catalog\Helper\Product\ConfigurationPool
+ * @var ConfigurationPool
*/
protected $model;
- protected function setUp()
+ protected function setUp(): void
{
$this->instancesType = ['simple' => 'simple', 'default' => 'default'];
- $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
- $this->model = new \Magento\Catalog\Helper\Product\ConfigurationPool($objectManagerMock, $this->instancesType);
+ $objectManagerMock = $this->createMock(ObjectManagerInterface::class);
+ $this->model = new ConfigurationPool($objectManagerMock, $this->instancesType);
}
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationTest.php
index 8421042af843a..424e6656bc76a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Helper/Product/ConfigurationTest.php
@@ -3,29 +3,43 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Helper\Product;
-class ConfigurationTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Helper\Product\Configuration;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Configuration\Item\ItemInterface;
+use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface;
+use Magento\Catalog\Model\Product\OptionFactory;
+use Magento\Framework\App\Helper\Context;
+use Magento\Framework\Filter\FilterManager;
+use Magento\Framework\Serialize\Serializer\Json;
+use Magento\Framework\Stdlib\StringUtils;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ConfigurationTest extends TestCase
{
/**
- * @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject
+ * @var Json|MockObject
*/
protected $serializer;
/**
- * @var \Magento\Catalog\Helper\Product\Configuration
+ * @var Configuration
*/
protected $helper;
- protected function setUp()
+ protected function setUp(): void
{
- $contextMock = $this->createMock(\Magento\Framework\App\Helper\Context::class);
- $optionFactoryMock = $this->createMock(\Magento\Catalog\Model\Product\OptionFactory::class);
- $filterManagerMock = $this->createMock(\Magento\Framework\Filter\FilterManager::class);
- $stringUtilsMock = $this->createMock(\Magento\Framework\Stdlib\StringUtils::class);
- $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class);
+ $contextMock = $this->createMock(Context::class);
+ $optionFactoryMock = $this->createMock(OptionFactory::class);
+ $filterManagerMock = $this->createMock(FilterManager::class);
+ $stringUtilsMock = $this->createMock(StringUtils::class);
+ $this->serializer = $this->createMock(Json::class);
- $this->helper = new \Magento\Catalog\Helper\Product\Configuration(
+ $this->helper = new Configuration(
$contextMock,
$optionFactoryMock,
$filterManagerMock,
@@ -41,14 +55,14 @@ public function testGetAdditionalOptionOnly()
{
$additionalOptionResult = ['additional_option' => 1];
- $itemMock = $this->createMock(\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class);
+ $itemMock = $this->createMock(ItemInterface::class);
$optionMock = $this->createMock(
- \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class
+ OptionInterface::class
);
$additionalOptionMock = $this->createMock(
- \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class
+ OptionInterface::class
);
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $productMock = $this->createMock(Product::class);
$this->serializer->expects($this->once())->method('unserialize')->willReturn($additionalOptionResult);
$optionMock->expects($this->once())->method('getValue')->willReturn(null);
diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/Product/Edit/Action/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/Product/Edit/Action/AttributeTest.php
index dcc8ec645abd3..f55c33a1f2c79 100644
--- a/app/code/Magento/Catalog/Test/Unit/Helper/Product/Edit/Action/AttributeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Helper/Product/Edit/Action/AttributeTest.php
@@ -3,20 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Helper\Product\Edit\Action;
-/**
- * Class AttributeTest
- */
-class AttributeTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Helper\Product\Edit\Action\Attribute;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class AttributeTest extends TestCase
{
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManagerMock;
/**
- * @var \Magento\Catalog\Helper\Product\Edit\Action\Attribute
+ * @var Attribute
*/
protected $attribute;
@@ -25,19 +31,19 @@ class AttributeTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->storeManagerMock = $this->getMockForAbstractClass(
- \Magento\Store\Model\StoreManagerInterface::class,
+ StoreManagerInterface::class,
[],
'',
false
);
$this->attribute = $objectManager->getObject(
- \Magento\Catalog\Helper\Product\Edit\Action\Attribute::class,
+ Attribute::class,
[
'storeManager' => $this->storeManagerMock
]
@@ -53,7 +59,7 @@ public function testGetStoreWebsiteId()
{
$storeId = 20;
- $storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getWebsiteId']);
+ $storeMock = $this->createPartialMock(Store::class, ['getWebsiteId']);
$this->storeManagerMock->expects($this->once())
->method('getStore')
diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/Product/Flat/IndexerTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/Product/Flat/IndexerTest.php
index 040a3538d069b..b37b4946bc142 100644
--- a/app/code/Magento/Catalog/Test/Unit/Helper/Product/Flat/IndexerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Helper/Product/Flat/IndexerTest.php
@@ -3,79 +3,96 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Helper\Product\Flat;
+use Magento\Catalog\Helper\Product\Flat\Indexer;
+use Magento\Catalog\Model\ResourceModel\ConfigFactory;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\AttributeFactory;
+use Magento\Framework\App\Helper\Context;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Adapter\Pdo\Mysql;
+use Magento\Framework\Mview\View\Changelog;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class IndexerTest extends \PHPUnit\Framework\TestCase
+class IndexerTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $_objectManager;
/**
- * @var \Magento\Catalog\Helper\Product\Flat\Indexer
+ * @var Indexer
*/
protected $_model;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $_storeManagerMock;
/**
- * @var Resource|\PHPUnit_Framework_MockObject_MockObject
+ * @var Resource|MockObject
*/
protected $_resourceMock;
/**
- * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
protected $_connectionMock;
/**
- * @var \Magento\Framework\Mview\View\Changelog|\PHPUnit_Framework_MockObject_MockObject
+ * @var Changelog|MockObject
*/
protected $_changelogMock;
- protected function setUp()
+ protected function setUp(): void
{
- $contextMock = $this->createMock(\Magento\Framework\App\Helper\Context::class);
+ $contextMock = $this->createMock(Context::class);
- $this->_resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
+ $this->_resourceMock = $this->createMock(ResourceConnection::class);
$this->_resourceMock->expects($this->any())->method('getTableName')->will($this->returnArgument(0));
$flatHelperMock = $this->createPartialMock(
- \Magento\Catalog\Helper\Product\Flat\Indexer::class,
+ Indexer::class,
['isAddChildData']
);
$flatHelperMock->expects($this->any())->method('isAddChildData')->will($this->returnValue(true));
- $eavConfigMock = $this->createMock(\Magento\Eav\Model\Config::class);
+ $eavConfigMock = $this->createMock(Config::class);
$attributeConfigMock = $this->createMock(\Magento\Catalog\Model\Attribute\Config::class);
$resourceConfigFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\ConfigFactory::class,
+ ConfigFactory::class,
['create']
);
- $eavFactoryMock = $this->createPartialMock(\Magento\Eav\Model\Entity\AttributeFactory::class, ['create']);
+ $eavFactoryMock = $this->createPartialMock(AttributeFactory::class, ['create']);
- $this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->_storeManagerMock = $this->createMock(StoreManagerInterface::class);
$this->_connectionMock = $this->createPartialMock(
- \Magento\Framework\DB\Adapter\Pdo\Mysql::class,
+ Mysql::class,
['getTables', 'dropTable']
);
- $this->_changelogMock = $this->createPartialMock(\Magento\Framework\Mview\View\Changelog::class, ['getName']);
+ $this->_changelogMock = $this->createPartialMock(Changelog::class, ['getName']);
- $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->_objectManager = new ObjectManager($this);
$this->_model = $this->_objectManager->getObject(
- \Magento\Catalog\Helper\Product\Flat\Indexer::class,
+ Indexer::class,
[
'context' => $contextMock,
'resource' => $this->_resourceMock,
@@ -236,7 +253,7 @@ protected function _setStoreManagerExpectedStores(array $storeIds)
{
$stores = [];
foreach ($storeIds as $storeId) {
- $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getId', '__sleep', '__wakeup']);
+ $store = $this->createPartialMock(Store::class, ['getId', '__sleep', '__wakeup']);
$store->expects($this->once())->method('getId')->will($this->returnValue($storeId));
$stores[] = $store;
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/ProductTest.php
index 93baa2ab36c8c..ca6d67961d9a7 100644
--- a/app/code/Magento/Catalog/Test/Unit/Helper/ProductTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Helper/ProductTest.php
@@ -3,16 +3,22 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Helper;
-class ProductTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Helper\Product;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
+class ProductTest extends TestCase
{
/**
- * @var \Magento\Catalog\Helper\Product
+ * @var Product
*/
protected $_productHelper;
- protected function setUp()
+ protected function setUp(): void
{
$arguments = [
'reindexPriceIndexerData' => [
@@ -21,8 +27,8 @@ protected function setUp()
],
];
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->_productHelper = $objectManager->getObject(\Magento\Catalog\Helper\Product::class, $arguments);
+ $objectManager = new ObjectManager($this);
+ $this->_productHelper = $objectManager->getObject(Product::class, $arguments);
}
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/ConditionProcessor/ConditionBuilder/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/ConditionProcessor/ConditionBuilder/FactoryTest.php
index e29eef0bed076..d735303c8f71c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/ConditionProcessor/ConditionBuilder/FactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/ConditionProcessor/ConditionBuilder/FactoryTest.php
@@ -7,17 +7,18 @@
namespace Magento\Catalog\Test\Unit\Model\Api\SearchCriteria\CollectionProcessor\ConditionProcessor\ConditionBuilder;
-use Magento\Eav\Model\Config as EavConfig;
-use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
use Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\ConditionProcessor\ConditionBuilder\Factory;
-use Magento\Framework\Api\SearchCriteria\CollectionProcessor\ConditionProcessor\CustomConditionInterface;
-use Magento\Framework\Api\Filter;
-use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
+use Magento\Eav\Model\Config as EavConfig;
+use Magento\Framework\Api\Filter;
+use Magento\Framework\Api\SearchCriteria\CollectionProcessor\ConditionProcessor\CustomConditionInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class FactoryTest extends \PHPUnit\Framework\TestCase
+class FactoryTest extends TestCase
{
-
private $productResourceMock;
private $eavConfigMock;
@@ -28,7 +29,7 @@ class FactoryTest extends \PHPUnit\Framework\TestCase
private $conditionBuilderFactory;
- protected function setUp()
+ protected function setUp(): void
{
$this->productResourceMock = $this->getMockBuilder(ProductResource::class)
->disableOriginalConstructor()
@@ -48,7 +49,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMockForAbstractClass();
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
$this->conditionBuilderFactory = $objectManagerHelper->getObject(
Factory::class,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductCategoryFilterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductCategoryFilterTest.php
index 157c72fcedf10..316d9ad9ad005 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductCategoryFilterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductCategoryFilterTest.php
@@ -3,30 +3,34 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor;
use Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductCategoryFilter;
use Magento\Catalog\Model\ResourceModel\Product\Collection;
use Magento\Framework\Api\Filter;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ProductCategoryFilterTest extends \PHPUnit\Framework\TestCase
+class ProductCategoryFilterTest extends TestCase
{
/** @var ProductCategoryFilter */
private $model;
- protected function setUp()
+ protected function setUp(): void
{
$this->model = new ProductCategoryFilter();
}
public function testApply()
{
- /** @var Filter|\PHPUnit_Framework_MockObject_MockObject $filterMock */
+ /** @var Filter|MockObject $filterMock */
$filterMock = $this->getMockBuilder(Filter::class)
->disableOriginalConstructor()
->getMock();
- /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
+ /** @var Collection|MockObject $collectionMock */
$collectionMock = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
@@ -47,12 +51,12 @@ public function testApply()
public function testApplyWithoutCondition()
{
- /** @var Filter|\PHPUnit_Framework_MockObject_MockObject $filterMock */
+ /** @var Filter|MockObject $filterMock */
$filterMock = $this->getMockBuilder(Filter::class)
->disableOriginalConstructor()
->getMock();
- /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
+ /** @var Collection|MockObject $collectionMock */
$collectionMock = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductWebsiteFilterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductWebsiteFilterTest.php
index e0fd8b62fddd6..f1e2df67f7eed 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductWebsiteFilterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductWebsiteFilterTest.php
@@ -3,30 +3,34 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor;
use Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductWebsiteFilter;
use Magento\Catalog\Model\ResourceModel\Product\Collection;
use Magento\Framework\Api\Filter;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ProductWebsiteFilterTest extends \PHPUnit\Framework\TestCase
+class ProductWebsiteFilterTest extends TestCase
{
/** @var ProductWebsiteFilter */
private $model;
- protected function setUp()
+ protected function setUp(): void
{
$this->model = new ProductWebsiteFilter();
}
public function testApply()
{
- /** @var Filter|\PHPUnit_Framework_MockObject_MockObject $filterMock */
+ /** @var Filter|MockObject $filterMock */
$filterMock = $this->getMockBuilder(Filter::class)
->disableOriginalConstructor()
->getMock();
- /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
+ /** @var Collection|MockObject $collectionMock */
$collectionMock = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/SaveHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/SaveHandlerTest.php
index fbb96933db517..c807ea881da6e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/SaveHandlerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/SaveHandlerTest.php
@@ -7,19 +7,26 @@
namespace Magento\Catalog\Test\Unit\Model\Attribute\Backend\TierPrice;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Catalog\Model\Product\Attribute\Backend\TierPrice\SaveHandler;
-use Magento\Store\Model\StoreManagerInterface;
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
+use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
+use Magento\Catalog\Model\Product\Attribute\Backend\TierPrice\SaveHandler;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\Tierprice;
+use Magento\Customer\Api\Data\GroupInterface;
use Magento\Customer\Api\GroupManagementInterface;
+use Magento\Framework\EntityManager\EntityMetadataInterface;
use Magento\Framework\EntityManager\MetadataPool;
-use Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\Tierprice;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Unit tests for \Magento\Catalog\Model\Product\Attribute\Backend\TierPrice\SaveHandler
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class SaveHandlerTest extends \PHPUnit\Framework\TestCase
+class SaveHandlerTest extends TestCase
{
/**
* Magento\Framework\TestFramework\Unit\Helper\ObjectManager
@@ -27,39 +34,39 @@ class SaveHandlerTest extends \PHPUnit\Framework\TestCase
private $objectManager;
/**
- * @var SaveHandler|\PHPUnit_Framework_MockObject_MockObject
+ * @var SaveHandler|MockObject
*/
private $saveHandler;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManager;
/**
- * @var ProductAttributeRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductAttributeRepositoryInterface|MockObject
*/
private $attributeRepository;
/**
- * @var GroupManagementInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupManagementInterface|MockObject
*/
private $groupManagement;
/**
- * @var MetadataPool|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataPool|MockObject
*/
private $metadataPoll;
/**
- * @var Tierprice|\PHPUnit_Framework_MockObject_MockObject
+ * @var Tierprice|MockObject
*/
private $tierPriceResource;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
$this->storeManager = $this->getMockBuilder(StoreManagerInterface::class)
@@ -84,7 +91,7 @@ protected function setUp()
->getMock();
$this->saveHandler = $this->objectManager->getObject(
- \Magento\Catalog\Model\Product\Attribute\Backend\TierPrice\SaveHandler::class,
+ SaveHandler::class,
[
'storeManager' => $this->storeManager,
'attributeRepository' => $this->attributeRepository,
@@ -104,8 +111,8 @@ public function testExecute(): void
$linkField = 'entity_id';
$productId = 10;
- /** @var \PHPUnit_Framework_MockObject_MockObject $product */
- $product = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)
+ /** @var MockObject $product */
+ $product = $this->getMockBuilder(ProductInterface::class)
->disableOriginalConstructor()
->setMethods(['getData','setData', 'getStoreId'])
->getMockForAbstractClass();
@@ -117,14 +124,14 @@ public function testExecute(): void
);
$product->expects($this->atLeastOnce())->method('getStoreId')->willReturn(0);
$product->expects($this->atLeastOnce())->method('setData')->with('tier_price_changed', 1);
- $store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
+ $store = $this->getMockBuilder(StoreInterface::class)
->disableOriginalConstructor()
->setMethods(['getWebsiteId'])
->getMockForAbstractClass();
$store->expects($this->atLeastOnce())->method('getWebsiteId')->willReturn(0);
$this->storeManager->expects($this->atLeastOnce())->method('getStore')->willReturn($store);
- /** @var \PHPUnit_Framework_MockObject_MockObject $attribute */
- $attribute = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeInterface::class)
+ /** @var MockObject $attribute */
+ $attribute = $this->getMockBuilder(ProductAttributeInterface::class)
->disableOriginalConstructor()
->setMethods(['getName', 'isScopeGlobal'])
->getMockForAbstractClass();
@@ -132,15 +139,15 @@ public function testExecute(): void
$attribute->expects($this->atLeastOnce())->method('isScopeGlobal')->willReturn(true);
$this->attributeRepository->expects($this->atLeastOnce())->method('get')->with('tier_price')
->willReturn($attribute);
- $productMetadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadataInterface::class)
+ $productMetadata = $this->getMockBuilder(EntityMetadataInterface::class)
->disableOriginalConstructor()
->setMethods(['getLinkField'])
->getMockForAbstractClass();
$productMetadata->expects($this->atLeastOnce())->method('getLinkField')->willReturn($linkField);
$this->metadataPoll->expects($this->atLeastOnce())->method('getMetadata')
- ->with(\Magento\Catalog\Api\Data\ProductInterface::class)
+ ->with(ProductInterface::class)
->willReturn($productMetadata);
- $customerGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)
+ $customerGroup = $this->getMockBuilder(GroupInterface::class)
->disableOriginalConstructor()
->setMethods(['getId'])
->getMockForAbstractClass();
@@ -152,22 +159,20 @@ public function testExecute(): void
$this->assertEquals($product, $this->saveHandler->execute($product));
}
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Tier prices data should be array, but actually other type is received
- */
public function testExecuteWithException(): void
{
- /** @var \PHPUnit_Framework_MockObject_MockObject $attribute */
- $attribute = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeInterface::class)
+ $this->expectException('Magento\Framework\Exception\InputException');
+ $this->expectExceptionMessage('Tier prices data should be array, but actually other type is received');
+ /** @var MockObject $attribute */
+ $attribute = $this->getMockBuilder(ProductAttributeInterface::class)
->disableOriginalConstructor()
->setMethods(['getName', 'isScopeGlobal'])
->getMockForAbstractClass();
$attribute->expects($this->atLeastOnce())->method('getName')->willReturn('tier_price');
$this->attributeRepository->expects($this->atLeastOnce())->method('get')->with('tier_price')
->willReturn($attribute);
- /** @var \PHPUnit_Framework_MockObject_MockObject $product */
- $product = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)
+ /** @var MockObject $product */
+ $product = $this->getMockBuilder(ProductInterface::class)
->disableOriginalConstructor()
->setMethods(['getData','setData', 'getStoreId', 'getOrigData'])
->getMockForAbstractClass();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/UpdateHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/UpdateHandlerTest.php
index 8b398d3ba4d97..189239f53b8e3 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/UpdateHandlerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/UpdateHandlerTest.php
@@ -7,19 +7,27 @@
namespace Magento\Catalog\Test\Unit\Model\Attribute\Backend\TierPrice;
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
+use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
use Magento\Catalog\Model\Product\Attribute\Backend\TierPrice\UpdateHandler;
use Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\Tierprice;
+use Magento\Customer\Api\Data\GroupInterface;
use Magento\Customer\Api\GroupManagementInterface;
+use Magento\Framework\EntityManager\EntityMetadataInterface;
use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Exception\InputException;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Unit tests for \Magento\Catalog\Model\Product\Attribute\Backend\TierPrice\UpdateHandler
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class UpdateHandlerTest extends \PHPUnit\Framework\TestCase
+class UpdateHandlerTest extends TestCase
{
/**
* Magento\Framework\TestFramework\Unit\Helper\ObjectManager
@@ -27,39 +35,39 @@ class UpdateHandlerTest extends \PHPUnit\Framework\TestCase
private $objectManager;
/**
- * @var UpdateHandler|\PHPUnit_Framework_MockObject_MockObject
+ * @var UpdateHandler|MockObject
*/
private $updateHandler;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManager;
/**
- * @var ProductAttributeRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductAttributeRepositoryInterface|MockObject
*/
private $attributeRepository;
/**
- * @var GroupManagementInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupManagementInterface|MockObject
*/
private $groupManagement;
/**
- * @var MetadataPool|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataPool|MockObject
*/
private $metadataPoll;
/**
- * @var Tierprice|\PHPUnit_Framework_MockObject_MockObject
+ * @var Tierprice|MockObject
*/
private $tierPriceResource;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
$this->storeManager = $this->getMockBuilder(StoreManagerInterface::class)
@@ -84,7 +92,7 @@ protected function setUp()
->getMock();
$this->updateHandler = $this->objectManager->getObject(
- \Magento\Catalog\Model\Product\Attribute\Backend\TierPrice\UpdateHandler::class,
+ UpdateHandler::class,
[
'storeManager' => $this->storeManager,
'attributeRepository' => $this->attributeRepository,
@@ -104,7 +112,7 @@ protected function setUp()
* @param string $linkField
* @param int $productId
* @param int $originalProductId
- * @throws \Magento\Framework\Exception\InputException
+ * @throws InputException
*
* @dataProvider configDataProvider
*/
@@ -117,8 +125,8 @@ public function testExecute(
$originalProductId
): void {
- /** @var \PHPUnit_Framework_MockObject_MockObject $product */
- $product = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)
+ /** @var MockObject $product */
+ $product = $this->getMockBuilder(ProductInterface::class)
->disableOriginalConstructor()
->setMethods(['getData','setData', 'getStoreId', 'getOrigData'])
->getMockForAbstractClass();
@@ -141,14 +149,14 @@ public function testExecute(
$product->expects($this->atLeastOnce())
->method('setData')
->with('tier_price_changed', 1);
- $store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
+ $store = $this->getMockBuilder(StoreInterface::class)
->disableOriginalConstructor()
->setMethods(['getWebsiteId'])
->getMockForAbstractClass();
$store->expects($this->atLeastOnce())->method('getWebsiteId')->willReturn(0);
$this->storeManager->expects($this->atLeastOnce())->method('getStore')->willReturn($store);
- /** @var \PHPUnit_Framework_MockObject_MockObject $attribute */
- $attribute = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeInterface::class)
+ /** @var MockObject $attribute */
+ $attribute = $this->getMockBuilder(ProductAttributeInterface::class)
->disableOriginalConstructor()
->setMethods(['getName', 'isScopeGlobal'])
->getMockForAbstractClass();
@@ -156,15 +164,15 @@ public function testExecute(
$attribute->expects($this->atLeastOnce())->method('isScopeGlobal')->willReturn(true);
$this->attributeRepository->expects($this->atLeastOnce())->method('get')->with('tier_price')
->willReturn($attribute);
- $productMetadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadataInterface::class)
+ $productMetadata = $this->getMockBuilder(EntityMetadataInterface::class)
->disableOriginalConstructor()
->setMethods(['getLinkField'])
->getMockForAbstractClass();
$productMetadata->expects($this->atLeastOnce())->method('getLinkField')->willReturn($linkField);
$this->metadataPoll->expects($this->atLeastOnce())->method('getMetadata')
- ->with(\Magento\Catalog\Api\Data\ProductInterface::class)
+ ->with(ProductInterface::class)
->willReturn($productMetadata);
- $customerGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)
+ $customerGroup = $this->getMockBuilder(GroupInterface::class)
->disableOriginalConstructor()
->setMethods(['getId'])
->getMockForAbstractClass();
@@ -179,22 +187,21 @@ public function testExecute(
/**
* Verify update handle with exception.
- *
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Tier prices data should be array, but actually other type is received
*/
public function testExecuteWithException(): void
{
- /** @var \PHPUnit_Framework_MockObject_MockObject $attribute */
- $attribute = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeInterface::class)
+ $this->expectException('Magento\Framework\Exception\InputException');
+ $this->expectExceptionMessage('Tier prices data should be array, but actually other type is received');
+ /** @var MockObject $attribute */
+ $attribute = $this->getMockBuilder(ProductAttributeInterface::class)
->disableOriginalConstructor()
->setMethods(['getName', 'isScopeGlobal'])
->getMockForAbstractClass();
$attribute->expects($this->atLeastOnce())->method('getName')->willReturn('tier_price');
$this->attributeRepository->expects($this->atLeastOnce())->method('get')->with('tier_price')
->willReturn($attribute);
- /** @var \PHPUnit_Framework_MockObject_MockObject $product */
- $product = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)
+ /** @var MockObject $product */
+ $product = $this->getMockBuilder(ProductInterface::class)
->disableOriginalConstructor()
->setMethods(['getData','setData', 'getStoreId', 'getOrigData'])
->getMockForAbstractClass();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ConverterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ConverterTest.php
index 711f7d8cfa97b..bc29559b98993 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ConverterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ConverterTest.php
@@ -3,18 +3,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Attribute\Config;
-class ConverterTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Attribute\Config\Converter;
+use PHPUnit\Framework\TestCase;
+
+class ConverterTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Attribute\Config\Converter
+ * @var Converter
*/
protected $_model;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_model = new \Magento\Catalog\Model\Attribute\Config\Converter();
+ $this->_model = new Converter();
}
public function testConvert()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ReaderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ReaderTest.php
index 4097243f3c31a..d1fd5ae9b8544 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ReaderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ReaderTest.php
@@ -3,38 +3,50 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Attribute\Config;
-class ReaderTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Attribute\Config\Converter;
+use Magento\Catalog\Model\Attribute\Config\Reader;
+use Magento\Catalog\Model\Attribute\Config\SchemaLocator;
+use Magento\Framework\Config\FileResolverInterface;
+use Magento\Framework\Config\ValidationStateInterface;
+use PHPUnit\Framework\Assert;
+use PHPUnit\Framework\AssertionFailedError;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ReaderTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Attribute\Config\Reader
+ * @var Reader
*/
protected $_model;
/**
- * @var \Magento\Framework\Config\FileResolverInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var FileResolverInterface|MockObject
*/
protected $_fileResolverMock;
/**
- * @var \Magento\Catalog\Model\Attribute\Config\Converter|\PHPUnit_Framework_MockObject_MockObject
+ * @var Converter|MockObject
*/
protected $_converter;
/**
- * @var \Magento\Catalog\Model\Attribute\Config\SchemaLocator
+ * @var SchemaLocator
*/
protected $_schemaLocator;
/**
- * @var \Magento\Framework\Config\ValidationStateInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ValidationStateInterface|MockObject
*/
protected $_validationState;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_fileResolverMock = $this->createMock(\Magento\Framework\Config\FileResolverInterface::class);
+ $this->_fileResolverMock = $this->createMock(FileResolverInterface::class);
$this->_fileResolverMock->expects(
$this->once()
)->method(
@@ -52,7 +64,7 @@ protected function setUp()
);
$this->_converter = $this->createPartialMock(
- \Magento\Catalog\Model\Attribute\Config\Converter::class,
+ Converter::class,
['convert']
);
@@ -67,14 +79,14 @@ protected function setUp()
)->will(
$this->returnValue('stub')
);
- $this->_schemaLocator = new \Magento\Catalog\Model\Attribute\Config\SchemaLocator($moduleReader);
+ $this->_schemaLocator = new SchemaLocator($moduleReader);
- $this->_validationState = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class);
+ $this->_validationState = $this->createMock(ValidationStateInterface::class);
$this->_validationState->expects($this->any())
->method('isValidationRequired')
->willReturn(false);
- $this->_model = new \Magento\Catalog\Model\Attribute\Config\Reader(
+ $this->_model = new Reader(
$this->_fileResolverMock,
$this->_converter,
$this->_schemaLocator,
@@ -88,9 +100,9 @@ public function testRead()
$constraint = function (\DOMDocument $actual) {
try {
$expected = __DIR__ . '/_files/attributes_config_merged.xml';
- \PHPUnit\Framework\Assert::assertXmlStringEqualsXmlFile($expected, $actual->saveXML());
+ Assert::assertXmlStringEqualsXmlFile($expected, $actual->saveXML());
return true;
- } catch (\PHPUnit\Framework\AssertionFailedError $e) {
+ } catch (AssertionFailedError $e) {
return false;
}
};
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/SchemaLocatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/SchemaLocatorTest.php
index e7674b6488699..718c32a767bf4 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/SchemaLocatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/SchemaLocatorTest.php
@@ -3,23 +3,30 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Attribute\Config;
-class SchemaLocatorTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Attribute\Config\SchemaLocator;
+use Magento\Framework\Module\Dir\Reader;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class SchemaLocatorTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Attribute\Config\SchemaLocator
+ * @var SchemaLocator
*/
protected $_model;
/**
- * @var \Magento\Framework\Module\Dir\Reader|\PHPUnit_Framework_MockObject_MockObject
+ * @var Reader|MockObject
*/
protected $_moduleReader;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_moduleReader = $this->createPartialMock(\Magento\Framework\Module\Dir\Reader::class, ['getModuleDir']);
+ $this->_moduleReader = $this->createPartialMock(Reader::class, ['getModuleDir']);
$this->_moduleReader->expects(
$this->once()
)->method(
@@ -30,7 +37,7 @@ protected function setUp()
)->will(
$this->returnValue('fixture_dir')
);
- $this->_model = new \Magento\Catalog\Model\Attribute\Config\SchemaLocator($this->_moduleReader);
+ $this->_model = new SchemaLocator($this->_moduleReader);
}
public function testGetSchema()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php
index 779630b9559c6..55b8a3f697c3d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php
@@ -5,21 +5,28 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Attribute\Config;
-class XsdTest extends \PHPUnit\Framework\TestCase
+use Magento\Framework\Config\Dom;
+use Magento\Framework\Config\Dom\UrnResolver;
+use Magento\Framework\Config\ValidationStateInterface;
+use PHPUnit\Framework\TestCase;
+
+class XsdTest extends TestCase
{
/**
* @var string
*/
protected $_schemaFile;
- protected function setUp()
+ protected function setUp(): void
{
if (!function_exists('libxml_set_external_entity_loader')) {
$this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
}
- $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver();
+ $urnResolver = new UrnResolver();
$this->_schemaFile = $urnResolver->getRealPath('urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd');
}
@@ -30,10 +37,10 @@ protected function setUp()
*/
public function testExemplarXml($fixtureXml, array $expectedErrors)
{
- $validationStateMock = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class);
+ $validationStateMock = $this->createMock(ValidationStateInterface::class);
$validationStateMock->method('isValidationRequired')
->willReturn(true);
- $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, '%message%');
+ $dom = new Dom($fixtureXml, $validationStateMock, [], null, null, '%message%');
$actualResult = $dom->validate($this->_schemaFile, $actualErrors);
$this->assertEquals(empty($expectedErrors), $actualResult);
$this->assertEquals($expectedErrors, $actualErrors);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/_files/attributes_config_merged.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/_files/attributes_config_merged.php
index cba79ad467e37..c0e03cb2e65d6 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/_files/attributes_config_merged.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/_files/attributes_config_merged.php
@@ -3,4 +3,6 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
return ['group_one' => ['test_attribute'], 'group_two' => ['attribute_one', 'attribute_two']];
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/ConfigTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/ConfigTest.php
index a928b9048e411..88e46f3ca40b9 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/ConfigTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/ConfigTest.php
@@ -3,24 +3,31 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Attribute;
-class ConfigTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Attribute\Config;
+use Magento\Catalog\Model\Attribute\Config\Data;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ConfigTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Attribute\Config
+ * @var Config
*/
protected $_model;
/**
- * @var \Magento\Catalog\Model\Attribute\Config\Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var Data|MockObject
*/
protected $_dataStorage;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_dataStorage = $this->createPartialMock(\Magento\Catalog\Model\Attribute\Config\Data::class, ['get']);
- $this->_model = new \Magento\Catalog\Model\Attribute\Config($this->_dataStorage);
+ $this->_dataStorage = $this->createPartialMock(Data::class, ['get']);
+ $this->_model = new Config($this->_dataStorage);
}
public function testGetAttributeNames()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/LockValidatorCompositeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/LockValidatorCompositeTest.php
index 1b3c6b5e1f99d..b180c43ac2052 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/LockValidatorCompositeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/LockValidatorCompositeTest.php
@@ -4,32 +4,40 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Attribute;
-class LockValidatorCompositeTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Attribute\Backend\Startdate;
+use Magento\Catalog\Model\Attribute\LockValidatorComposite;
+use Magento\Catalog\Model\Attribute\LockValidatorInterface;
+use Magento\Catalog\Model\Product;
+use Magento\Framework\ObjectManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class LockValidatorCompositeTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Attribute\LockValidatorComposite
+ * @var LockValidatorComposite
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $objectManagerMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
+ $this->objectManagerMock = $this->createMock(ObjectManagerInterface::class);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testCompositionsWithInvalidValidatorInstance()
{
- $validators = [\Magento\Catalog\Model\Attribute\Backend\Startdate::class];
- $this->model = new \Magento\Catalog\Model\Attribute\LockValidatorComposite(
+ $this->expectException('InvalidArgumentException');
+ $validators = [Startdate::class];
+ $this->model = new LockValidatorComposite(
$this->objectManagerMock,
$validators
);
@@ -37,23 +45,23 @@ public function testCompositionsWithInvalidValidatorInstance()
public function testValidateWithValidValidatorInstance()
{
- $validators = [\Magento\Catalog\Model\Attribute\LockValidatorComposite::class];
- $lockValidatorMock = $this->createMock(\Magento\Catalog\Model\Attribute\LockValidatorInterface::class);
+ $validators = [LockValidatorComposite::class];
+ $lockValidatorMock = $this->createMock(LockValidatorInterface::class);
$this->objectManagerMock->expects(
$this->any()
)->method(
'get'
)->with(
- \Magento\Catalog\Model\Attribute\LockValidatorComposite::class
+ LockValidatorComposite::class
)->will(
$this->returnValue($lockValidatorMock)
);
- $this->model = new \Magento\Catalog\Model\Attribute\LockValidatorComposite(
+ $this->model = new LockValidatorComposite(
$this->objectManagerMock,
$validators
);
- $abstractModelHelper = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $abstractModelHelper = $this->createMock(Product::class);
$lockValidatorMock->expects($this->once())->method('validate')->with($abstractModelHelper);
$this->model->validate($abstractModelHelper);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php
index f8a89f9d9fd90..bd880e9f8607d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php
@@ -3,65 +3,75 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Category\Attribute\Backend;
+use Magento\Catalog\Model\Category\Attribute\Backend\Image;
+use Magento\Catalog\Model\ImageUploader;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
use Magento\Framework\App\Filesystem\DirectoryList;
+use Magento\Framework\DataObject;
use Magento\Framework\Exception\FileSystemException;
+use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
/**
* Test for Magento\Catalog\Model\Category\Attribute\Backend\Image class.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ImageTest extends \PHPUnit\Framework\TestCase
+class ImageTest extends TestCase
{
/**
- * @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute
+ * @var AbstractAttribute
*/
private $attribute;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManager;
/**
- * @var \Magento\Catalog\Model\ImageUploader
+ * @var ImageUploader
*/
private $imageUploader;
/**
- * @var \Psr\Log\LoggerInterface
+ * @var LoggerInterface
*/
private $logger;
/**
- * @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject
+ * @var Filesystem|MockObject
*/
private $filesystem;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject;
+ * @var StoreManagerInterface|MockObject ;
*/
private $storeManagerInterfaceMock;
/**
- * @var Store|\PHPUnit_Framework_MockObject_MockObject
+ * @var Store|MockObject
*/
private $storeMock;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
$this->attribute = $this->getMockForAbstractClass(
- \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
+ AbstractAttribute::class,
[],
'TestAttribute',
false,
@@ -71,7 +81,7 @@ protected function setUp()
);
$this->logger = $this->getMockForAbstractClass(
- \Psr\Log\LoggerInterface::class,
+ LoggerInterface::class,
[],
'TestLogger',
false,
@@ -81,7 +91,7 @@ protected function setUp()
);
$this->imageUploader = $this->createPartialMock(
- \Magento\Catalog\Model\ImageUploader::class,
+ ImageUploader::class,
['moveFileFromTmp', 'getBasePath']
);
@@ -93,7 +103,7 @@ protected function setUp()
Store::class
)->disableOriginalConstructor()->getMock();
- $this->filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class)->disableOriginalConstructor()
+ $this->filesystem = $this->getMockBuilder(Filesystem::class)->disableOriginalConstructor()
->getMock();
}
@@ -119,10 +129,10 @@ public function testBeforeSaveValueDeletion($value)
->method('getName')
->will($this->returnValue('test_attribute'));
- $model = $this->objectManager->getObject(\Magento\Catalog\Model\Category\Attribute\Backend\Image::class);
+ $model = $this->objectManager->getObject(Image::class);
$model->setAttribute($this->attribute);
- $object = new \Magento\Framework\DataObject(['test_attribute' => $value]);
+ $object = new DataObject(['test_attribute' => $value]);
$model->beforeSave($object);
@@ -158,10 +168,10 @@ public function testBeforeSaveValueInvalid($value)
->method('getName')
->will($this->returnValue('test_attribute'));
- $model = $this->objectManager->getObject(\Magento\Catalog\Model\Category\Attribute\Backend\Image::class);
+ $model = $this->objectManager->getObject(Image::class);
$model->setAttribute($this->attribute);
- $object = new \Magento\Framework\DataObject(['test_attribute' => $value]);
+ $object = new DataObject(['test_attribute' => $value]);
$model->beforeSave($object);
@@ -189,7 +199,7 @@ public function testBeforeSaveAttributeFileName()
->with('base/path/test123.jpg')
->willReturn('absolute/path/base/path/test123.jpg');
- $object = new \Magento\Framework\DataObject(
+ $object = new DataObject(
[
'test_attribute' => [
['name' => 'test123.jpg'],
@@ -220,7 +230,7 @@ public function testBeforeSaveAttributeFileNameOutsideOfCategoryDir()
->with(DirectoryList::MEDIA)
->willReturn('pub/media');
- $object = new \Magento\Framework\DataObject(
+ $object = new DataObject(
[
'test_attribute' => [
[
@@ -268,7 +278,7 @@ public function testBeforeSaveTemporaryAttribute()
$this->imageUploader->expects($this->any())->method('moveFileFromTmp')->willReturn('test123.jpg');
- $object = new \Magento\Framework\DataObject(
+ $object = new DataObject(
[
'test_attribute' => [
[
@@ -295,10 +305,10 @@ public function testBeforeSaveTemporaryAttribute()
*/
public function testBeforeSaveAttributeStringValue()
{
- $model = $this->objectManager->getObject(\Magento\Catalog\Model\Category\Attribute\Backend\Image::class);
+ $model = $this->objectManager->getObject(Image::class);
$model->setAttribute($this->attribute);
- $object = new \Magento\Framework\DataObject(['test_attribute' => 'test123.jpg']);
+ $object = new DataObject(['test_attribute' => 'test123.jpg']);
$model->beforeSave($object);
@@ -307,7 +317,7 @@ public function testBeforeSaveAttributeStringValue()
}
/**
- * @return \Magento\Catalog\Model\Category\Attribute\Backend\Image
+ * @return Image
*/
private function setUpModelForTests()
{
@@ -330,7 +340,7 @@ function ($class, $params = []) use ($imageUploaderMock) {
);
$model = $this->objectManager->getObject(
- \Magento\Catalog\Model\Category\Attribute\Backend\Image::class,
+ Image::class,
[
'objectManager' => $objectManagerMock,
'logger' => $this->logger,
@@ -370,7 +380,7 @@ public function testBeforeSaveWithAdditionalData($value)
->method('moveFileFromTmp')
->with($this->equalTo('test1234.jpg'));
- $object = new \Magento\Framework\DataObject(
+ $object = new DataObject(
[
'test_attribute' => $value,
'_additional_data_test_attribute' => [['name' => 'test1234.jpg', 'tmp_name' => 'test-test-1234']]
@@ -393,7 +403,7 @@ public function testBeforeSaveWithoutAdditionalData($value)
$this->imageUploader->expects($this->never())
->method('moveFileFromTmp');
- $object = new \Magento\Framework\DataObject(
+ $object = new DataObject(
[
'test_attribute' => $value
]
@@ -442,7 +452,7 @@ public function testBeforeSaveWithExceptions()
->method('critical')
->with($this->equalTo($exception));
- $object = new \Magento\Framework\DataObject(
+ $object = new DataObject(
[
'_additional_data_test_attribute' => [['name' => 'test1234.jpg', 'tmp_name' => 'test-test-1234']]
]
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/SortbyTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/SortbyTest.php
index 467d72a549b64..8892e46e9a922 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/SortbyTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/SortbyTest.php
@@ -3,44 +3,54 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Category\Attribute\Backend;
-class SortbyTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Category\Attribute\Backend\Sortby;
+use Magento\Eav\Model\Entity\AbstractEntity;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\DataObject;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
+class SortbyTest extends TestCase
{
const DEFAULT_ATTRIBUTE_CODE = 'attribute_name';
/**
- * @var \Magento\Catalog\Model\Category\Attribute\Backend\Sortby
+ * @var Sortby
*/
protected $_model;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $_objectHelper;
/**
- * @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute
+ * @var AbstractAttribute
*/
protected $_attribute;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface
+ * @var ScopeConfigInterface
*/
protected $_scopeConfig;
- protected function setUp()
+ protected function setUp(): void
{
$this->markTestSkipped('Due to MAGETWO-48956');
- $this->_objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->_scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $this->_objectHelper = new ObjectManager($this);
+ $this->_scopeConfig = $this->createMock(ScopeConfigInterface::class);
$this->_model = $this->_objectHelper->getObject(
- \Magento\Catalog\Model\Category\Attribute\Backend\Sortby::class,
+ Sortby::class,
['scopeConfig' => $this->_scopeConfig]
);
$this->_attribute = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
+ AbstractAttribute::class,
[
'getName',
'__call',
@@ -65,7 +75,7 @@ protected function setUp()
public function testBeforeSave($attributeCode, $data, $expected)
{
$this->_attribute->expects($this->any())->method('getName')->will($this->returnValue($attributeCode));
- $object = new \Magento\Framework\DataObject($data);
+ $object = new DataObject($data);
$this->_model->beforeSave($object);
$this->assertTrue($object->hasData($attributeCode));
$this->assertSame($expected, $object->getData($attributeCode));
@@ -114,7 +124,7 @@ public function beforeSaveDataProvider()
public function testAfterLoad($attributeCode, $data, $expected)
{
$this->_attribute->expects($this->any())->method('getName')->will($this->returnValue($attributeCode));
- $object = new \Magento\Framework\DataObject($data);
+ $object = new DataObject($data);
$this->_model->afterLoad($object);
$this->assertTrue($object->hasData($attributeCode));
$this->assertSame($expected, $object->getData($attributeCode));
@@ -161,7 +171,7 @@ public function testValidate($attributeData, $data, $expected)
->expects($this->any())
->method('isValueEmpty')
->will($this->returnValue($attributeData['isValueEmpty']));
- $object = new \Magento\Framework\DataObject($data);
+ $object = new DataObject($data);
$this->assertSame($expected, $this->_model->validate($object));
}
@@ -201,7 +211,7 @@ public function testValidateUnique()
$this->_attribute->expects($this->at(2))->method('getIsUnique')->will($this->returnValue(true));
$entityMock = $this->getMockForAbstractClass(
- \Magento\Eav\Model\Entity\AbstractEntity::class,
+ AbstractEntity::class,
[],
'',
false,
@@ -211,20 +221,18 @@ public function testValidateUnique()
);
$this->_attribute->expects($this->any())->method('getEntity')->will($this->returnValue($entityMock));
$entityMock->expects($this->at(0))->method('checkAttributeUniqueValue')->will($this->returnValue(true));
- $this->assertTrue($this->_model->validate(new \Magento\Framework\DataObject()));
+ $this->assertTrue($this->_model->validate(new DataObject()));
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- */
public function testValidateUniqueException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$this->_attribute->expects($this->any())->method('getName')->will($this->returnValue('attribute_name'));
$this->_attribute->expects($this->at(1))->method('getIsRequired');
$this->_attribute->expects($this->at(2))->method('getIsUnique')->will($this->returnValue(true));
$entityMock = $this->getMockForAbstractClass(
- \Magento\Eav\Model\Entity\AbstractEntity::class,
+ AbstractEntity::class,
[],
'',
false,
@@ -233,7 +241,7 @@ public function testValidateUniqueException()
['checkAttributeUniqueValue']
);
$frontMock = $this->getMockForAbstractClass(
- \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend::class,
+ AbstractFrontend::class,
[],
'',
false,
@@ -244,7 +252,7 @@ public function testValidateUniqueException()
$this->_attribute->expects($this->any())->method('getEntity')->will($this->returnValue($entityMock));
$this->_attribute->expects($this->any())->method('getFrontend')->will($this->returnValue($frontMock));
$entityMock->expects($this->at(0))->method('checkAttributeUniqueValue')->will($this->returnValue(false));
- $this->assertTrue($this->_model->validate(new \Magento\Framework\DataObject()));
+ $this->assertTrue($this->_model->validate(new DataObject()));
}
/**
@@ -256,7 +264,7 @@ public function testValidateDefaultSort($attributeCode, $data)
{
$this->_attribute->expects($this->any())->method('getName')->will($this->returnValue($attributeCode));
$this->_scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue('value2'));
- $object = new \Magento\Framework\DataObject($data);
+ $object = new DataObject($data);
$this->assertTrue($this->_model->validate($object));
}
@@ -296,13 +304,13 @@ public function validateDefaultSortDataProvider()
* @param $attributeCode
* @param $data
* @dataProvider validateDefaultSortException
- * @expectedException \Magento\Framework\Exception\LocalizedException
*/
public function testValidateDefaultSortException($attributeCode, $data)
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$this->_attribute->expects($this->any())->method('getName')->will($this->returnValue($attributeCode));
$this->_scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue('another value'));
- $object = new \Magento\Framework\DataObject($data);
+ $object = new DataObject($data);
$this->_model->validate($object);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/LayoutTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/LayoutTest.php
index 263aa74db774e..76c867767944d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/LayoutTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/LayoutTest.php
@@ -3,16 +3,22 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Category\Attribute\Source;
+use Magento\Catalog\Model\Category\Attribute\Source\Layout;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Model\PageLayout\Config\BuilderInterface;
+use Magento\Framework\View\PageLayout\Config;
+use PHPUnit\Framework\TestCase;
-class LayoutTest extends \PHPUnit\Framework\TestCase
+class LayoutTest extends TestCase
{
private $testArray = ['test1', ['test1']];
/**
- * @var \Magento\Catalog\Model\Category\Attribute\Source\Layout
+ * @var Layout
*/
private $model;
@@ -23,11 +29,11 @@ public function testGetAllOptions()
$this->assertEquals($assertArray, $this->model->getAllOptions());
}
- protected function setUp()
+ protected function setUp(): void
{
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Category\Attribute\Source\Layout::class,
+ Layout::class,
[
'pageLayoutBuilder' => $this->getMockedPageLayoutBuilder()
]
@@ -35,11 +41,11 @@ protected function setUp()
}
/**
- * @return \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface
+ * @return BuilderInterface
*/
private function getMockedPageLayoutBuilder()
{
- $mockPageLayoutConfig = $this->getMockBuilder(\Magento\Framework\View\PageLayout\Config::class)
+ $mockPageLayoutConfig = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
$mockPageLayoutConfig->expects($this->any())
@@ -47,7 +53,7 @@ private function getMockedPageLayoutBuilder()
->will($this->returnValue($this->testArray));
$mockPageLayoutBuilder = $this->getMockBuilder(
- \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface::class
+ BuilderInterface::class
)->disableOriginalConstructor()->getMock();
$mockPageLayoutBuilder->expects($this->once())
->method('getPageLayoutsConfig')
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/PageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/PageTest.php
index 4558f39d752c6..e638fd69db481 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/PageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/PageTest.php
@@ -3,12 +3,17 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Category\Attribute\Source;
+use Magento\Catalog\Model\Category\Attribute\Source\Page;
use Magento\Cms\Model\ResourceModel\Block\CollectionFactory;
+use Magento\Framework\Data\Collection;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class PageTest extends \PHPUnit\Framework\TestCase
+class PageTest extends TestCase
{
/**
* @var array
@@ -16,7 +21,7 @@ class PageTest extends \PHPUnit\Framework\TestCase
private $testArray = ['test1', ['test1']];
/**
- * @var \Magento\Catalog\Model\Category\Attribute\Source\Page
+ * @var Page
*/
private $model;
@@ -27,11 +32,11 @@ public function testGetAllOptions()
$this->assertEquals($assertArray, $this->model->getAllOptions());
}
- protected function setUp()
+ protected function setUp(): void
{
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Category\Attribute\Source\Page::class,
+ Page::class,
[
'blockCollectionFactory' => $this->getMockedBlockCollectionFactory()
]
@@ -39,13 +44,13 @@ protected function setUp()
}
/**
- * @return \Magento\Cms\Model\ResourceModel\Block\CollectionFactory
+ * @return CollectionFactory
*/
private function getMockedBlockCollectionFactory()
{
$mockedCollection = $this->getMockedCollection();
- $mockBuilder = $this->getMockBuilder(\Magento\Cms\Model\ResourceModel\Block\CollectionFactory::class);
+ $mockBuilder = $this->getMockBuilder(CollectionFactory::class);
$mock = $mockBuilder->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
@@ -58,11 +63,11 @@ private function getMockedBlockCollectionFactory()
}
/**
- * @return \Magento\Framework\Data\Collection
+ * @return Collection
*/
private function getMockedCollection()
{
- $mockBuilder = $this->getMockBuilder(\Magento\Framework\Data\Collection::class);
+ $mockBuilder = $this->getMockBuilder(Collection::class);
$mock = $mockBuilder->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/SortbyTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/SortbyTest.php
index 3c380a4d47a51..a52e0287ae35a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/SortbyTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Source/SortbyTest.php
@@ -3,14 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Category\Attribute\Source;
+use Magento\Catalog\Model\Category\Attribute\Source\Sortby;
+use Magento\Catalog\Model\Config;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class SortbyTest extends \PHPUnit\Framework\TestCase
+class SortbyTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Category\Attribute\Source\Sortby
+ * @var Sortby
*/
private $model;
@@ -20,11 +25,11 @@ public function testGetAllOptions()
$this->assertEquals($validResult, $this->model->getAllOptions());
}
- protected function setUp()
+ protected function setUp(): void
{
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Category\Attribute\Source\Sortby::class,
+ Sortby::class,
[
'catalogConfig' => $this->getMockedConfig()
]
@@ -32,11 +37,11 @@ protected function setUp()
}
/**
- * @return \Magento\Catalog\Model\Config
+ * @return Config
*/
private function getMockedConfig()
{
- $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Config::class);
+ $mockBuilder = $this->getMockBuilder(Config::class);
$mockBuilder->disableOriginalConstructor();
$mock = $mockBuilder->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php
index 400e45476f063..4df26c7da624c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php
@@ -4,16 +4,28 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Category;
+use Magento\Catalog\Api\Data\CategoryAttributeInterface;
use Magento\Catalog\Model\Category\AttributeRepository;
+use Magento\Eav\Api\AttributeRepositoryInterface;
+use Magento\Eav\Model\Config;
+use Magento\Framework\Api\Filter;
+use Magento\Framework\Api\FilterBuilder;
+use Magento\Framework\Api\SearchCriteria;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\Api\SearchResultsInterface;
+use Magento\Framework\DataObject;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class AttributeRepositoryTest extends \PHPUnit\Framework\TestCase
+class AttributeRepositoryTest extends TestCase
{
/**
* @var AttributeRepository
@@ -21,40 +33,40 @@ class AttributeRepositoryTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $searchBuilderMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $filterBuilderMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $attributeRepositoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $searchResultMock;
/**
- * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
protected $eavConfigMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->searchBuilderMock =
- $this->createMock(\Magento\Framework\Api\SearchCriteriaBuilder::class);
+ $this->createMock(SearchCriteriaBuilder::class);
$this->filterBuilderMock =
- $this->createMock(\Magento\Framework\Api\FilterBuilder::class);
+ $this->createMock(FilterBuilder::class);
$this->attributeRepositoryMock =
- $this->createMock(\Magento\Eav\Api\AttributeRepositoryInterface::class);
+ $this->createMock(AttributeRepositoryInterface::class);
$this->searchResultMock =
- $this->createPartialMock(\Magento\Framework\Api\SearchResultsInterface::class, [
+ $this->createPartialMock(SearchResultsInterface::class, [
'getItems',
'getSearchCriteria',
'getTotalCount',
@@ -63,11 +75,11 @@ protected function setUp()
'setTotalCount',
'__wakeup',
]);
- $this->eavConfigMock = $this->createMock(\Magento\Eav\Model\Config::class);
+ $this->eavConfigMock = $this->createMock(Config::class);
$this->eavConfigMock->expects($this->any())->method('getEntityType')
- ->willReturn(new \Magento\Framework\DataObject(['default_attribute_set_id' => 3]));
+ ->willReturn(new DataObject(['default_attribute_set_id' => 3]));
$this->model = (new ObjectManager($this))->getObject(
- \Magento\Catalog\Model\Category\AttributeRepository::class,
+ AttributeRepository::class,
[
'searchCriteriaBuilder' => $this->searchBuilderMock,
'filterBuilder' => $this->filterBuilderMock,
@@ -79,10 +91,10 @@ protected function setUp()
public function testGetList()
{
- $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteria::class);
+ $searchCriteriaMock = $this->createMock(SearchCriteria::class);
$this->attributeRepositoryMock->expects($this->once())
->method('getList')
- ->with(\Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE, $searchCriteriaMock)
+ ->with(CategoryAttributeInterface::ENTITY_TYPE_CODE, $searchCriteriaMock)
->willReturn($this->searchResultMock);
$this->model->getList($searchCriteriaMock);
@@ -92,10 +104,10 @@ public function testGet()
{
$attributeCode = 'some Attribute Code';
$dataInterfaceMock =
- $this->createMock(\Magento\Catalog\Api\Data\CategoryAttributeInterface::class);
+ $this->createMock(CategoryAttributeInterface::class);
$this->attributeRepositoryMock->expects($this->once())
->method('get')
- ->with(\Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE, $attributeCode)
+ ->with(CategoryAttributeInterface::ENTITY_TYPE_CODE, $attributeCode)
->willReturn($dataInterfaceMock);
$this->model->get($attributeCode);
@@ -103,7 +115,7 @@ public function testGet()
public function testGetCustomAttributesMetadata()
{
- $filterMock = $this->createMock(\Magento\Framework\Api\Filter::class);
+ $filterMock = $this->createMock(Filter::class);
$this->filterBuilderMock->expects($this->once())->method('setField')
->with('attribute_set_id')->willReturnSelf();
$this->filterBuilderMock->expects($this->once())->method('setValue')->with(
@@ -111,11 +123,11 @@ public function testGetCustomAttributesMetadata()
)->willReturnSelf();
$this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock);
$this->searchBuilderMock->expects($this->once())->method('addFilters')->with([$filterMock])->willReturnSelf();
- $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteria::class);
+ $searchCriteriaMock = $this->createMock(SearchCriteria::class);
$this->searchBuilderMock->expects($this->once())->method('create')->willReturn($searchCriteriaMock);
- $itemMock = $this->createMock(\Magento\Framework\DataObject::class);
+ $itemMock = $this->createMock(DataObject::class);
$this->attributeRepositoryMock->expects($this->once())->method('getList')->with(
- \Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE,
+ CategoryAttributeInterface::ENTITY_TYPE_CODE,
$searchCriteriaMock
)->willReturn($this->searchResultMock);
$this->searchResultMock->expects($this->once())->method('getItems')->willReturn([$itemMock]);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/DataProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/DataProviderTest.php
index ce131a1953bfd..71105c586f5ed 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/DataProviderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/DataProviderTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Category;
@@ -107,7 +108,7 @@ class DataProviderTest extends TestCase
/**
* @inheritDoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->eavValidationRules = $this->getMockBuilder(EavValidationRules::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/FileInfoTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/FileInfoTest.php
index 6977a9ad1c7cc..53828bb96ba7b 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/FileInfoTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/FileInfoTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Category;
use Magento\Catalog\Model\Category\FileInfo;
@@ -11,10 +13,10 @@
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\ReadInterface;
use Magento\Framework\Filesystem\Directory\WriteInterface;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
-use Magento\Store\Model\StoreManagerInterface;
-use Magento\Store\Model\Store;
/**
* Test for Magento\Catalog\Model\Category\FileInfo class.
@@ -61,7 +63,7 @@ class FileInfoTest extends TestCase
*/
private $model;
- protected function setUp()
+ protected function setUp(): void
{
$this->mediaDirectory = $this->getMockBuilder(WriteInterface::class)
->getMockForAbstractClass();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/ImageTest.php
index 7cf63a56283f2..42a3031ae27e0 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/ImageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/ImageTest.php
@@ -38,7 +38,7 @@ class ImageTest extends TestCase
/**
* @inheritDoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$storeManager = $this->createPartialMock(StoreManager::class, ['getStore']);
$this->store = $this->createPartialMock(Store::class, ['getBaseUrl']);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Link/ReadHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Link/ReadHandlerTest.php
index 5879c38cada9e..600319aaf8773 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Link/ReadHandlerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Link/ReadHandlerTest.php
@@ -3,21 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Category\Link;
use Magento\Catalog\Api\Data\CategoryLinkInterface;
use Magento\Catalog\Api\Data\CategoryLinkInterfaceFactory;
use Magento\Catalog\Api\Data\ProductExtensionInterface;
use Magento\Catalog\Model\Category\Link\ReadHandler;
+use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Product\CategoryLink;
use Magento\Framework\Api\DataObjectHelper;
-use Magento\Catalog\Model\Product;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class ReadHandlerTest
- */
-class ReadHandlerTest extends \PHPUnit\Framework\TestCase
+class ReadHandlerTest extends TestCase
{
/**
* @var ReadHandler
@@ -42,7 +42,7 @@ class ReadHandlerTest extends \PHPUnit\Framework\TestCase
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->categoryLinkFactory = $this->getMockBuilder(CategoryLinkInterfaceFactory::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Link/SaveHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Link/SaveHandlerTest.php
index 0b85ef38387fa..60611e753394b 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Link/SaveHandlerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Link/SaveHandlerTest.php
@@ -3,21 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Category\Link;
use Magento\Catalog\Api\Data\CategoryLinkInterface;
+use Magento\Catalog\Api\Data\ProductExtensionInterface;
use Magento\Catalog\Model\Category\Link\SaveHandler;
+use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Product\CategoryLink;
use Magento\Framework\EntityManager\HydratorInterface;
use Magento\Framework\EntityManager\HydratorPool;
-use Magento\Catalog\Model\Product;
-use Magento\Framework\Indexer\IndexerRegistry;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class SaveHandlerTest
- */
-class SaveHandlerTest extends \PHPUnit\Framework\TestCase
+class SaveHandlerTest extends TestCase
{
/**
* @var SaveHandler
@@ -42,7 +42,7 @@ class SaveHandlerTest extends \PHPUnit\Framework\TestCase
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->productCategoryLink = $this->getMockBuilder(CategoryLink::class)
->disableOriginalConstructor()
@@ -79,7 +79,7 @@ public function testExecute($categoryIds, $categoryLinks, $existCategoryLinks, $
->willReturn($this->hydrator);
}
- $extensionAttributes = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductExtensionInterface::class)
+ $extensionAttributes = $this->getMockBuilder(ProductExtensionInterface::class)
->disableOriginalConstructor()
->setMethods(['setCategoryLinks', 'getCategoryLinks'])
->getMockForAbstractClass();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Product/PositionResolverTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Product/PositionResolverTest.php
index 7ad8b1a0ab3f8..bab89d690fa2b 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Product/PositionResolverTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Product/PositionResolverTest.php
@@ -7,32 +7,34 @@
namespace Magento\Catalog\Test\Unit\Model\Category\Product;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Catalog\Model\Category\Product\PositionResolver;
-use Magento\Framework\Model\ResourceModel\Db\Context;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Select;
+use Magento\Framework\Model\ResourceModel\Db\Context;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class PositionResolverTest extends \PHPUnit\Framework\TestCase
+class PositionResolverTest extends TestCase
{
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $context;
/**
- * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resources;
/**
- * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $connection;
/**
- * @var Select|\PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
private $select;
@@ -64,7 +66,7 @@ class PositionResolverTest extends \PHPUnit\Framework\TestCase
*/
private $categoryId = 1;
- protected function setUp()
+ protected function setUp(): void
{
$this->context = $this->getMockBuilder(Context::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/TreeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/TreeTest.php
index 97c098ba0ff2e..7858d179e96b5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Category/TreeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/TreeTest.php
@@ -3,33 +3,50 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Category;
-class TreeTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Api\Data\CategoryTreeInterface;
+use Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\ResourceModel\Category\Collection;
+use Magento\Catalog\Model\ResourceModel\Category\Tree;
+use Magento\Catalog\Model\ResourceModel\Category\TreeFactory;
+use Magento\Framework\Data\Tree\Node;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
+class TreeTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Catalog\Model\ResourceModel\Category\Tree
+ * @var MockObject|Tree
*/
protected $categoryTreeMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManagerInterface
+ * @var MockObject|StoreManagerInterface
*/
protected $storeManagerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Catalog\Model\ResourceModel\Category\Collection
+ * @var MockObject|Collection
*/
protected $categoryCollection;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory
+ * @var MockObject|CategoryTreeInterfaceFactory
*/
protected $treeFactoryMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManager;
@@ -44,35 +61,35 @@ class TreeTest extends \PHPUnit\Framework\TestCase
protected $node;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Category\TreeFactory
+ * @var TreeFactory
*/
private $treeResourceFactoryMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
$this->categoryTreeMock = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Category\Tree::class
+ Tree::class
)->disableOriginalConstructor()->getMock();
$this->categoryCollection = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Category\Collection::class
+ Collection::class
)->disableOriginalConstructor()->getMock();
$this->storeManagerMock = $this->getMockBuilder(
- \Magento\Store\Model\StoreManagerInterface::class
+ StoreManagerInterface::class
)->disableOriginalConstructor()->getMock();
$this->treeResourceFactoryMock = $this->createMock(
- \Magento\Catalog\Model\ResourceModel\Category\TreeFactory::class
+ TreeFactory::class
);
$this->treeResourceFactoryMock->method('create')
->willReturn($this->categoryTreeMock);
$methods = ['create'];
$this->treeFactoryMock =
- $this->createPartialMock(\Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory::class, $methods);
+ $this->createPartialMock(CategoryTreeInterfaceFactory::class, $methods);
$this->tree = $this->objectManager
->getObject(
@@ -90,12 +107,12 @@ protected function setUp()
public function testGetNode()
{
$category = $this->getMockBuilder(
- \Magento\Catalog\Model\Category::class
+ Category::class
)->disableOriginalConstructor()->getMock();
$category->expects($this->exactly(2))->method('getId')->will($this->returnValue(1));
$node = $this->getMockBuilder(
- \Magento\Framework\Data\Tree\Node::class
+ Node::class
)->disableOriginalConstructor()->getMock();
$node->expects($this->once())->method('loadChildren');
@@ -103,7 +120,7 @@ public function testGetNode()
->with($this->equalTo(1))
->will($this->returnValue($node));
- $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock();
+ $store = $this->getMockBuilder(Store::class)->disableOriginalConstructor()->getMock();
$store->expects($this->once())->method('getId')->will($this->returnValue(1));
$this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($store));
@@ -119,7 +136,7 @@ public function testGetNode()
public function testGetRootNode()
{
- $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock();
+ $store = $this->getMockBuilder(Store::class)->disableOriginalConstructor()->getMock();
$store->expects($this->once())->method('getRootCategoryId')->will($this->returnValue(2));
$store->expects($this->once())->method('getId')->will($this->returnValue(1));
$this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($store));
@@ -130,7 +147,7 @@ public function testGetRootNode()
$this->categoryCollection->expects($this->once())->method('setStoreId')->will($this->returnSelf());
$node = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Category\Tree::class
+ Tree::class
)->disableOriginalConstructor()
->getMock();
$node->expects($this->once())->method('addCollectionData')
@@ -147,7 +164,7 @@ public function testGetTree()
$depth = 2;
$currentLevel = 1;
- $treeNodeMock1 = $this->createMock(\Magento\Catalog\Api\Data\CategoryTreeInterface::class);
+ $treeNodeMock1 = $this->createMock(CategoryTreeInterface::class);
$treeNodeMock1->expects($this->once())->method('setId')->with($this->equalTo($currentLevel))
->will($this->returnSelf());
$treeNodeMock1->expects($this->once())->method('setParentId')->with($this->equalTo($currentLevel - 1))
@@ -164,7 +181,7 @@ public function testGetTree()
->will($this->returnSelf());
$treeNodeMock1->expects($this->once())->method('setChildrenData')->will($this->returnSelf());
- $treeNodeMock2 = $this->createMock(\Magento\Catalog\Api\Data\CategoryTreeInterface::class);
+ $treeNodeMock2 = $this->createMock(CategoryTreeInterface::class);
$treeNodeMock2->expects($this->once())->method('setId')->with($this->equalTo($currentLevel))
->will($this->returnSelf());
$treeNodeMock2->expects($this->once())->method('setParentId')->with($this->equalTo($currentLevel - 1))
@@ -184,7 +201,7 @@ public function testGetTree()
$this->treeFactoryMock->expects($this->exactly(2))
->method('create')
->will($this->onConsecutiveCalls($treeNodeMock1, $treeNodeMock2));
- $node = $this->getMockBuilder(\Magento\Framework\Data\Tree\Node::class)->disableOriginalConstructor()
+ $node = $this->getMockBuilder(Node::class)->disableOriginalConstructor()
->setMethods(
[
'hasChildren',
@@ -215,7 +232,7 @@ public function testGetTree()
public function testGetTreeWhenChildrenAreNotExist()
{
$currentLevel = 1;
- $treeNodeMock = $this->createMock(\Magento\Catalog\Api\Data\CategoryTreeInterface::class);
+ $treeNodeMock = $this->createMock(CategoryTreeInterface::class);
$this->treeFactoryMock->expects($this->any())->method('create')->will($this->returnValue($treeNodeMock));
$treeNodeMock->expects($this->once())->method('setId')->with($this->equalTo($currentLevel))
->will($this->returnSelf());
@@ -233,7 +250,7 @@ public function testGetTreeWhenChildrenAreNotExist()
->will($this->returnSelf());
$treeNodeMock->expects($this->once())->method('setChildrenData')->will($this->returnSelf());
- $node = $this->getMockBuilder(\Magento\Framework\Data\Tree\Node::class)->disableOriginalConstructor()
+ $node = $this->getMockBuilder(Node::class)->disableOriginalConstructor()
->setMethods(
[
'hasChildren',
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkManagementTest.php
index df471e1b573f2..276d14640d9ba 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkManagementTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkManagementTest.php
@@ -3,42 +3,58 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model;
-class CategoryLinkManagementTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Api\CategoryLinkRepositoryInterface;
+use Magento\Catalog\Api\Data\CategoryProductLinkInterface;
+use Magento\Catalog\Api\Data\CategoryProductLinkInterfaceFactory;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\CategoryLinkManagement;
+use Magento\Catalog\Model\CategoryRepository;
+use Magento\Catalog\Model\ResourceModel\Product;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Framework\Indexer\IndexerRegistry;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
+class CategoryLinkManagementTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\CategoryLinkManagement
+ * @var CategoryLinkManagement
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $categoryRepositoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productLinkFactoryMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->categoryRepositoryMock = $this->createMock(\Magento\Catalog\Model\CategoryRepository::class);
- $productResource = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product::class);
- $categoryLinkRepository = $this->getMockBuilder(\Magento\Catalog\Api\CategoryLinkRepositoryInterface::class)
+ $this->categoryRepositoryMock = $this->createMock(CategoryRepository::class);
+ $productResource = $this->createMock(Product::class);
+ $categoryLinkRepository = $this->getMockBuilder(CategoryLinkRepositoryInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $indexerRegistry = $this->getMockBuilder(\Magento\Framework\Indexer\IndexerRegistry::class)
+ $indexerRegistry = $this->getMockBuilder(IndexerRegistry::class)
->disableOriginalConstructor()
->getMock();
$this->productLinkFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Api\Data\CategoryProductLinkInterfaceFactory::class,
+ CategoryProductLinkInterfaceFactory::class,
['create']
);
- $this->model = new \Magento\Catalog\Model\CategoryLinkManagement(
+ $this->model = new CategoryLinkManagement(
$this->categoryRepositoryMock,
$this->productLinkFactoryMock
);
@@ -57,13 +73,13 @@ public function testGetAssignedProducts()
$productId = 55;
$position = 25;
$productSku = 'testSku';
- $categoryProductLinkMock = $this->createMock(\Magento\Catalog\Api\Data\CategoryProductLinkInterface::class);
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryProductLinkMock = $this->createMock(CategoryProductLinkInterface::class);
+ $categoryMock = $this->createMock(Category::class);
$productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
$productMock->expects($this->once())->method('getSku')->willReturn($productSku);
$productMock->expects($this->once())->method('getData')->with('cat_index_position')->willReturn($position);
$items = [$productId => $productMock];
- $productsMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
+ $productsMock = $this->createMock(Collection::class);
$this->categoryRepositoryMock->expects($this->once())->method('get')->with($categoryId)
->willReturn($categoryMock);
$categoryMock->expects($this->once())->method('getProductCollection')->willReturn($productsMock);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkRepositoryTest.php
index 909b952078b58..45313a5968883 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkRepositoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkRepositoryTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model;
@@ -15,14 +16,15 @@
use Magento\Catalog\Model\ResourceModel\Product;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\InputException;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test for \Magento\Catalog\Model\CategoryLinkRepository
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CategoryLinkRepositoryTest extends \PHPUnit\Framework\TestCase
+class CategoryLinkRepositoryTest extends TestCase
{
/**
* @var CategoryLinkRepository
@@ -52,7 +54,7 @@ class CategoryLinkRepositoryTest extends \PHPUnit\Framework\TestCase
/**
* Initialize required data
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->productResourceMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryListTest.php
index c7821f06985bc..2cae8b0ff9c33 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryListTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryListTest.php
@@ -10,20 +10,23 @@
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Api\Data\CategorySearchResultsInterface;
+use Magento\Catalog\Api\Data\CategorySearchResultsInterfaceFactory;
use Magento\Catalog\Model\Category;
use Magento\Catalog\Model\CategoryList;
use Magento\Catalog\Model\ResourceModel\Category\Collection;
+use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
-use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
-use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
+use Magento\Framework\Api\SearchCriteriaInterface;
+use Magento\Framework\DataObject;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Catalog\Api\Data\CategorySearchResultsInterfaceFactory;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CategoryListTest extends \PHPUnit\Framework\TestCase
+class CategoryListTest extends TestCase
{
/**
* @var CategoryList
@@ -31,34 +34,34 @@ class CategoryListTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
private $categoryCollectionFactory;
/**
- * @var JoinProcessorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var JoinProcessorInterface|MockObject
*/
private $extensionAttributesJoinProcessor;
/**
- * @var CategorySearchResultsInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategorySearchResultsInterfaceFactory|MockObject
*/
private $categorySearchResultsFactory;
/**
- * @var CategoryRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryRepositoryInterface|MockObject
*/
private $categoryRepository;
/**
- * @var CollectionProcessorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionProcessorInterface|MockObject
*/
private $collectionProcessorMock;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->categoryCollectionFactory = $this->getMockBuilder(CollectionFactory::class)
->disableOriginalConstructor()
@@ -94,7 +97,7 @@ public function testGetList()
$categoryFirst = $this->getMockBuilder(Category::class)->disableOriginalConstructor()->getMock();
$categorySecond = $this->getMockBuilder(Category::class)->disableOriginalConstructor()->getMock();
- /** @var SearchCriteriaInterface|\PHPUnit_Framework_MockObject_MockObject $searchCriteria */
+ /** @var SearchCriteriaInterface|MockObject $searchCriteria */
$searchCriteria = $this->createMock(SearchCriteriaInterface::class);
$collection = $this->getMockBuilder(Collection::class)->disableOriginalConstructor()->getMock();
@@ -103,7 +106,7 @@ public function testGetList()
[['entity_id' => $categoryIdFirst], ['entity_id' => $categoryIdSecond]]
);
$collection->expects($this->any())->method('getEntity')->willReturn(
- new \Magento\Framework\DataObject(['id_field_name' => 'entity_id'])
+ new DataObject(['id_field_name' => 'entity_id'])
);
$this->collectionProcessorMock->expects($this->once())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryManagementTest.php
index 2e9f2f03ecbde..c0b16e8bb8467 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryManagementTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryManagementTest.php
@@ -3,57 +3,77 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model;
-class CategoryManagementTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Api\CategoryRepositoryInterface;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Category\Tree;
+use Magento\Catalog\Model\CategoryManagement;
+use Magento\Catalog\Model\ResourceModel\Category\Collection;
+use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
+use Magento\Framework\App\ScopeInterface;
+use Magento\Framework\App\ScopeResolverInterface;
+use Magento\Framework\Data\Tree\Node;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Store;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
+class CategoryManagementTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\CategoryManagement
+ * @var CategoryManagement
*/
protected $model;
/**
- * @var \Magento\Catalog\Api\CategoryRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryRepositoryInterface|MockObject
*/
protected $categoryRepositoryMock;
/**
- * @var \Magento\Catalog\Model\Category\Tree|\PHPUnit_Framework_MockObject_MockObject
+ * @var Tree|MockObject
*/
protected $categoryTreeMock;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
protected $categoriesFactoryMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManagerHelper;
/**
- * @var \Magento\Framework\App\ScopeResolverInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeResolverInterface|MockObject
*/
protected $scopeResolverMock;
/**
- * @var \Magento\Framework\App\ScopeInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeInterface|MockObject
*/
protected $scopeMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->categoryRepositoryMock = $this->createMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class);
- $this->categoryTreeMock = $this->createMock(\Magento\Catalog\Model\Category\Tree::class);
+ $this->objectManagerHelper = new ObjectManager($this);
+ $this->categoryRepositoryMock = $this->createMock(CategoryRepositoryInterface::class);
+ $this->categoryTreeMock = $this->createMock(Tree::class);
$this->categoriesFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class,
+ CollectionFactory::class,
['create', 'addFilter', 'getFirstItem']
);
$this->model = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Model\CategoryManagement::class,
+ CategoryManagement::class,
[
'categoryRepository' => $this->categoryRepositoryMock,
'categoryTree' => $this->categoryTreeMock,
@@ -61,9 +81,9 @@ protected function setUp()
]
);
- $this->scopeResolverMock = $this->createMock(\Magento\Framework\App\ScopeResolverInterface::class);
+ $this->scopeResolverMock = $this->createMock(ScopeResolverInterface::class);
- $this->scopeMock = $this->createMock(\Magento\Framework\App\ScopeInterface::class);
+ $this->scopeMock = $this->createMock(ScopeInterface::class);
$this->objectManagerHelper->setBackwardCompatibleProperty(
$this->model,
@@ -76,8 +96,8 @@ public function testGetTree()
{
$rootCategoryId = 1;
$depth = 2;
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
- $nodeMock = $this->createMock(\Magento\Framework\Data\Tree\Node::class);
+ $categoryMock = $this->createMock(Category::class);
+ $nodeMock = $this->createMock(Node::class);
$this->categoryRepositoryMock
->expects($this->once())
@@ -132,8 +152,8 @@ public function testGetTreeWithNullArguments()
public function testGetTreeForAllScope()
{
$depth = null;
- $categoriesMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
- $categoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $categoriesMock = $this->createMock(Collection::class);
+ $categoryMock = $this->getMockBuilder(Category::class)
->setMockClassName('categoryMock')
->disableOriginalConstructor()
->getMock();
@@ -150,7 +170,7 @@ public function testGetTreeForAllScope()
->expects($this->once())
->method('create')
->willReturn($categoriesMock);
- $nodeMock = $this->createMock(\Magento\Framework\Data\Tree\Node::class);
+ $nodeMock = $this->createMock(Node::class);
$this->categoryTreeMock
->expects($this->once())
@@ -173,7 +193,7 @@ public function testGetTreeForAllScope()
$this->scopeMock
->expects($this->once())
->method('getCode')
- ->willReturn(\Magento\Store\Model\Store::ADMIN_CODE);
+ ->willReturn(Store::ADMIN_CODE);
$this->model->getTree();
}
@@ -183,11 +203,11 @@ public function testMove()
$categoryId = 2;
$parentId = 1;
$afterId = null;
- $categoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $categoryMock = $this->getMockBuilder(Category::class)
->setMockClassName('categoryMock')
->disableOriginalConstructor()
->getMock();
- $parentCategoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $parentCategoryMock = $this->getMockBuilder(Category::class)
->setMockClassName('parentCategoryMock')
->disableOriginalConstructor()
->getMock();
@@ -209,20 +229,18 @@ public function testMove()
$this->assertTrue($this->model->move($categoryId, $parentId, $afterId));
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Operation do not allow to move a parent category to any of children category
- */
public function testMoveWithException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('Operation do not allow to move a parent category to any of children category');
$categoryId = 2;
$parentId = 1;
$afterId = null;
- $categoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $categoryMock = $this->getMockBuilder(Category::class)
->setMockClassName('categoryMock')
->disableOriginalConstructor()
->getMock();
- $parentCategoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $parentCategoryMock = $this->getMockBuilder(Category::class)
->setMockClassName('parentCategoryMock')
->disableOriginalConstructor()
->getMock();
@@ -241,20 +259,18 @@ public function testMoveWithException()
$this->model->move($categoryId, $parentId, $afterId);
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Could not move category
- */
public function testMoveWithCouldNotMoveException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('Could not move category');
$categoryId = 2;
$parentId = 1;
$afterId = null;
- $categoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $categoryMock = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->setMockClassName('categoryMock')
->getMock();
- $parentCategoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $parentCategoryMock = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->setMockClassName('parentCategoryMock')
->getMock();
@@ -271,13 +287,13 @@ public function testMoveWithCouldNotMoveException()
$categoryMock->expects($this->once())
->method('move')
->with($parentId, $afterId)
- ->willThrowException(new \Magento\Framework\Exception\LocalizedException(__('message')));
+ ->willThrowException(new LocalizedException(__('message')));
$this->model->move($categoryId, $parentId, $afterId);
}
public function testGetCount()
{
- $categoriesMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
+ $categoriesMock = $this->createMock(Collection::class);
$this->categoriesFactoryMock
->expects($this->once())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php
index 3799e6e5fa4aa..1c5ebaedb9dae 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php
@@ -3,16 +3,30 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model;
-use Magento\Catalog\Model\Category;
+use Magento\Catalog\Api\Data\CategoryInterface;
+use Magento\Catalog\Model\Category as CategoryModel;
+use Magento\Catalog\Model\CategoryFactory;
use Magento\Catalog\Model\CategoryRepository;
+use Magento\Framework\Api\ExtensibleDataObjectConverter;
+use Magento\Framework\DataObject;
+use Magento\Framework\EntityManager\EntityMetadata;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Exception\CouldNotSaveException;
+use Magento\Framework\Exception\StateException;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CategoryRepositoryTest extends \PHPUnit\Framework\TestCase
+class CategoryRepositoryTest extends TestCase
{
/**
* @var CategoryRepository
@@ -20,64 +34,64 @@ class CategoryRepositoryTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $categoryFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $categoryResourceMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $extensibleDataObjectConverterMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $storeMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $storeManagerMock;
/**
- * @var \Magento\Framework\EntityManager\MetadataPool|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataPool|MockObject
*/
protected $metadataPoolMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->categoryFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\CategoryFactory::class,
+ CategoryFactory::class,
['create']
);
$this->categoryResourceMock =
$this->createMock(\Magento\Catalog\Model\ResourceModel\Category::class);
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
+ $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $this->storeMock = $this->getMockBuilder(StoreInterface::class)
->disableOriginalConstructor()
->setMethods(['getId'])
->getMockForAbstractClass();
$this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
$this->extensibleDataObjectConverterMock = $this
- ->getMockBuilder(\Magento\Framework\Api\ExtensibleDataObjectConverter::class)
+ ->getMockBuilder(ExtensibleDataObjectConverter::class)
->setMethods(['toNestedArray'])
->disableOriginalConstructor()
->getMock();
- $metadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class);
+ $metadataMock = $this->createMock(EntityMetadata::class);
$metadataMock->expects($this->any())
->method('getLinkField')
->willReturn('entity_id');
- $this->metadataPoolMock = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class);
+ $this->metadataPoolMock = $this->createMock(MetadataPool::class);
$this->metadataPoolMock->expects($this->any())
->method('getMetadata')
- ->with(\Magento\Catalog\Api\Data\CategoryInterface::class)
+ ->with(CategoryInterface::class)
->willReturn($metadataMock);
$this->model = (new ObjectManager($this))->getObject(
@@ -95,7 +109,7 @@ protected function setUp()
public function testGet()
{
$categoryId = 5;
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(CategoryModel::class);
$categoryMock->expects(
$this->once()
)->method('getId')->willReturn(
@@ -115,14 +129,12 @@ public function testGet()
$this->assertEquals($categoryMock, $this->model->get($categoryId));
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage No such entity with id = 5
- */
public function testGetWhenCategoryDoesNotExist()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage('No such entity with id = 5');
$categoryId = 5;
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(CategoryModel::class);
$categoryMock->expects(
$this->once()
)->method('getId')->willReturn(null);
@@ -176,7 +188,7 @@ public function filterExtraFieldsOnUpdateCategoryDataProvider()
public function testFilterExtraFieldsOnUpdateCategory($categoryId, $categoryData, $dataForSave)
{
$this->storeMock->expects($this->any())->method('getId')->willReturn(1);
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(CategoryModel::class);
$categoryMock->expects(
$this->atLeastOnce()
)->method('getId')->willReturn($categoryId);
@@ -193,7 +205,7 @@ public function testFilterExtraFieldsOnUpdateCategory($categoryId, $categoryData
$categoryMock->expects($this->once())->method('addData')->with($dataForSave);
$this->categoryResourceMock->expects($this->once())
->method('save')
- ->willReturn(\Magento\Framework\DataObject::class);
+ ->willReturn(DataObject::class);
$this->assertEquals($categoryMock, $this->model->save($categoryMock));
}
@@ -209,8 +221,8 @@ public function testCreateNewCategory()
->expects($this->once())
->method('toNestedArray')
->will($this->returnValue($categoryData));
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
- $parentCategoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(CategoryModel::class);
+ $parentCategoryMock = $this->createMock(CategoryModel::class);
$categoryMock->expects($this->any())->method('getId')
->will($this->onConsecutiveCalls($categoryId, $newCategoryId));
$this->categoryFactoryMock->expects($this->exactly(2))->method('create')->willReturn($parentCategoryMock);
@@ -222,18 +234,16 @@ public function testCreateNewCategory()
$categoryMock->expects($this->once())->method('validate')->willReturn(true);
$this->categoryResourceMock->expects($this->once())
->method('save')
- ->willReturn(\Magento\Framework\DataObject::class);
+ ->willReturn(DataObject::class);
$this->assertEquals($categoryMock, $this->model->save($categoryMock));
}
- /**
- * @expectedException \Magento\Framework\Exception\CouldNotSaveException
- * @expectedExceptionMessage Could not save category
- */
public function testSaveWithException()
{
+ $this->expectException('Magento\Framework\Exception\CouldNotSaveException');
+ $this->expectExceptionMessage('Could not save category');
$categoryId = 5;
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(CategoryModel::class);
$this->extensibleDataObjectConverterMock
->expects($this->once())
->method('toNestedArray')
@@ -258,12 +268,12 @@ public function testSaveWithValidateCategoryException($error, $expectedException
$this->expectException($expectedException);
$this->expectExceptionMessage($expectedExceptionMessage);
$categoryId = 5;
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(CategoryModel::class);
$this->extensibleDataObjectConverterMock
->expects($this->once())
->method('toNestedArray')
->will($this->returnValue([]));
- $objectMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getFrontend', 'getLabel']);
+ $objectMock = $this->createPartialMock(DataObject::class, ['getFrontend', 'getLabel']);
$categoryMock->expects(
$this->atLeastOnce()
)->method('getId')->willReturn($categoryId);
@@ -287,10 +297,10 @@ public function saveWithValidateCategoryExceptionDataProvider()
{
return [
[
- true, \Magento\Framework\Exception\CouldNotSaveException::class,
+ true, CouldNotSaveException::class,
'Could not save category: The "ValidateCategoryTest" attribute is required. Enter and try again.'
], [
- 'Something went wrong', \Magento\Framework\Exception\CouldNotSaveException::class,
+ 'Something went wrong', CouldNotSaveException::class,
'Could not save category: Something went wrong'
]
];
@@ -298,18 +308,18 @@ public function saveWithValidateCategoryExceptionDataProvider()
public function testDelete()
{
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(CategoryModel::class);
$this->assertTrue($this->model->delete($categoryMock));
}
/**
- * @throws \Magento\Framework\Exception\StateException
- * @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Cannot delete category with id
+ * @throws StateException
*/
public function testDeleteWithException()
{
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $this->expectException('Magento\Framework\Exception\StateException');
+ $this->expectExceptionMessage('Cannot delete category with id');
+ $categoryMock = $this->createMock(CategoryModel::class);
$this->categoryResourceMock->expects($this->once())->method('delete')->willThrowException(new \Exception());
$this->model->delete($categoryMock);
}
@@ -317,7 +327,7 @@ public function testDeleteWithException()
public function testDeleteByIdentifier()
{
$categoryId = 5;
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(CategoryModel::class);
$categoryMock->expects(
$this->any()
)->method('getId')->willReturn(
@@ -336,14 +346,12 @@ public function testDeleteByIdentifier()
$this->assertTrue($this->model->deleteByIdentifier($categoryId));
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage No such entity with id = 5
- */
public function testDeleteByIdentifierWithException()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage('No such entity with id = 5');
$categoryId = 5;
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(CategoryModel::class);
$categoryMock->expects(
$this->once()
)->method('getId')->willReturn(null);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php
index b4042d6b02c13..947bc3a0731b9 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php
@@ -3,161 +3,187 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model;
-use Magento\Catalog\Model\Indexer;
+use Magento\Catalog\Api\CategoryAttributeRepositoryInterface;
+use Magento\Catalog\Api\CategoryRepositoryInterface;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Config;
+use Magento\Catalog\Model\Indexer\Category\Flat\State;
+use Magento\Catalog\Model\Indexer\Category\Product;
+use Magento\Catalog\Model\ResourceModel\Category\Tree;
+use Magento\Catalog\Model\ResourceModel\Category\TreeFactory;
+use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator;
+use Magento\Framework\Api\AttributeValue;
+use Magento\Framework\Api\AttributeValueFactory;
+use Magento\Framework\Api\MetadataObjectInterface;
+use Magento\Framework\Filter\FilterManager;
+use Magento\Framework\Indexer\IndexerInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\Registry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\UrlInterface;
+use Magento\Store\Model\ResourceModel\Store\CollectionFactory;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManager;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\UrlRewrite\Model\UrlFinderInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CategoryTest extends \PHPUnit\Framework\TestCase
+class CategoryTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Category
+ * @var Category
*/
private $category;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
private $registry;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManager;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Category\Tree|\PHPUnit_Framework_MockObject_MockObject
+ * @var Tree|MockObject
*/
private $categoryTreeResource;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $categoryTreeFactory;
/**
- * @var \Magento\Catalog\Api\CategoryRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryRepositoryInterface|MockObject
*/
private $categoryRepository;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $storeCollectionFactory;
/**
- * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlInterface|MockObject
*/
private $url;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $productCollectionFactory;
/**
- * @var \Magento\Catalog\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $catalogConfig;
/**
- * @var \Magento\Framework\Filter\FilterManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var FilterManager|MockObject
*/
private $filterManager;
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Flat\State|\PHPUnit_Framework_MockObject_MockObject
+ * @var State|MockObject
*/
private $flatState;
/**
- * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerInterface|MockObject
*/
private $flatIndexer;
/**
- * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerInterface|MockObject
*/
private $productIndexer;
/**
- * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryUrlPathGenerator|MockObject
*/
private $categoryUrlPathGenerator;
/**
- * @var \Magento\UrlRewrite\Model\UrlFinderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlFinderInterface|MockObject
*/
private $urlFinder;
/**
- * @var \Magento\Framework\Model\ResourceModel\AbstractResource|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractResource|MockObject
*/
private $resource;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
private $indexerRegistry;
/**
- * @var \Magento\Catalog\Api\CategoryAttributeRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryAttributeRepositoryInterface|MockObject
*/
private $metadataServiceMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $attributeValueFactory;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManager;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->registry = $this->createMock(\Magento\Framework\Registry::class);
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->categoryTreeResource = $this->createMock(\Magento\Catalog\Model\ResourceModel\Category\Tree::class);
+ $this->objectManager = new ObjectManager($this);
+ $this->registry = $this->createMock(Registry::class);
+ $this->storeManager = $this->createMock(StoreManagerInterface::class);
+ $this->categoryTreeResource = $this->createMock(Tree::class);
$this->categoryTreeFactory = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Category\TreeFactory::class,
+ TreeFactory::class,
['create']
);
- $this->categoryRepository = $this->createMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class);
+ $this->categoryRepository = $this->createMock(CategoryRepositoryInterface::class);
$this->storeCollectionFactory = $this->createPartialMock(
- \Magento\Store\Model\ResourceModel\Store\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
- $this->url = $this->createMock(\Magento\Framework\UrlInterface::class);
+ $this->url = $this->createMock(UrlInterface::class);
$this->productCollectionFactory = $this->createPartialMock(
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class,
['create']
);
- $this->catalogConfig = $this->createMock(\Magento\Catalog\Model\Config::class);
+ $this->catalogConfig = $this->createMock(Config::class);
$this->filterManager = $this->createPartialMock(
- \Magento\Framework\Filter\FilterManager::class,
+ FilterManager::class,
['translitUrl']
);
- $this->flatState = $this->createMock(\Magento\Catalog\Model\Indexer\Category\Flat\State::class);
- $this->flatIndexer = $this->createMock(\Magento\Framework\Indexer\IndexerInterface::class);
- $this->productIndexer = $this->createMock(\Magento\Framework\Indexer\IndexerInterface::class);
+ $this->flatState = $this->createMock(State::class);
+ $this->flatIndexer = $this->createMock(IndexerInterface::class);
+ $this->productIndexer = $this->createMock(IndexerInterface::class);
$this->categoryUrlPathGenerator = $this->createMock(
- \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::class
+ CategoryUrlPathGenerator::class
);
- $this->urlFinder = $this->createMock(\Magento\UrlRewrite\Model\UrlFinderInterface::class);
+ $this->urlFinder = $this->createMock(UrlFinderInterface::class);
$this->resource = $this->createMock(\Magento\Catalog\Model\ResourceModel\Category::class);
- $this->indexerRegistry = $this->createPartialMock(\Magento\Framework\Indexer\IndexerRegistry::class, ['get']);
+ $this->indexerRegistry = $this->createPartialMock(IndexerRegistry::class, ['get']);
$this->metadataServiceMock = $this->createMock(
- \Magento\Catalog\Api\CategoryAttributeRepositoryInterface::class
+ CategoryAttributeRepositoryInterface::class
);
- $this->attributeValueFactory = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class)
+ $this->attributeValueFactory = $this->getMockBuilder(AttributeValueFactory::class)
->disableOriginalConstructor()->getMock();
$this->category = $this->getCategoryModel();
@@ -175,38 +201,38 @@ public function testFormatUrlKey()
}
/**
- * @expectedException \Magento\Framework\Exception\LocalizedException
* @codingStandardsIgnoreStart
- * @expectedExceptionMessage Sorry, but we can't find the new parent category you selected.
* @codingStandardsIgnoreEnd
*/
public function testMoveWhenCannotFindParentCategory()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('Sorry, but we can\'t find the new parent category you selected.');
$this->markTestIncomplete('MAGETWO-31165');
$parentCategory = $this->createPartialMock(
- \Magento\Catalog\Model\Category::class,
+ Category::class,
['getId', 'setStoreId', 'load']
);
$parentCategory->expects($this->any())->method('setStoreId')->will($this->returnSelf());
$parentCategory->expects($this->any())->method('load')->will($this->returnSelf());
$this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($parentCategory));
- $store = $this->createMock(\Magento\Store\Model\Store::class);
+ $store = $this->createMock(Store::class);
$this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
$this->category->move(1, 2);
}
/**
- * @expectedException \Magento\Framework\Exception\LocalizedException
* @codingStandardsIgnoreStart
- * @expectedExceptionMessage Sorry, but we can't find the new category you selected.
* @codingStandardsIgnoreEnd
*/
public function testMoveWhenCannotFindNewCategory()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('Sorry, but we can\'t find the new category you selected.');
$parentCategory = $this->createPartialMock(
- \Magento\Catalog\Model\Category::class,
+ Category::class,
['getId', 'setStoreId', 'load']
);
$parentCategory->expects($this->any())->method('getId')->will($this->returnValue(5));
@@ -214,23 +240,25 @@ public function testMoveWhenCannotFindNewCategory()
$parentCategory->expects($this->any())->method('load')->will($this->returnSelf());
$this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($parentCategory));
- $store = $this->createMock(\Magento\Store\Model\Store::class);
+ $store = $this->createMock(Store::class);
$this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
$this->category->move(1, 2);
}
/**
- * @expectedException \Magento\Framework\Exception\LocalizedException
* @codingStandardsIgnoreStart
- * @expectedExceptionMessage We can't move the category because the parent category name matches the child category name.
* @codingStandardsIgnoreEnd
*/
public function testMoveWhenParentCategoryIsSameAsChildCategory()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage(
+ 'We can\'t move the category because the parent category name matches the child category name.'
+ );
$this->markTestIncomplete('MAGETWO-31165');
$parentCategory = $this->createPartialMock(
- \Magento\Catalog\Model\Category::class,
+ Category::class,
['getId', 'setStoreId', 'load']
);
$parentCategory->expects($this->any())->method('getId')->will($this->returnValue(5));
@@ -238,7 +266,7 @@ public function testMoveWhenParentCategoryIsSameAsChildCategory()
$parentCategory->expects($this->any())->method('load')->will($this->returnSelf());
$this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($parentCategory));
- $store = $this->createMock(\Magento\Store\Model\Store::class);
+ $store = $this->createMock(Store::class);
$this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
$this->category->setId(5);
@@ -254,7 +282,7 @@ public function testMovePrimaryWorkflow()
->with('catalog_category_product')
->will($this->returnValue($indexer));
$parentCategory = $this->createPartialMock(
- \Magento\Catalog\Model\Category::class,
+ Category::class,
['getId', 'setStoreId', 'load']
);
$parentCategory->expects($this->any())->method('getId')->will($this->returnValue(5));
@@ -262,7 +290,7 @@ public function testMovePrimaryWorkflow()
$parentCategory->expects($this->any())->method('load')->will($this->returnSelf());
$this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($parentCategory));
- $store = $this->createMock(\Magento\Store\Model\Store::class);
+ $store = $this->createMock(Store::class);
$this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
$this->category->setId(3);
@@ -290,7 +318,7 @@ public function testGetUseFlatResourceTrue()
protected function getCategoryModel()
{
return $this->objectManager->getObject(
- \Magento\Catalog\Model\Category::class,
+ Category::class,
[
'registry' => $this->registry,
'storeManager' => $this->storeManager,
@@ -366,12 +394,12 @@ public function testReindexFlatEnabled(
$this->indexerRegistry->expects($this->at(0))
->method('get')
- ->with(Indexer\Category\Flat\State::INDEXER_ID)
+ ->with(State::INDEXER_ID)
->will($this->returnValue($this->flatIndexer));
$this->indexerRegistry->expects($this->at(1))
->method('get')
- ->with(Indexer\Category\Product::INDEXER_ID)
+ ->with(Product::INDEXER_ID)
->will($this->returnValue($this->productIndexer));
$this->category->reindex();
@@ -439,7 +467,7 @@ public function testReindexFlatDisabled(
$this->indexerRegistry->expects($this->at(0))
->method('get')
- ->with(Indexer\Category\Product::INDEXER_ID)
+ ->with(Product::INDEXER_ID)
->will($this->returnValue($this->productIndexer));
$this->category->reindex();
@@ -452,11 +480,11 @@ public function testGetCustomAttributes()
$initialCustomAttributeValue = 'initial description';
$newCustomAttributeValue = 'new description';
- $interfaceAttribute = $this->createMock(\Magento\Framework\Api\MetadataObjectInterface::class);
+ $interfaceAttribute = $this->createMock(MetadataObjectInterface::class);
$interfaceAttribute->expects($this->once())
->method('getAttributeCode')
->willReturn($interfaceAttributeCode);
- $colorAttribute = $this->createMock(\Magento\Framework\Api\MetadataObjectInterface::class);
+ $colorAttribute = $this->createMock(MetadataObjectInterface::class);
$colorAttribute->expects($this->once())
->method('getAttributeCode')
->willReturn($customAttributeCode);
@@ -472,8 +500,8 @@ public function testGetCustomAttributes()
//Set the description attribute;
$this->category->setData($customAttributeCode, $initialCustomAttributeValue);
- $attributeValue = new \Magento\Framework\Api\AttributeValue();
- $attributeValue2 = new \Magento\Framework\Api\AttributeValue();
+ $attributeValue = new AttributeValue();
+ $attributeValue2 = new AttributeValue();
$this->attributeValueFactory->expects($this->exactly(2))->method('create')
->willReturnOnConsecutiveCalls($attributeValue, $attributeValue2);
$this->assertEquals(1, count($this->category->getCustomAttributes()));
@@ -512,8 +540,8 @@ public function getImageWithAttributeCodeDataProvider()
*/
public function testGetImageWithAttributeCode($value, $url)
{
- $storeManager = $this->createPartialMock(\Magento\Store\Model\StoreManager::class, ['getStore']);
- $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getBaseUrl']);
+ $storeManager = $this->createPartialMock(StoreManager::class, ['getStore']);
+ $store = $this->createPartialMock(Store::class, ['getBaseUrl']);
$storeManager->expects($this->any())
->method('getStore')
@@ -521,12 +549,12 @@ public function testGetImageWithAttributeCode($value, $url)
$store->expects($this->any())
->method('getBaseUrl')
- ->with(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA)
+ ->with(UrlInterface::URL_TYPE_MEDIA)
->will($this->returnValue('http://www.example.com/'));
- /** @var \Magento\Catalog\Model\Category $model */
+ /** @var Category $model */
$model = $this->objectManager->getObject(
- \Magento\Catalog\Model\Category::class,
+ Category::class,
[
'storeManager' => $storeManager
]
@@ -541,8 +569,8 @@ public function testGetImageWithAttributeCode($value, $url)
public function testGetImageWithoutAttributeCode()
{
- $storeManager = $this->createPartialMock(\Magento\Store\Model\StoreManager::class, ['getStore']);
- $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getBaseUrl']);
+ $storeManager = $this->createPartialMock(StoreManager::class, ['getStore']);
+ $store = $this->createPartialMock(Store::class, ['getBaseUrl']);
$storeManager->expects($this->any())
->method('getStore')
@@ -550,11 +578,11 @@ public function testGetImageWithoutAttributeCode()
$store->expects($this->any())
->method('getBaseUrl')
- ->with(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA)
+ ->with(UrlInterface::URL_TYPE_MEDIA)
->will($this->returnValue('http://www.example.com/'));
- /** @var \Magento\Catalog\Model\Category $model */
- $model = $this->objectManager->getObject(\Magento\Catalog\Model\Category::class, [
+ /** @var Category $model */
+ $model = $this->objectManager->getObject(Category::class, [
'storeManager' => $storeManager
]);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CollectionProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CollectionProviderTest.php
index 09fbdf293ffc9..8c84d831bd68a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/CollectionProviderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/CollectionProviderTest.php
@@ -3,16 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model;
+use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ProductLink\CollectionProvider;
use Magento\Catalog\Model\ProductLink\CollectionProviderInterface;
use Magento\Catalog\Model\ProductLink\Converter\ConverterInterface;
use Magento\Catalog\Model\ProductLink\Converter\ConverterPool;
-use Magento\Catalog\Model\Product;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CollectionProviderTest extends \PHPUnit\Framework\TestCase
+class CollectionProviderTest extends TestCase
{
/**
* @var CollectionProvider
@@ -20,26 +23,26 @@ class CollectionProviderTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $converterPoolMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $providerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $productMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $converterMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->productMock = $this->createMock(Product::class);
$this->converterPoolMock = $this->createMock(ConverterPool::class);
@@ -109,12 +112,11 @@ public function testGetCollection()
/**
* Test exception when collection provider is not configured for product link type.
- *
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage The collection provider isn't registered.
*/
public function testGetCollectionWithMissingProviders()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage('The collection provider isn\'t registered.');
$this->model->getCollection($this->productMock, 'upsell');
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Config/CatalogClone/Media/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Config/CatalogClone/Media/ImageTest.php
index 23f0aec5b69a2..47736d51e8365 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Config/CatalogClone/Media/ImageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Config/CatalogClone/Media/ImageTest.php
@@ -3,66 +3,77 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Config\CatalogClone\Media;
+use Magento\Catalog\Model\Config\CatalogClone\Media\Image;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\Attribute;
use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
+use Magento\Eav\Model\Entity\Type;
+use Magento\Framework\Escaper;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Tests \Magento\Catalog\Model\Config\CatalogClone\Media\Image.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ImageTest extends \PHPUnit\Framework\TestCase
+class ImageTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Config\CatalogClone\Media\Image
+ * @var Image
*/
private $model;
/**
- * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $eavConfig;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $attributeCollectionFactory;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection|\PHPUnit_Framework_MockObject_MockObject
+ * @var Collection|MockObject
*/
private $attributeCollection;
/**
- * @var \Magento\Eav\Model\Entity\Attribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var Attribute|MockObject
*/
private $attribute;
/**
- * @var \Magento\Framework\Escaper|\PHPUnit_Framework_MockObject_MockObject
+ * @var Escaper|MockObject
*/
private $escaperMock;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->eavConfig = $this->getMockBuilder(\Magento\Eav\Model\Config::class)
+ $this->eavConfig = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
$this->attributeCollection = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class
+ Collection::class
)
->disableOriginalConstructor()
->getMock();
$this->attributeCollectionFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class
+ CollectionFactory::class
)
->setMethods(['create'])
->disableOriginalConstructor()
@@ -71,12 +82,12 @@ protected function setUp()
$this->returnValue($this->attributeCollection)
);
- $this->attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
+ $this->attribute = $this->getMockBuilder(Attribute::class)
->disableOriginalConstructor()
->getMock();
$this->escaperMock = $this->getMockBuilder(
- \Magento\Framework\Escaper::class
+ Escaper::class
)
->disableOriginalConstructor()
->setMethods(['escapeHtml'])
@@ -84,7 +95,7 @@ protected function setUp()
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Config\CatalogClone\Media\Image::class,
+ Image::class,
[
'eavConfig' => $this->eavConfig,
'attributeCollectionFactory' => $this->attributeCollectionFactory,
@@ -103,14 +114,14 @@ protected function setUp()
public function testGetPrefixes(string $actualLabel, string $expectedLabel): void
{
$entityTypeId = 3;
- /** @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject $entityType */
- $entityType = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class)
+ /** @var Type|MockObject $entityType */
+ $entityType = $this->getMockBuilder(Type::class)
->disableOriginalConstructor()
->getMock();
$entityType->expects($this->once())->method('getId')->willReturn($entityTypeId);
- /** @var AbstractFrontend|\PHPUnit_Framework_MockObject_MockObject $frontend */
- $frontend = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend::class)
+ /** @var AbstractFrontend|MockObject $frontend */
+ $frontend = $this->getMockBuilder(AbstractFrontend::class)
->setMethods(['getLabel'])
->disableOriginalConstructor()
->getMockForAbstractClass();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/CategoryTest.php
index 6978dd158783e..e2b9d339cfc7b 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/CategoryTest.php
@@ -3,12 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Config\Source;
+use Magento\Catalog\Model\ResourceModel\Category;
+use Magento\Catalog\Model\ResourceModel\Category\Collection;
+use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CategoryTest extends \PHPUnit\Framework\TestCase
+class CategoryTest extends TestCase
{
/**
* @var \Magento\Catalog\Model\Config\Source\Category
@@ -16,7 +22,7 @@ class CategoryTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Category\Collection|MockObject
+ * @var Collection|MockObject
*/
private $categoryCollection;
@@ -25,24 +31,24 @@ class CategoryTest extends \PHPUnit\Framework\TestCase
*/
private $category;
- protected function setUp()
+ protected function setUp(): void
{
$this->categoryCollection = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Category\Collection::class
+ Collection::class
)
->disableOriginalConstructor()
->getMock();
- $this->category = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category::class)
+ $this->category = $this->getMockBuilder(Category::class)
->setMethods(['getName', 'getId'])
->disableOriginalConstructor()
->getMock();
/**
- * @var \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory|MockObject $categoryCollectionFactory
+ * @var CollectionFactory|MockObject $categoryCollectionFactory
*/
$categoryCollectionFactory =
- $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class)
+ $this->getMockBuilder(CollectionFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/GridPerPageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/GridPerPageTest.php
index 496e6cf6b037c..b9e75d84fc0f0 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/GridPerPageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/GridPerPageTest.php
@@ -3,22 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Config\Source;
+use Magento\Catalog\Model\Config\Source\GridPerPage;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class GridPerPageTest extends \PHPUnit\Framework\TestCase
+class GridPerPageTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Config\Source\GridPerPage
+ * @var GridPerPage
*/
private $model;
- protected function setUp()
+ protected function setUp(): void
{
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Config\Source\GridPerPage::class,
+ GridPerPage::class,
['perPageValues' => 'some,values']
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListPerPageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListPerPageTest.php
index 99b1adf2edefa..5488dc126df84 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListPerPageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListPerPageTest.php
@@ -3,22 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Config\Source;
+use Magento\Catalog\Model\Config\Source\ListPerPage;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class ListPerPageTest extends \PHPUnit\Framework\TestCase
+class ListPerPageTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Config\Source\ListPerPage
+ * @var ListPerPage
*/
private $model;
- protected function setUp()
+ protected function setUp(): void
{
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Config\Source\ListPerPage::class,
+ ListPerPage::class,
['options' => 'some,test,options']
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListSortTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListSortTest.php
index e05315f198988..dd836e6c620b4 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListSortTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/ListSortTest.php
@@ -3,30 +3,36 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Config\Source;
+use Magento\Catalog\Model\Config;
+use Magento\Catalog\Model\Config\Source\ListSort;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ListSortTest extends \PHPUnit\Framework\TestCase
+class ListSortTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Config\Source\ListSort
+ * @var ListSort
*/
private $model;
/**
- * @var \Magento\Catalog\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $catalogConfig;
- protected function setUp()
+ protected function setUp(): void
{
- $this->catalogConfig = $this->getMockBuilder(\Magento\Catalog\Model\Config::class)
+ $this->catalogConfig = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()->getMock();
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Config\Source\ListSort::class,
+ ListSort::class,
['catalogConfig' => $this->catalogConfig]
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/Product/Options/TypeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/Product/Options/TypeTest.php
index 799a66a186eea..ac395222b5caf 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/Product/Options/TypeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Config/Source/Product/Options/TypeTest.php
@@ -3,32 +3,38 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Config\Source\Product\Options;
+use Magento\Catalog\Model\Config\Source\Product\Options\Type;
+use Magento\Catalog\Model\ProductOptions\ConfigInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class TypeTest extends \PHPUnit\Framework\TestCase
+class TypeTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Config\Source\Product\Options\Type
+ * @var Type
*/
private $model;
/**
- * @var \Magento\Catalog\Model\ProductOptions\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConfigInterface|MockObject
*/
private $productOptionConfig;
- protected function setUp()
+ protected function setUp(): void
{
- $this->productOptionConfig = $this->getMockBuilder(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class)
+ $this->productOptionConfig = $this->getMockBuilder(ConfigInterface::class)
->setMethods(['getAll'])
->disableOriginalConstructor()
->getMockForAbstractClass();
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Config\Source\Product\Options\Type::class,
+ Type::class,
['productOptionConfig' => $this->productOptionConfig]
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ConfigTest.php
index c785a4430a77a..56b0c633eba34 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ConfigTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ConfigTest.php
@@ -4,12 +4,30 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model;
+use Magento\Catalog\Model\Config;
+use Magento\Catalog\Model\Product\Type;
+use Magento\Catalog\Model\Product\TypeFactory;
+use Magento\Catalog\Model\ResourceModel\ConfigFactory;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Eav\Model\Entity\Attribute\Group;
+use Magento\Eav\Model\Entity\Attribute\Set;
+use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection;
+use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\DataObject;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\TestCase;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ConfigTest extends \PHPUnit\Framework\TestCase
+class ConfigTest extends TestCase
{
/**
* @covers \Magento\Catalog\Model\Config::loadAttributeSets
@@ -18,22 +36,22 @@ class ConfigTest extends \PHPUnit\Framework\TestCase
public function testLoadAttributeSets()
{
$setCollectionFactory = $this->createPartialMock(
- \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$model = $objectManager->getObject(
- \Magento\Catalog\Model\Config::class,
+ Config::class,
['setCollectionFactory' => $setCollectionFactory]
);
$setItem = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute\Set::class,
+ Set::class,
['getEntityTypeId', 'getAttributeSetName', '__wakeup']
);
$setItem->expects($this->once())->method('getEntityTypeId')->will($this->returnValue(1));
$setItem->expects($this->once())->method('getAttributeSetName')->will($this->returnValue('name'));
$setCollection = $this->createPartialMock(
- \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class,
+ Collection::class,
['load']
);
$setCollection->expects($this->once())->method('load')->will($this->returnValue([1 => $setItem]));
@@ -72,13 +90,13 @@ public function testLoadAttributeGroups()
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory::class,
['create']
);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$model = $objectManager->getObject(
- \Magento\Catalog\Model\Config::class,
+ Config::class,
['groupCollectionFactory' => $groupCollectionFactory]
);
$setItem = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute\Group::class,
+ Group::class,
['getAttributeSetId', 'getAttributeGroupName', '__wakeup']
);
$setItem->expects($this->once())->method('getAttributeSetId')->will($this->returnValue(1));
@@ -122,13 +140,13 @@ public function testGetAttributeGroupId($model)
*/
public function testLoadProductTypes()
{
- $productTypeFactory = $this->createPartialMock(\Magento\Catalog\Model\Product\TypeFactory::class, ['create']);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $productTypeFactory = $this->createPartialMock(TypeFactory::class, ['create']);
+ $objectManager = new ObjectManager($this);
$model = $objectManager->getObject(
- \Magento\Catalog\Model\Config::class,
+ Config::class,
['productTypeFactory' => $productTypeFactory]
);
- $typeCollection = $this->createPartialMock(\Magento\Catalog\Model\Product\Type::class, ['getOptionArray']);
+ $typeCollection = $this->createPartialMock(Type::class, ['getOptionArray']);
$typeCollection->expects($this->once())->method('getOptionArray')->will($this->returnValue([1 => 'name']));
$productTypeFactory
->expects($this->any())
@@ -168,10 +186,10 @@ public function testGetProductTypeName($model)
*/
public function testGetSourceOptionId($expected, $data, $search)
{
- $object = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getAllOptions']);
+ $object = $this->createPartialMock(DataObject::class, ['getAllOptions']);
$object->expects($this->once())->method('getAllOptions')->will($this->returnValue($data));
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $model = $objectManager->getObject(\Magento\Catalog\Model\Config::class);
+ $objectManager = new ObjectManager($this);
+ $model = $objectManager->getObject(Config::class);
$this->assertEquals($expected, $model->getSourceOptionId($object, $search));
}
@@ -200,14 +218,14 @@ protected function prepareConfigModelForAttributes()
$attributeCode = 'code';
$attribute = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
+ AbstractAttribute::class,
['getStoreLabel', 'getAttributeCode', '__wakeup']
);
$attribute->expects($this->any())->method('getStoreLabel')->will($this->returnValue($storeLabel));
$attribute->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attributeCode));
- $storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $store = $this->createMock(\Magento\Store\Model\Store::class);
+ $storeManager = $this->createMock(StoreManagerInterface::class);
+ $store = $this->createMock(Store::class);
$storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
$store->expects($this->any())->method('getId')->will($this->returnValue($storeId));
@@ -220,7 +238,7 @@ protected function prepareConfigModelForAttributes()
$config->expects($this->any())->method('getAttributesUsedForSortBy')->will($this->returnValue($attributesData));
$configFactory =
- $this->createPartialMock(\Magento\Catalog\Model\ResourceModel\ConfigFactory::class, ['create']);
+ $this->createPartialMock(ConfigFactory::class, ['create']);
$configFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($config));
$eavConfig = $this->createPartialMock(
@@ -232,9 +250,9 @@ protected function prepareConfigModelForAttributes()
$eavConfig->expects($this->once())->method('getAttribute')->with($entityType, $attributeData['attribute_code'])
->will($this->returnValue($attribute));
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$model = $objectManager->getObject(
- \Magento\Catalog\Model\Config::class,
+ Config::class,
['configFactory' => $configFactory, 'storeManager' => $storeManager, 'eavConfig' => $eavConfig]
);
@@ -285,13 +303,13 @@ public function testGetAttributeUsedForSortByArray()
public function testGetProductListDefaultSortBy()
{
$scopeConfig = $this->createPartialMock(
- \Magento\Framework\App\Config\ScopeConfigInterface::class,
+ ScopeConfigInterface::class,
['getValue', 'isSetFlag']
);
$scopeConfig->expects($this->once())->method('getValue')
->with('catalog/frontend/default_sort_by', 'store', null)->will($this->returnValue(1));
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $model = $objectManager->getObject(\Magento\Catalog\Model\Config::class, ['scopeConfig' => $scopeConfig]);
+ $objectManager = new ObjectManager($this);
+ $model = $objectManager->getObject(Config::class, ['scopeConfig' => $scopeConfig]);
$this->assertEquals(1, $model->getProductListDefaultSortBy());
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionProcessorTest.php
index cd0c02874b452..7e76056c8f0ee 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionProcessorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionProcessorTest.php
@@ -3,97 +3,112 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\CustomOptions;
+use Magento\Catalog\Api\Data\CustomOptionInterface;
+use Magento\Catalog\Model\CustomOptions\CustomOption;
+use Magento\Catalog\Model\CustomOptions\CustomOptionFactory;
use Magento\Catalog\Model\CustomOptions\CustomOptionProcessor;
+use Magento\Framework\DataObject;
+use Magento\Framework\DataObject\Factory;
+use Magento\Framework\Serialize\Serializer\Json;
+use Magento\Quote\Api\Data\CartItemInterface;
+use Magento\Quote\Api\Data\ProductOptionExtensionFactory;
+use Magento\Quote\Api\Data\ProductOptionExtensionInterface;
+use Magento\Quote\Model\Quote\Item\Option;
+use Magento\Quote\Model\Quote\ProductOption;
+use Magento\Quote\Model\Quote\ProductOptionFactory;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CustomOptionProcessorTest extends \PHPUnit\Framework\TestCase
+class CustomOptionProcessorTest extends TestCase
{
/**
- * @var \Magento\Framework\DataObject\Factory|\PHPUnit_Framework_MockObject_MockObject
+ * @var Factory|MockObject
*/
protected $objectFactory;
/**
- * @var \Magento\Quote\Model\Quote\ProductOptionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductOptionFactory|MockObject
*/
protected $productOptionFactory;
/**
- * @var \Magento\Quote\Api\Data\ProductOptionExtensionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductOptionExtensionFactory|MockObject
*/
protected $extensionFactory;
/**
- * @var \Magento\Catalog\Model\CustomOptions\CustomOptionFactory
- * |\PHPUnit_Framework_MockObject_MockObject
+ * @var CustomOptionFactory|MockObject
*/
protected $customOptionFactory;
- /** @var \Magento\Quote\Api\Data\CartItemInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var CartItemInterface|MockObject */
protected $cartItem;
- /** @var \Magento\Quote\Api\Data\ProductOptionExtensionInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ProductOptionExtensionInterface|MockObject */
protected $extensibleAttribute;
- /** @var \Magento\Quote\Model\Quote\ProductOption|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ProductOption|MockObject */
protected $productOption;
- /** @var \Magento\Catalog\Model\CustomOptions\CustomOption|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var CustomOption|MockObject */
protected $customOption;
- /** @var \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var DataObject|MockObject */
protected $buyRequest;
/** @var CustomOptionProcessor */
protected $processor;
- /** @var \Magento\Framework\Serialize\Serializer\Json */
+ /** @var Json */
private $serializer;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectFactory = $this->getMockBuilder(\Magento\Framework\DataObject\Factory::class)
+ $this->objectFactory = $this->getMockBuilder(Factory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
- $this->productOptionFactory = $this->getMockBuilder(\Magento\Quote\Model\Quote\ProductOptionFactory::class)
+ $this->productOptionFactory = $this->getMockBuilder(ProductOptionFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
- $this->extensionFactory = $this->getMockBuilder(\Magento\Quote\Api\Data\ProductOptionExtensionFactory::class)
+ $this->extensionFactory = $this->getMockBuilder(ProductOptionExtensionFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
$this->customOptionFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\CustomOptions\CustomOptionFactory::class
+ CustomOptionFactory::class
)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
- $this->cartItem = $this->getMockBuilder(\Magento\Quote\Api\Data\CartItemInterface::class)
+ $this->cartItem = $this->getMockBuilder(CartItemInterface::class)
->disableOriginalConstructor()
->setMethods(['getOptionByCode', 'getProductOption', 'setProductOption'])
->getMockForAbstractClass();
$this->extensibleAttribute = $this->getMockBuilder(
- \Magento\Quote\Api\Data\ProductOptionExtensionInterface::class
+ ProductOptionExtensionInterface::class
)
->disableOriginalConstructor()
->setMethods(['setCustomOptions', 'getCustomOptions'])
->getMockForAbstractClass();
- $this->productOption = $this->getMockBuilder(\Magento\Quote\Model\Quote\ProductOption::class)
+ $this->productOption = $this->getMockBuilder(ProductOption::class)
->disableOriginalConstructor()
->getMock();
- $this->customOption = $this->getMockBuilder(\Magento\Catalog\Api\Data\CustomOptionInterface::class)
+ $this->customOption = $this->getMockBuilder(CustomOptionInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->buyRequest = $this->getMockBuilder(\Magento\Framework\DataObject::class)
+ $this->buyRequest = $this->getMockBuilder(DataObject::class)
->disableOriginalConstructor()
->getMock();
- $this->serializer = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)
+ $this->serializer = $this->getMockBuilder(Json::class)
->setMethods(['unserialize'])
->getMockForAbstractClass();
@@ -138,7 +153,7 @@ public function testConvertToBuyRequest()
public function testProcessCustomOptions()
{
$optionId = 23;
- $quoteItemOption = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class)
+ $quoteItemOption = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->getMock();
$this->cartItem->expects($this->atLeastOnce())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionTest.php
index fb90eaaaf1ec5..9428c02f55218 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionTest.php
@@ -3,38 +3,49 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\CustomOptions;
+use Magento\Catalog\Api\Data\CustomOptionExtensionInterface;
+use Magento\Catalog\Api\Data\CustomOptionInterface;
use Magento\Catalog\Model\CustomOptions\CustomOption;
use Magento\Catalog\Model\Webapi\Product\Option\Type\File\Processor as FileProcessor;
+use Magento\Framework\Api\AttributeValueFactory;
+use Magento\Framework\Api\Data\ImageContentInterface;
use Magento\Framework\Api\ExtensionAttributesFactory;
-use Magento\Catalog\Api\Data\CustomOptionExtensionInterface;
-
-class CustomOptionTest extends \PHPUnit\Framework\TestCase
+use Magento\Framework\Data\Collection\AbstractDb;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\Registry;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class CustomOptionTest extends TestCase
{
/**
* @var CustomOption
*/
protected $model;
- /** @var \Magento\Framework\Api\ExtensionAttributesFactory | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var ExtensionAttributesFactory|MockObject */
private $extensionAttributesFactoryMock;
- /** @var \Magento\Catalog\Api\Data\CustomOptionExtensionInterface | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var CustomOptionExtensionInterface|MockObject */
private $extensionMock;
/**
- * @var FileProcessor | \PHPUnit_Framework_MockObject_MockObject
+ * @var FileProcessor|MockObject
*/
protected $fileProcessor;
- protected function setUp()
+ protected function setUp(): void
{
- $context = $this->getMockBuilder(\Magento\Framework\Model\Context::class)
+ $context = $this->getMockBuilder(Context::class)
->disableOriginalConstructor()
->getMock();
- $registry = $this->getMockBuilder(\Magento\Framework\Registry::class)
+ $registry = $this->getMockBuilder(Registry::class)
->disableOriginalConstructor()
->getMock();
@@ -42,7 +53,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $attributeValueFactory = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class)
+ $attributeValueFactory = $this->getMockBuilder(AttributeValueFactory::class)
->disableOriginalConstructor()
->getMock();
@@ -52,15 +63,15 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $resource = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\AbstractResource::class)
+ $resource = $this->getMockBuilder(AbstractResource::class)
->disableOriginalConstructor()
->getMock();
- $collection = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class)
+ $collection = $this->getMockBuilder(AbstractDb::class)
->disableOriginalConstructor()
->getMock();
- $this->extensionMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\CustomOptionExtensionInterface::class)
+ $this->extensionMock = $this->getMockBuilder(CustomOptionExtensionInterface::class)
->setMethods(['getFileInfo'])
->getMockForAbstractClass();
@@ -90,16 +101,16 @@ public function testGetOptionValue()
{
$this->assertNull($this->model->getOptionValue());
- $this->model->setData(\Magento\Catalog\Api\Data\CustomOptionInterface::OPTION_VALUE, 'test');
+ $this->model->setData(CustomOptionInterface::OPTION_VALUE, 'test');
$this->assertEquals('test', $this->model->getOptionValue());
- $this->model->setData(\Magento\Catalog\Api\Data\CustomOptionInterface::OPTION_VALUE, 'file');
+ $this->model->setData(CustomOptionInterface::OPTION_VALUE, 'file');
$this->assertEquals('file', $this->model->getOptionValue());
}
public function testGetOptionValueWithFileInfo()
{
- $imageContent = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class)
+ $imageContent = $this->getMockBuilder(ImageContentInterface::class)
->getMockForAbstractClass();
$this->extensionMock->expects($this->once())
@@ -123,7 +134,7 @@ public function testGetOptionValueWithFileInfo()
->with($imageContent)
->willReturn($imageResult);
- $this->model->setData(\Magento\Catalog\Api\Data\CustomOptionInterface::OPTION_VALUE, 'file');
+ $this->model->setData(CustomOptionInterface::OPTION_VALUE, 'file');
$this->assertEquals($imageResult, $this->model->getOptionValue());
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php
index 55c43978f1a44..89e053af5b3dd 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php
@@ -3,124 +3,149 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Entity;
+use Magento\Catalog\Model\Attribute\LockValidatorInterface;
use Magento\Catalog\Model\Entity\Attribute;
+use Magento\Catalog\Model\Product\ReservedAttributeList;
+use Magento\Eav\Api\Data\AttributeOptionInterfaceFactory;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\TypeFactory;
+use Magento\Eav\Model\ResourceModel\Helper;
+use Magento\Framework\Api\AttributeValueFactory;
+use Magento\Framework\Api\DataObjectHelper;
+use Magento\Framework\Api\ExtensionAttributesFactory;
+use Magento\Framework\Api\MetadataServiceInterface;
+use Magento\Framework\App\CacheInterface;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\Locale\ResolverInterface;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\Reflection\DataObjectProcessor;
+use Magento\Framework\Registry;
+use Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\Validator\UniversalFactory;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class AttributeTest extends \PHPUnit\Framework\TestCase
+class AttributeTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Entity\Attribute
+ * @var Attribute
*/
private $attribute;
/**
- * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $contextMock;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
private $registryMock;
/**
- * @var \Magento\Framework\Api\MetadataServiceInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataServiceInterface|MockObject
*/
private $metadataServiceMock;
/**
- * @var \Magento\Framework\Api\AttributeValueFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeValueFactory|MockObject
*/
private $attributeValueFactoryMock;
/**
- * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $configMock;
/**
- * @var \Magento\Eav\Model\Entity\TypeFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var TypeFactory|MockObject
*/
private $typeFactoryMock;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManagerMock;
/**
- * @var \Magento\Eav\Model\ResourceModel\Helper|\PHPUnit_Framework_MockObject_MockObject
+ * @var Helper|MockObject
*/
private $helperMock;
/**
- * @var \Magento\Framework\Validator\UniversalFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var UniversalFactory|MockObject
*/
private $universalFactoryMock;
/**
- * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var TimezoneInterface|MockObject
*/
private $timezoneMock;
/**
- * @var \Magento\Catalog\Model\Product\ReservedAttributeList|\PHPUnit_Framework_MockObject_MockObject
+ * @var ReservedAttributeList|MockObject
*/
private $reservedAttributeListMock;
/**
- * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResolverInterface|MockObject
*/
private $resolverMock;
/**
- * @var \Magento\Catalog\Model\Attribute\LockValidatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LockValidatorInterface|MockObject
*/
private $lockValidatorMock;
/**
- * @var \Magento\Framework\Model\ResourceModel\AbstractResource|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractResource|MockObject
*/
private $resourceMock;
/**
- * @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CacheInterface|MockObject
*/
private $cacheManager;
/**
- * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
private $eventDispatcher;
/**
- * @var \Magento\Eav\Api\Data\AttributeOptionInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeOptionInterfaceFactory|MockObject
*/
private $attributeOptionFactoryMock;
/**
- * @var \Magento\Framework\Reflection\DataObjectProcessor|\PHPUnit_Framework_MockObject_MockObject
+ * @var DataObjectProcessor|MockObject
*/
private $dataObjectProcessorMock;
/**
- * @var \Magento\Framework\Api\DataObjectHelper|\PHPUnit_Framework_MockObject_MockObject
+ * @var DataObjectHelper|MockObject
*/
private $dataObjectHelperMock;
/**
- * @var \Magento\Framework\Api\ExtensionAttributesFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ExtensionAttributesFactory|MockObject
*/
private $extensionAttributesFactory;
/**
- * @var \Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var DateTimeFormatterInterface|MockObject
*/
private $dateTimeFormatter;
@@ -128,67 +153,67 @@ class AttributeTest extends \PHPUnit\Framework\TestCase
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->contextMock = $this->getMockBuilder(\Magento\Framework\Model\Context::class)
+ $this->contextMock = $this->getMockBuilder(Context::class)
->setMethods(['getCacheManager', 'getEventDispatcher'])
->disableOriginalConstructor()
->getMock();
- $this->registryMock = $this->getMockBuilder(\Magento\Framework\Registry::class)
+ $this->registryMock = $this->getMockBuilder(Registry::class)
->getMock();
- $this->metadataServiceMock = $this->getMockBuilder(\Magento\Framework\Api\MetadataServiceInterface::class)
+ $this->metadataServiceMock = $this->getMockBuilder(MetadataServiceInterface::class)
->getMock();
$this->extensionAttributesFactory = $this->getMockBuilder(
- \Magento\Framework\Api\ExtensionAttributesFactory::class
+ ExtensionAttributesFactory::class
)->disableOriginalConstructor()->getMock();
- $this->attributeValueFactoryMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class)
+ $this->attributeValueFactoryMock = $this->getMockBuilder(AttributeValueFactory::class)
->disableOriginalConstructor()
->getMock();
- $this->configMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class)
+ $this->configMock = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
- $this->typeFactoryMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\TypeFactory::class)
+ $this->typeFactoryMock = $this->getMockBuilder(TypeFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
- $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
->getMock();
- $this->helperMock = $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Helper::class)
+ $this->helperMock = $this->getMockBuilder(Helper::class)
->disableOriginalConstructor()
->getMock();
- $this->universalFactoryMock = $this->getMockBuilder(\Magento\Framework\Validator\UniversalFactory::class)
+ $this->universalFactoryMock = $this->getMockBuilder(UniversalFactory::class)
->disableOriginalConstructor()
->getMock();
$this->attributeOptionFactoryMock =
- $this->getMockBuilder(\Magento\Eav\Api\Data\AttributeOptionInterfaceFactory::class)
+ $this->getMockBuilder(AttributeOptionInterfaceFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
- $this->dataObjectProcessorMock = $this->getMockBuilder(\Magento\Framework\Reflection\DataObjectProcessor::class)
+ $this->dataObjectProcessorMock = $this->getMockBuilder(DataObjectProcessor::class)
->disableOriginalConstructor()
->getMock();
- $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class)
+ $this->dataObjectHelperMock = $this->getMockBuilder(DataObjectHelper::class)
->disableOriginalConstructor()
->getMock();
- $this->timezoneMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class)
+ $this->timezoneMock = $this->getMockBuilder(TimezoneInterface::class)
->getMock();
$this->reservedAttributeListMock = $this->getMockBuilder(
- \Magento\Catalog\Model\Product\ReservedAttributeList::class
+ ReservedAttributeList::class
)->disableOriginalConstructor()->getMock();
- $this->resolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class)
+ $this->resolverMock = $this->getMockBuilder(ResolverInterface::class)
->getMock();
- $this->lockValidatorMock = $this->getMockBuilder(\Magento\Catalog\Model\Attribute\LockValidatorInterface::class)
+ $this->lockValidatorMock = $this->getMockBuilder(LockValidatorInterface::class)
->getMock();
$this->dateTimeFormatter = $this->createMock(
- \Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface::class
+ DateTimeFormatterInterface::class
);
- $this->resourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\AbstractResource::class)
+ $this->resourceMock = $this->getMockBuilder(AbstractResource::class)
->setMethods(['_construct', 'getConnection', 'getIdFieldName', 'saveInSetIncluding'])
->getMockForAbstractClass();
- $this->cacheManager = $this->getMockBuilder(\Magento\Framework\App\CacheInterface::class)
+ $this->cacheManager = $this->getMockBuilder(CacheInterface::class)
->getMock();
- $this->eventDispatcher = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class)
+ $this->eventDispatcher = $this->getMockBuilder(ManagerInterface::class)
->getMock();
$this->contextMock
->expects($this->any())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/FactoryTest.php
index a22068136dd85..6852487daa082 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/FactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/FactoryTest.php
@@ -3,19 +3,24 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model;
-use \Magento\Catalog\Model\Factory;
+use Magento\Catalog\Model\Factory;
+use Magento\Catalog\Model\Product\Option;
+use Magento\Framework\ObjectManagerInterface;
+use PHPUnit\Framework\TestCase;
-class FactoryTest extends \PHPUnit\Framework\TestCase
+class FactoryTest extends TestCase
{
/**
- * @var \Magento\Framework\ObjectManagerInterface
+ * @var ObjectManagerInterface
*/
protected $objectManager;
/**
- * @var \Magento\Catalog\Model\Product\Option
+ * @var Option
*/
protected $model;
@@ -26,20 +31,18 @@ class FactoryTest extends \PHPUnit\Framework\TestCase
public function testCreate()
{
- $this->assertInstanceOf(\Magento\Catalog\Model\Product\Option::class, $this->factory->create('model', []));
+ $this->assertInstanceOf(Option::class, $this->factory->create('model', []));
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- */
public function testExceptionCreate()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$this->factory->create('null', []);
}
- protected function setUp()
+ protected function setUp(): void
{
- $this->model = $this->createMock(\Magento\Catalog\Model\Product\Option::class);
+ $this->model = $this->createMock(Option::class);
$this->setObjectManager();
@@ -48,7 +51,7 @@ protected function setUp()
protected function setObjectManager()
{
- $this->objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
+ $this->objectManager = $this->createMock(ObjectManagerInterface::class);
$this->objectManager
->expects($this->any())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/FrontendStorageConfigurationPoolTest.php b/app/code/Magento/Catalog/Test/Unit/Model/FrontendStorageConfigurationPoolTest.php
index 710d1e854123e..05b6d4053fd70 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/FrontendStorageConfigurationPoolTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/FrontendStorageConfigurationPoolTest.php
@@ -3,15 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\FrontendStorageConfigurationInterface;
+use Magento\Catalog\Model\FrontendStorageConfigurationPool;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\TestCase;
-class FrontendStorageConfigurationPoolTest extends \PHPUnit\Framework\TestCase
+class FrontendStorageConfigurationPoolTest extends TestCase
{
- /** @var \Magento\Catalog\Model\FrontendStorageConfigurationPool */
+ /** @var FrontendStorageConfigurationPool */
protected $model;
/** @var ObjectManagerHelper */
@@ -22,13 +26,13 @@ class FrontendStorageConfigurationPoolTest extends \PHPUnit\Framework\TestCase
*/
private $defaultStorageConfiguration;
- protected function setUp()
+ protected function setUp(): void
{
$this->defaultStorageConfiguration = $this->createMock(FrontendStorageConfigurationInterface::class);
$productStorageConfiguration = $this->createMock(ProductInterface::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Model\FrontendStorageConfigurationPool::class,
+ FrontendStorageConfigurationPool::class,
[
'storageConfigurations' => [
'default' => $this->defaultStorageConfiguration,
@@ -43,12 +47,10 @@ public function testGet()
$this->assertEquals($this->defaultStorageConfiguration, $this->model->get('default'));
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Invalid pool type with namespace: product
- */
public function testGetWithException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('Invalid pool type with namespace: product');
$this->assertEquals($this->defaultStorageConfiguration, $this->model->get('product'));
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ImageExtractorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ImageExtractorTest.php
index 3b0262aa99e4f..22dbfff9b789b 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ImageExtractorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ImageExtractorTest.php
@@ -3,26 +3,30 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model;
+use Magento\Catalog\Model\ImageExtractor;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class ImageExtractorTest extends \PHPUnit\Framework\TestCase
+class ImageExtractorTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ImageExtractor
+ * @var ImageExtractor
*/
private $model;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
- $this->model = $objectManager->getObject(\Magento\Catalog\Model\ImageExtractor::class);
+ $this->model = $objectManager->getObject(ImageExtractor::class);
}
public function testProcess()
{
- $expectedArray = include(__DIR__ . '/_files/converted_view.php');
+ $expectedArray = include __DIR__ . '/_files/converted_view.php';
$this->assertSame($expectedArray, $this->model->process($this->getDomElement(), 'media'));
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ImageUploaderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ImageUploaderTest.php
index 6552e85440008..371e93079aa64 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ImageUploaderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ImageUploaderTest.php
@@ -3,52 +3,66 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model;
-class ImageUploaderTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\ImageUploader;
+use Magento\Framework\Filesystem;
+use Magento\Framework\Filesystem\Directory\WriteInterface;
+use Magento\MediaStorage\Helper\File\Storage\Database;
+use Magento\MediaStorage\Model\File\Uploader;
+use Magento\MediaStorage\Model\File\UploaderFactory;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
+
+class ImageUploaderTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ImageUploader
+ * @var ImageUploader
*/
private $imageUploader;
/**
* Core file storage database
*
- * @var \Magento\MediaStorage\Helper\File\Storage\Database|\PHPUnit_Framework_MockObject_MockObject
+ * @var Database|MockObject
*/
private $coreFileStorageDatabaseMock;
/**
* Media directory object (writable).
*
- * @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject
+ * @var Filesystem|MockObject
*/
private $mediaDirectoryMock;
/**
* Media directory object (writable).
*
- * @var \Magento\Framework\Filesystem\Directory\WriteInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriteInterface|MockObject
*/
private $mediaWriteDirectoryMock;
/**
* Uploader factory
*
- * @var \Magento\MediaStorage\Model\File\UploaderFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var UploaderFactory|MockObject
*/
private $uploaderFactoryMock;
/**
* Store manager
*
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManagerMock;
/**
- * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
private $loggerMock;
@@ -80,34 +94,34 @@ class ImageUploaderTest extends \PHPUnit\Framework\TestCase
*/
private $allowedMimeTypes;
- protected function setUp()
+ protected function setUp(): void
{
$this->coreFileStorageDatabaseMock = $this->createMock(
- \Magento\MediaStorage\Helper\File\Storage\Database::class
+ Database::class
);
$this->mediaDirectoryMock = $this->createMock(
- \Magento\Framework\Filesystem::class
+ Filesystem::class
);
$this->mediaWriteDirectoryMock = $this->createMock(
- \Magento\Framework\Filesystem\Directory\WriteInterface::class
+ WriteInterface::class
);
$this->mediaDirectoryMock->expects($this->any())->method('getDirectoryWrite')->willReturn(
$this->mediaWriteDirectoryMock
);
$this->uploaderFactoryMock = $this->createMock(
- \Magento\MediaStorage\Model\File\UploaderFactory::class
+ UploaderFactory::class
);
$this->storeManagerMock = $this->createMock(
- \Magento\Store\Model\StoreManagerInterface::class
+ StoreManagerInterface::class
);
- $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class);
+ $this->loggerMock = $this->createMock(LoggerInterface::class);
$this->baseTmpPath = 'base/tmp/';
$this->basePath = 'base/real/';
$this->allowedExtensions = ['.jpg'];
$this->allowedMimeTypes = ['image/jpg', 'image/jpeg', 'image/gif', 'image/png'];
$this->imageUploader =
- new \Magento\Catalog\Model\ImageUploader(
+ new ImageUploader(
$this->coreFileStorageDatabaseMock,
$this->mediaDirectoryMock,
$this->uploaderFactoryMock,
@@ -129,8 +143,8 @@ public function testSaveFileToTmpDir()
'image/gif',
'image/png',
];
- /** @var \Magento\MediaStorage\Model\File\Uploader|\PHPUnit_Framework_MockObject_MockObject $uploader */
- $uploader = $this->createMock(\Magento\MediaStorage\Model\File\Uploader::class);
+ /** @var \Magento\MediaStorage\Model\File\Uploader|MockObject $uploader */
+ $uploader = $this->createMock(Uploader::class);
$this->uploaderFactoryMock->expects($this->once())->method('create')->willReturn($uploader);
$uploader->expects($this->once())->method('setAllowedExtensions')->with($this->allowedExtensions);
$uploader->expects($this->once())->method('setAllowRenameFiles')->with(true);
@@ -140,7 +154,7 @@ public function testSaveFileToTmpDir()
->willReturn(['tmp_name' => $this->baseTmpPath, 'file' => $fileId, 'path' => $this->basePath]);
$uploader->expects($this->atLeastOnce())->method('checkMimeType')->with($allowedMimeTypes)->willReturn(true);
$storeMock = $this->createPartialMock(
- \Magento\Store\Model\Store::class,
+ Store::class,
['getBaseUrl']
);
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php
index f69cbeb91631f..e4267a0806592 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php
@@ -3,14 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Category\Flat\Plugin;
use Magento\Catalog\Model\Indexer\Category\Flat\Plugin\IndexerConfigData;
use Magento\Catalog\Model\Indexer\Category\Flat\State;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Indexer\Model\Config\Data;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class IndexerConfigDataTest extends \PHPUnit\Framework\TestCase
+class IndexerConfigDataTest extends TestCase
{
/**
* @var IndexerConfigData
@@ -18,16 +22,16 @@ class IndexerConfigDataTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var State|\PHPUnit_Framework_MockObject_MockObject
+ * @var State|MockObject
*/
protected $stateMock;
/**
- * @var Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var Data|MockObject
*/
protected $subjectMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->stateMock = $this->createPartialMock(State::class, ['isFlatEnabled']);
$this->subjectMock = $this->createMock(Data::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php
index 6d9063b9043b0..bfc0ba6402722 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Category\Flat\Plugin;
use Magento\Catalog\Model\Indexer\Category\Flat\Plugin\StoreGroup;
@@ -12,16 +14,18 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Store\Model\Group as GroupModel;
use Magento\Store\Model\ResourceModel\Group;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class StoreGroupTest extends \PHPUnit\Framework\TestCase
+class StoreGroupTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|IndexerInterface
+ * @var MockObject|IndexerInterface
*/
protected $indexerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|State
+ * @var MockObject|State
*/
protected $stateMock;
@@ -31,21 +35,21 @@ class StoreGroupTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|Group
+ * @var MockObject|Group
*/
protected $subjectMock;
/**
- * @var IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
protected $indexerRegistryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|GroupModel
+ * @var MockObject|GroupModel
*/
protected $groupMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->indexerMock = $this->getMockForAbstractClass(
IndexerInterface::class,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php
index 4aef779e4078d..b39fffe8f8e1f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php
@@ -3,19 +3,27 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Category\Flat\Plugin;
use Magento\Catalog\Model\Indexer\Category\Flat\Plugin\StoreView;
+use Magento\Catalog\Model\Indexer\Category\Flat\State;
+use Magento\Framework\Indexer\IndexerInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
+use Magento\Store\Model\ResourceModel\Store;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class StoreViewTest extends \PHPUnit\Framework\TestCase
+class StoreViewTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Indexer\IndexerInterface
+ * @var MockObject|IndexerInterface
*/
protected $indexerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Indexer\Category\Flat\State
+ * @var MockObject|State
*/
protected $stateMock;
@@ -25,19 +33,19 @@ class StoreViewTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
protected $indexerRegistryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $subjectMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->indexerMock = $this->getMockForAbstractClass(
- \Magento\Framework\Indexer\IndexerInterface::class,
+ IndexerInterface::class,
[],
'',
false,
@@ -46,12 +54,12 @@ protected function setUp()
['getId', 'getState', '__wakeup']
);
$this->stateMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Category\Flat\State::class,
+ State::class,
['isFlatEnabled']
);
- $this->subjectMock = $this->createMock(\Magento\Store\Model\ResourceModel\Store::class);
+ $this->subjectMock = $this->createMock(Store::class);
$this->indexerRegistryMock = $this->createPartialMock(
- \Magento\Framework\Indexer\IndexerRegistry::class,
+ IndexerRegistry::class,
['get']
);
$this->model = new StoreView($this->indexerRegistryMock, $this->stateMock);
@@ -105,7 +113,7 @@ protected function mockIndexerMethods()
$this->indexerMock->expects($this->once())->method('invalidate');
$this->indexerRegistryMock->expects($this->once())
->method('get')
- ->with(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID)
+ ->with(State::INDEXER_ID)
->will($this->returnValue($this->indexerMock));
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php
index 6916cef2dfa61..fee0795281382 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php
@@ -3,38 +3,47 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Category\Flat;
-class StateTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Category\Flat\State;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Indexer\IndexerInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class StateTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Flat\State
+ * @var State
*/
protected $model;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $scopeConfigMock;
/**
- * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerInterface|MockObject
*/
protected $flatIndexerMock;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
protected $indexerRegistryMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->scopeConfigMock = $this->getMockForAbstractClass(
- \Magento\Framework\App\Config\ScopeConfigInterface::class
+ ScopeConfigInterface::class
);
$this->flatIndexerMock = $this->getMockForAbstractClass(
- \Magento\Framework\Indexer\IndexerInterface::class,
+ IndexerInterface::class,
[],
'',
false,
@@ -44,7 +53,7 @@ protected function setUp()
);
$this->indexerRegistryMock = $this->createPartialMock(
- \Magento\Framework\Indexer\IndexerRegistry::class,
+ IndexerRegistry::class,
['get']
);
}
@@ -61,7 +70,7 @@ public function testIsFlatEnabled()
$this->returnValue(true)
);
- $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat\State(
+ $this->model = new State(
$this->scopeConfigMock,
$this->indexerRegistryMock
);
@@ -81,7 +90,7 @@ public function testIsAvailable($isAvailable, $isFlatEnabled, $isValid, $result)
$this->flatIndexerMock->expects($this->any())->method('isValid')->will($this->returnValue($isValid));
$this->indexerRegistryMock->expects($this->any())
->method('get')
- ->with(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID)
+ ->with(State::INDEXER_ID)
->will($this->returnValue($this->flatIndexerMock));
$this->scopeConfigMock->expects(
@@ -94,7 +103,7 @@ public function testIsAvailable($isAvailable, $isFlatEnabled, $isValid, $result)
$this->returnValue($isFlatEnabled)
);
- $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat\State(
+ $this->model = new State(
$this->scopeConfigMock,
$this->indexerRegistryMock,
$isAvailable
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php
index fb02b80a60175..808b86a874986 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php
@@ -3,52 +3,63 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Category\Flat\System\Config;
-class ModeTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Category\Flat\System\Config\Mode;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Indexer\IndexerInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Indexer\Model\Indexer\State;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ModeTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Flat\System\Config\Mode
+ * @var Mode
*/
protected $model;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $configMock;
/**
- * @var \Magento\Indexer\Model\Indexer\State|\PHPUnit_Framework_MockObject_MockObject
+ * @var State|MockObject
*/
protected $indexerStateMock;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
protected $indexerRegistry;
/**
- * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerInterface|MockObject
*/
protected $flatIndexer;
- protected function setUp()
+ protected function setUp(): void
{
- $this->configMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $this->configMock = $this->createMock(ScopeConfigInterface::class);
$this->indexerStateMock = $this->createPartialMock(
- \Magento\Indexer\Model\Indexer\State::class,
+ State::class,
['loadByIndexer', 'setStatus', 'save', '__wakeup']
);
$this->indexerRegistry = $this->createPartialMock(
- \Magento\Framework\Indexer\IndexerRegistry::class,
+ IndexerRegistry::class,
['load', 'setScheduled', 'get']
);
- $this->flatIndexer = $this->createMock(\Magento\Framework\Indexer\IndexerInterface::class);
+ $this->flatIndexer = $this->createMock(IndexerInterface::class);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Indexer\Category\Flat\System\Config\Mode::class,
+ Mode::class,
[
'config' => $this->configMock,
'indexerState' => $this->indexerStateMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/FlatTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/FlatTest.php
index 5854cf24c4102..d261a85aeb798 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/FlatTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/FlatTest.php
@@ -3,54 +3,69 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Category;
-class FlatTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Indexer\Category\Flat;
+use Magento\Catalog\Model\Indexer\Category\Flat\Action\Full;
+use Magento\Catalog\Model\Indexer\Category\Flat\Action\FullFactory;
+use Magento\Catalog\Model\Indexer\Category\Flat\Action\Rows;
+use Magento\Catalog\Model\Indexer\Category\Flat\Action\RowsFactory;
+use Magento\Catalog\Model\Indexer\Category\Flat\State;
+use Magento\Framework\Indexer\CacheContext;
+use Magento\Framework\Indexer\IndexerInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class FlatTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Flat
+ * @var Flat
*/
protected $model;
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Flat\Action\FullFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var FullFactory|MockObject
*/
protected $fullMock;
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Flat\Action\RowsFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var RowsFactory|MockObject
*/
protected $rowsMock;
/**
- * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerInterface|MockObject
*/
protected $indexerMock;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
protected $indexerRegistryMock;
/**
- * @var \Magento\Framework\Indexer\CacheContext|\PHPUnit_Framework_MockObject_MockObject
+ * @var CacheContext|MockObject
*/
protected $cacheContextMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->fullMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Category\Flat\Action\FullFactory::class,
+ FullFactory::class,
['create']
);
$this->rowsMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Category\Flat\Action\RowsFactory::class,
+ RowsFactory::class,
['create']
);
$this->indexerMock = $this->getMockForAbstractClass(
- \Magento\Framework\Indexer\IndexerInterface::class,
+ IndexerInterface::class,
[],
'',
false,
@@ -60,20 +75,20 @@ protected function setUp()
);
$this->indexerRegistryMock = $this->createPartialMock(
- \Magento\Framework\Indexer\IndexerRegistry::class,
+ IndexerRegistry::class,
['get']
);
- $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat(
+ $this->model = new Flat(
$this->fullMock,
$this->rowsMock,
$this->indexerRegistryMock
);
- $this->cacheContextMock = $this->createMock(\Magento\Framework\Indexer\CacheContext::class);
+ $this->cacheContextMock = $this->createMock(CacheContext::class);
$cacheContextProperty = new \ReflectionProperty(
- \Magento\Catalog\Model\Indexer\Category\Flat::class,
+ Flat::class,
'cacheContext'
);
$cacheContextProperty->setAccessible(true);
@@ -99,7 +114,7 @@ public function testExecuteWithIndexerWorking()
$this->prepareIndexer();
$rowMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Category\Flat\Action\Rows::class,
+ Rows::class,
['reindex']
);
$rowMock->expects($this->at(0))->method('reindex')->with($ids, true)->will($this->returnSelf());
@@ -109,7 +124,7 @@ public function testExecuteWithIndexerWorking()
$this->cacheContextMock->expects($this->once())
->method('registerEntities')
- ->with(\Magento\Catalog\Model\Category::CACHE_TAG, $ids);
+ ->with(Category::CACHE_TAG, $ids);
$this->model->execute($ids);
}
@@ -123,7 +138,7 @@ public function testExecuteWithIndexerNotWorking()
$this->prepareIndexer();
$rowMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Category\Flat\Action\Rows::class,
+ Rows::class,
['reindex']
);
$rowMock->expects($this->once())->method('reindex')->with($ids, false)->will($this->returnSelf());
@@ -132,7 +147,7 @@ public function testExecuteWithIndexerNotWorking()
$this->cacheContextMock->expects($this->once())
->method('registerEntities')
- ->with(\Magento\Catalog\Model\Category::CACHE_TAG, $ids);
+ ->with(Category::CACHE_TAG, $ids);
$this->model->execute($ids);
}
@@ -141,14 +156,14 @@ protected function prepareIndexer()
{
$this->indexerRegistryMock->expects($this->once())
->method('get')
- ->with(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID)
+ ->with(State::INDEXER_ID)
->will($this->returnValue($this->indexerMock));
}
public function testExecuteFull()
{
- /** @var \Magento\Catalog\Model\Indexer\Category\Flat\Action\Full $categoryIndexerFlatFull */
- $categoryIndexerFlatFull = $this->createMock(\Magento\Catalog\Model\Indexer\Category\Flat\Action\Full::class);
+ /** @var Full $categoryIndexerFlatFull */
+ $categoryIndexerFlatFull = $this->createMock(Full::class);
$this->fullMock->expects($this->once())
->method('create')
->willReturn($categoryIndexerFlatFull);
@@ -156,7 +171,7 @@ public function testExecuteFull()
->method('reindexAll');
$this->cacheContextMock->expects($this->once())
->method('registerTags')
- ->with([\Magento\Catalog\Model\Category::CACHE_TAG]);
+ ->with([Category::CACHE_TAG]);
$this->model->executeFull();
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/ImportTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/ImportTest.php
index 9825ef7b2fec1..0dc0e23ccb3c2 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/ImportTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/ImportTest.php
@@ -3,19 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Category\Product\Plugin;
-class ImportTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Category\Product\Processor;
+use Magento\ImportExport\Model\Import;
+use PHPUnit\Framework\TestCase;
+
+class ImportTest extends TestCase
{
public function testAfterImportSource()
{
- $processorMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Category\Product\Processor::class)
+ $processorMock = $this->getMockBuilder(Processor::class)
->disableOriginalConstructor()
->getMock();
$processorMock->expects($this->once())
->method('markIndexerAsInvalid');
- $subjectMock = $this->getMockBuilder(\Magento\ImportExport\Model\Import::class)
+ $subjectMock = $this->getMockBuilder(Import::class)
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/MviewStateTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/MviewStateTest.php
index 97a2c3c0cf10d..c545df70cb71f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/MviewStateTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/MviewStateTest.php
@@ -3,9 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Category\Product\Plugin;
-class MviewStateTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Category\Product;
+use Magento\Catalog\Model\Indexer\Category\Product\Plugin\MviewState;
+use Magento\Catalog\Model\Indexer\Product\Category;
+use Magento\Framework\Mview\View\ChangelogInterface;
+use Magento\Framework\Mview\View\StateInterface;
+use PHPUnit\Framework\TestCase;
+
+class MviewStateTest extends TestCase
{
/**
* @return array
@@ -22,12 +31,12 @@ public function afterSetStatusSuspendDataProvider()
*/
public function testAfterSetStatusSuspend($stateStatus, $relatedStatus)
{
- $stateViewId = \Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID;
- $relatedViewId = \Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID;
+ $stateViewId = Category::INDEXER_ID;
+ $relatedViewId = Product::INDEXER_ID;
$relatedVersion = 'related_version';
$state = $this->getMockBuilder(
- \Magento\Framework\Mview\View\StateInterface::class
+ StateInterface::class
)->disableOriginalConstructor()->getMockForAbstractClass();
$state->expects($this->exactly(2))->method('getViewId')->will($this->returnValue($stateViewId));
@@ -35,7 +44,7 @@ public function testAfterSetStatusSuspend($stateStatus, $relatedStatus)
$state->expects($this->any())->method('getStatus')->will($this->returnValue($stateStatus));
$relatedViewState = $this->getMockBuilder(
- \Magento\Framework\Mview\View\StateInterface::class
+ StateInterface::class
)->disableOriginalConstructor()->getMock();
$relatedViewState->expects(
@@ -75,7 +84,7 @@ public function testAfterSetStatusSuspend($stateStatus, $relatedStatus)
);
$relatedViewChangelog = $this->getMockBuilder(
- \Magento\Framework\Mview\View\ChangelogInterface::class
+ ChangelogInterface::class
)->disableOriginalConstructor()->getMock();
$relatedViewChangelog->expects(
@@ -90,11 +99,11 @@ public function testAfterSetStatusSuspend($stateStatus, $relatedStatus)
$relatedViewChangelog->expects($this->once())->method('getVersion')->will($this->returnValue($relatedVersion));
- $model = new \Magento\Catalog\Model\Indexer\Category\Product\Plugin\MviewState(
+ $model = new MviewState(
$relatedViewState,
$relatedViewChangelog
);
- $this->assertInstanceOf(\Magento\Framework\Mview\View\StateInterface::class, $model->afterSetStatus($state));
+ $this->assertInstanceOf(StateInterface::class, $model->afterSetStatus($state));
}
/**
@@ -112,11 +121,11 @@ public function afterSetStatusResumeDataProvider()
*/
public function testAfterSetStatusResume($stateStatus, $relatedStatus)
{
- $stateViewId = \Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID;
- $relatedViewId = \Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID;
+ $stateViewId = Category::INDEXER_ID;
+ $relatedViewId = Product::INDEXER_ID;
$state = $this->getMockBuilder(
- \Magento\Framework\Mview\View\StateInterface::class
+ StateInterface::class
)->disableOriginalConstructor()->getMockForAbstractClass();
$state->expects($this->exactly(2))->method('getViewId')->will($this->returnValue($stateViewId));
@@ -124,7 +133,7 @@ public function testAfterSetStatusResume($stateStatus, $relatedStatus)
$state->expects($this->any())->method('getStatus')->will($this->returnValue($stateStatus));
$relatedViewState = $this->getMockBuilder(
- \Magento\Framework\Mview\View\StateInterface::class
+ StateInterface::class
)->disableOriginalConstructor()->getMock();
$relatedViewState->expects(
@@ -156,14 +165,14 @@ public function testAfterSetStatusResume($stateStatus, $relatedStatus)
);
$relatedViewChangelog = $this->getMockBuilder(
- \Magento\Framework\Mview\View\ChangelogInterface::class
+ ChangelogInterface::class
)->disableOriginalConstructor()->getMock();
- $model = new \Magento\Catalog\Model\Indexer\Category\Product\Plugin\MviewState(
+ $model = new MviewState(
$relatedViewState,
$relatedViewChangelog
);
- $this->assertInstanceOf(\Magento\Framework\Mview\View\StateInterface::class, $model->afterSetStatus($state));
+ $this->assertInstanceOf(StateInterface::class, $model->afterSetStatus($state));
}
/**
@@ -187,11 +196,11 @@ public function afterSetStatusSkipDataProvider()
*/
public function testAfterSetStatusSkip($stateStatus, $relatedStatus)
{
- $stateViewId = \Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID;
- $relatedViewId = \Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID;
+ $stateViewId = Category::INDEXER_ID;
+ $relatedViewId = Product::INDEXER_ID;
$state = $this->getMockBuilder(
- \Magento\Framework\Mview\View\StateInterface::class
+ StateInterface::class
)->disableOriginalConstructor()->getMockForAbstractClass();
$state->expects($this->exactly(2))->method('getViewId')->will($this->returnValue($stateViewId));
@@ -199,7 +208,7 @@ public function testAfterSetStatusSkip($stateStatus, $relatedStatus)
$state->expects($this->any())->method('getStatus')->will($this->returnValue($stateStatus));
$relatedViewState = $this->getMockBuilder(
- \Magento\Framework\Mview\View\StateInterface::class
+ StateInterface::class
)->disableOriginalConstructor()->getMock();
$relatedViewState->expects(
@@ -223,14 +232,14 @@ public function testAfterSetStatusSkip($stateStatus, $relatedStatus)
$relatedViewState->expects($this->never())->method('setStatus');
$relatedViewChangelog = $this->getMockBuilder(
- \Magento\Framework\Mview\View\ChangelogInterface::class
+ ChangelogInterface::class
)->disableOriginalConstructor()->getMock();
- $model = new \Magento\Catalog\Model\Indexer\Category\Product\Plugin\MviewState(
+ $model = new MviewState(
$relatedViewState,
$relatedViewChangelog
);
- $this->assertInstanceOf(\Magento\Framework\Mview\View\StateInterface::class, $model->afterSetStatus($state));
+ $this->assertInstanceOf(StateInterface::class, $model->afterSetStatus($state));
}
/**
@@ -247,11 +256,11 @@ public function afterSetStatusDisabledDataProvider()
*/
public function testAfterSetStatusDisabled($stateStatus)
{
- $stateViewId = \Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID;
- $relatedViewId = \Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID;
+ $stateViewId = Category::INDEXER_ID;
+ $relatedViewId = Product::INDEXER_ID;
$state = $this->getMockBuilder(
- \Magento\Framework\Mview\View\StateInterface::class
+ StateInterface::class
)->disableOriginalConstructor()->getMockForAbstractClass();
$state->expects($this->exactly(2))->method('getViewId')->will($this->returnValue($stateViewId));
@@ -259,7 +268,7 @@ public function testAfterSetStatusDisabled($stateStatus)
$state->expects($this->any())->method('getStatus')->will($this->returnValue($stateStatus));
$relatedViewState = $this->getMockBuilder(
- \Magento\Framework\Mview\View\StateInterface::class
+ StateInterface::class
)->disableOriginalConstructor()->getMock();
$relatedViewState->expects(
@@ -283,13 +292,13 @@ public function testAfterSetStatusDisabled($stateStatus)
$relatedViewState->expects($this->never())->method('setStatus');
$relatedViewChangelog = $this->getMockBuilder(
- \Magento\Framework\Mview\View\ChangelogInterface::class
+ ChangelogInterface::class
)->disableOriginalConstructor()->getMock();
- $model = new \Magento\Catalog\Model\Indexer\Category\Product\Plugin\MviewState(
+ $model = new MviewState(
$relatedViewState,
$relatedViewChangelog
);
- $this->assertInstanceOf(\Magento\Framework\Mview\View\StateInterface::class, $model->afterSetStatus($state));
+ $this->assertInstanceOf(StateInterface::class, $model->afterSetStatus($state));
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php
index e134407d547ac..4b535f4341a60 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Category\Product\Plugin;
use Magento\Catalog\Model\Indexer\Category\Product;
@@ -12,26 +14,28 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Store\Model\Group as GroupModel;
use Magento\Store\Model\ResourceModel\Group;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class StoreGroupTest extends \PHPUnit\Framework\TestCase
+class StoreGroupTest extends TestCase
{
/**
- * @var GroupModel|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupModel|MockObject
*/
private $groupMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|IndexerInterface
+ * @var MockObject|IndexerInterface
*/
private $indexerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|Group
+ * @var MockObject|Group
*/
private $subject;
/**
- * @var IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
private $indexerRegistryMock;
@@ -40,7 +44,7 @@ class StoreGroupTest extends \PHPUnit\Framework\TestCase
*/
private $model;
- protected function setUp()
+ protected function setUp(): void
{
$this->groupMock = $this->createPartialMock(
GroupModel::class,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreViewTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreViewTest.php
index 4da831f5257d0..5461c346ff894 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreViewTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreViewTest.php
@@ -3,23 +3,29 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Category\Product\Plugin;
+use Magento\Catalog\Model\Indexer\Category\Product;
use Magento\Catalog\Model\Indexer\Category\Product\Plugin\StoreView;
+use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
use Magento\Framework\Indexer\IndexerInterface;
use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Store\Model\ResourceModel\Group;
use Magento\Store\Model\Store;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class StoreViewTest extends \PHPUnit\Framework\TestCase
+class StoreViewTest extends TestCase
{
/**
- * @var Store|\PHPUnit_Framework_MockObject_MockObject
+ * @var Store|MockObject
*/
private $storeMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|IndexerInterface
+ * @var MockObject|IndexerInterface
*/
protected $indexerMock;
@@ -29,21 +35,21 @@ class StoreViewTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
protected $indexerRegistryMock;
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer|\PHPUnit_Framework_MockObject_MockObject
+ * @var TableMaintainer|MockObject
*/
protected $tableMaintainer;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $subject;
- protected function setUp()
+ protected function setUp(): void
{
$this->indexerMock = $this->getMockForAbstractClass(
IndexerInterface::class,
@@ -66,7 +72,7 @@ protected function setUp()
]
);
$this->tableMaintainer = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer::class,
+ TableMaintainer::class,
[
'createTablesForStore'
]
@@ -110,7 +116,7 @@ private function mockIndexerMethods()
$this->indexerMock->expects($this->once())->method('invalidate');
$this->indexerRegistryMock->expects($this->once())
->method('get')
- ->with(\Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID)
+ ->with(Product::INDEXER_ID)
->willReturn($this->indexerMock);
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/RowSizeEstimatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/RowSizeEstimatorTest.php
index 6f11ba37ad353..6e961ba1208fd 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/RowSizeEstimatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/RowSizeEstimatorTest.php
@@ -3,40 +3,45 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Category\Product;
-/**
- * Class RowSizeEstimatorTest
- * @package Magento\Catalog\Test\Unit\Model\Indexer\Category
- */
-class RowSizeEstimatorTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Category\Product\RowSizeEstimator;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class RowSizeEstimatorTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $resourceConnectionMock;
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Product\RowSizeEstimator
+ * @var RowSizeEstimator
*/
private $model;
- protected function setUp()
+ protected function setUp(): void
{
- $this->resourceConnectionMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class)
+ $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
->disableOriginalConstructor()
->getMock();
- $this->model = new \Magento\Catalog\Model\Indexer\Category\Product\RowSizeEstimator(
+ $this->model = new RowSizeEstimator(
$this->resourceConnectionMock
);
}
public function testEstimateRowSize()
{
- $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
+ $connectionMock = $this->getMockBuilder(AdapterInterface::class)
->getMock();
- $storeGroupCounterMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $storeGroupCounterMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
$this->resourceConnectionMock->expects($this->exactly(2))
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php
index f7dde23e1510e..693c89954de22 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php
@@ -3,54 +3,68 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Category;
-class ProductTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Indexer\Category\Product;
+use Magento\Catalog\Model\Indexer\Category\Product\Action\Full;
+use Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory;
+use Magento\Catalog\Model\Indexer\Category\Product\Action\Rows;
+use Magento\Catalog\Model\Indexer\Category\Product\Action\RowsFactory;
+use Magento\Framework\Indexer\CacheContext;
+use Magento\Framework\Indexer\IndexerInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ProductTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Product
+ * @var Product
*/
protected $model;
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var FullFactory|MockObject
*/
protected $fullMock;
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Product\Action\RowsFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var RowsFactory|MockObject
*/
protected $rowsMock;
/**
- * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerInterface|MockObject
*/
protected $indexerMock;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
protected $indexerRegistryMock;
/**
- * @var \Magento\Framework\Indexer\CacheContext|\PHPUnit_Framework_MockObject_MockObject
+ * @var CacheContext|MockObject
*/
protected $cacheContextMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->fullMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory::class,
+ FullFactory::class,
['create']
);
$this->rowsMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Category\Product\Action\RowsFactory::class,
+ RowsFactory::class,
['create']
);
$this->indexerMock = $this->getMockForAbstractClass(
- \Magento\Framework\Indexer\IndexerInterface::class,
+ IndexerInterface::class,
[],
'',
false,
@@ -60,20 +74,20 @@ protected function setUp()
);
$this->indexerRegistryMock = $this->createPartialMock(
- \Magento\Framework\Indexer\IndexerRegistry::class,
+ IndexerRegistry::class,
['get']
);
- $this->model = new \Magento\Catalog\Model\Indexer\Category\Product(
+ $this->model = new Product(
$this->fullMock,
$this->rowsMock,
$this->indexerRegistryMock
);
- $this->cacheContextMock = $this->createMock(\Magento\Framework\Indexer\CacheContext::class);
+ $this->cacheContextMock = $this->createMock(CacheContext::class);
$cacheContextProperty = new \ReflectionProperty(
- \Magento\Catalog\Model\Indexer\Category\Product::class,
+ Product::class,
'cacheContext'
);
$cacheContextProperty->setAccessible(true);
@@ -87,7 +101,7 @@ public function testExecuteWithIndexerWorking()
$this->prepareIndexer();
$rowMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Category\Product\Action\Rows::class,
+ Rows::class,
['execute']
);
$rowMock->expects($this->at(0))->method('execute')->with($ids)->will($this->returnSelf());
@@ -104,7 +118,7 @@ public function testExecuteWithIndexerNotWorking()
$this->prepareIndexer();
$rowMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Category\Product\Action\Rows::class,
+ Rows::class,
['execute']
);
$rowMock->expects($this->once())->method('execute')->with($ids)->will($this->returnSelf());
@@ -113,7 +127,7 @@ public function testExecuteWithIndexerNotWorking()
$this->cacheContextMock->expects($this->once())
->method('registerEntities')
- ->with(\Magento\Catalog\Model\Category::CACHE_TAG, $ids);
+ ->with(Category::CACHE_TAG, $ids);
$this->model->execute($ids);
}
@@ -122,14 +136,14 @@ protected function prepareIndexer()
{
$this->indexerRegistryMock->expects($this->any())
->method('get')
- ->with(\Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID)
+ ->with(Product::INDEXER_ID)
->will($this->returnValue($this->indexerMock));
}
public function testExecuteFull()
{
- /** @var \Magento\Catalog\Model\Indexer\Category\Product\Action\Full $productIndexerFlatFull */
- $productIndexerFlatFull = $this->createMock(\Magento\Catalog\Model\Indexer\Category\Product\Action\Full::class);
+ /** @var Full $productIndexerFlatFull */
+ $productIndexerFlatFull = $this->createMock(Full::class);
$this->fullMock->expects($this->once())
->method('create')
->willReturn($productIndexerFlatFull);
@@ -137,7 +151,7 @@ public function testExecuteFull()
->method('execute');
$this->cacheContextMock->expects($this->once())
->method('registerTags')
- ->with([\Magento\Catalog\Model\Category::CACHE_TAG]);
+ ->with([Category::CACHE_TAG]);
$this->model->executeFull();
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Category/Plugin/ImportTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Category/Plugin/ImportTest.php
index ce6166f6f510e..2dafc07ffee15 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Category/Plugin/ImportTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Category/Plugin/ImportTest.php
@@ -3,19 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Category\Plugin;
-class ImportTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Category\Processor;
+use Magento\ImportExport\Model\Import;
+use PHPUnit\Framework\TestCase;
+
+class ImportTest extends TestCase
{
public function testAfterImportSource()
{
- $processorMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Category\Processor::class)
+ $processorMock = $this->getMockBuilder(Processor::class)
->disableOriginalConstructor()
->getMock();
$processorMock->expects($this->once())
->method('markIndexerAsInvalid');
- $subjectMock = $this->getMockBuilder(\Magento\ImportExport\Model\Import::class)
+ $subjectMock = $this->getMockBuilder(Import::class)
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php
index 4e6659f85f5df..42c0822ac83a9 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php
@@ -3,54 +3,71 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product;
-class CategoryTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Category\Product;
+use Magento\Catalog\Model\Indexer\Category\Product\Action\Full;
+use Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory;
+use Magento\Catalog\Model\Indexer\Product\Category;
+use Magento\Catalog\Model\Indexer\Product\Category\Action\Rows;
+use Magento\Catalog\Model\Indexer\Product\Category\Action\RowsFactory;
+use Magento\Framework\Indexer\CacheContext;
+use Magento\Framework\Indexer\IndexerInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
+class CategoryTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Product
+ * @var Product
*/
protected $model;
/**
- * @var \Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var FullFactory|MockObject
*/
protected $fullMock;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Category\Action\RowsFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var RowsFactory|MockObject
*/
protected $rowsMock;
/**
- * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerInterface|MockObject
*/
protected $indexerMock;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
protected $indexerRegistryMock;
/**
- * @var \Magento\Framework\Indexer\CacheContext|\PHPUnit_Framework_MockObject_MockObject
+ * @var CacheContext|MockObject
*/
protected $cacheContextMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->fullMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory::class,
+ FullFactory::class,
['create']
);
$this->rowsMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Product\Category\Action\RowsFactory::class,
+ RowsFactory::class,
['create']
);
$this->indexerMock = $this->getMockForAbstractClass(
- \Magento\Framework\Indexer\IndexerInterface::class,
+ IndexerInterface::class,
[],
'',
false,
@@ -60,20 +77,20 @@ protected function setUp()
);
$this->indexerRegistryMock = $this->createPartialMock(
- \Magento\Framework\Indexer\IndexerRegistry::class,
+ IndexerRegistry::class,
['get']
);
- $this->model = new \Magento\Catalog\Model\Indexer\Product\Category(
+ $this->model = new Category(
$this->fullMock,
$this->rowsMock,
$this->indexerRegistryMock
);
- $this->cacheContextMock = $this->createMock(\Magento\Framework\Indexer\CacheContext::class);
+ $this->cacheContextMock = $this->createMock(CacheContext::class);
$cacheContextProperty = new \ReflectionProperty(
- \Magento\Catalog\Model\Indexer\Category\Product::class,
+ Product::class,
'cacheContext'
);
$cacheContextProperty->setAccessible(true);
@@ -87,7 +104,7 @@ public function testExecuteWithIndexerWorking()
$this->prepareIndexer();
$rowMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Product\Category\Action\Rows::class,
+ Rows::class,
['execute']
);
$rowMock->expects($this->at(0))->method('execute')->with($ids)->will($this->returnSelf());
@@ -104,7 +121,7 @@ public function testExecuteWithIndexerNotWorking()
$this->prepareIndexer();
$rowMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Product\Category\Action\Rows::class,
+ Rows::class,
['execute']
);
$rowMock->expects($this->once())->method('execute')->with($ids)->will($this->returnSelf());
@@ -122,14 +139,14 @@ protected function prepareIndexer()
{
$this->indexerRegistryMock->expects($this->any())
->method('get')
- ->with(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID)
+ ->with(Category::INDEXER_ID)
->will($this->returnValue($this->indexerMock));
}
public function testExecuteFull()
{
- /** @var \Magento\Catalog\Model\Indexer\Category\Product\Action\Full $productIndexerFlatFull */
- $productIndexerFlatFull = $this->createMock(\Magento\Catalog\Model\Indexer\Category\Product\Action\Full::class);
+ /** @var Full $productIndexerFlatFull */
+ $productIndexerFlatFull = $this->createMock(Full::class);
$this->fullMock->expects($this->once())
->method('create')
->willReturn($productIndexerFlatFull);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php
index 6ad14af44304e..fd7e8641397ce 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php
@@ -3,48 +3,61 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Eav;
-class AbstractActionTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Eav\AbstractAction;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Decimal;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Source;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\Exception\LocalizedException;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class AbstractActionTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Eav\AbstractAction|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractAction|MockObject
*/
protected $_model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_eavDecimalFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_eavSourceFactoryMock;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $scopeConfig;
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->_eavDecimalFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory::class,
+ DecimalFactory::class,
['create']
);
$this->_eavSourceFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory::class,
+ SourceFactory::class,
['create']
);
- $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
+ $this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->_model = $this->getMockForAbstractClass(
- \Magento\Catalog\Model\Indexer\Product\Eav\AbstractAction::class,
+ AbstractAction::class,
[
$this->_eavDecimalFactoryMock,
$this->_eavSourceFactoryMock,
@@ -74,12 +87,10 @@ public function testGetIndexers()
$this->assertEquals($expectedIndexers, $this->_model->getIndexers());
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Unknown EAV indexer type "unknown_type".
- */
public function testGetIndexerWithUnknownTypeThrowsException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('Unknown EAV indexer type "unknown_type".');
$this->_eavSourceFactoryMock->expects($this->once())
->method('create')
->will($this->returnValue('return_value'));
@@ -93,7 +104,7 @@ public function testGetIndexerWithUnknownTypeThrowsException()
/**
* @return void
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
public function testGetIndexer()
{
@@ -114,11 +125,11 @@ public function testGetIndexer()
*/
public function testReindexWithoutArgumentsExecutesReindexAll()
{
- $eavSource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Source::class)
+ $eavSource = $this->getMockBuilder(Source::class)
->disableOriginalConstructor()
->getMock();
- $eavDecimal = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Decimal::class)
+ $eavDecimal = $this->getMockBuilder(Decimal::class)
->disableOriginalConstructor()
->getMock();
@@ -157,14 +168,14 @@ public function testReindexWithNotNullArgumentExecutesReindexEntities(
) : void {
$reindexIds = array_unique(array_merge($ids, $parentIds, $childIds));
- $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
+ $connectionMock = $this->getMockBuilder(AdapterInterface::class)
->getMockForAbstractClass();
- $eavSource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Source::class)
+ $eavSource = $this->getMockBuilder(Source::class)
->disableOriginalConstructor()
->getMock();
- $eavDecimal = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Decimal::class)
+ $eavDecimal = $this->getMockBuilder(Decimal::class)
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php
index 2e1cff834fd34..398121eebf185 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php
@@ -11,26 +11,27 @@
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Indexer\Product\Eav\Action\Full;
use Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\BatchSizeCalculator;
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Decimal;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory;
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Source;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Query\Generator;
use Magento\Framework\DB\Select;
use Magento\Framework\EntityManager\EntityMetadataInterface;
-use Magento\Framework\Exception\LocalizedException;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalFactory;
-use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\SourceFactory;
use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Indexer\BatchProviderInterface;
-use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\BatchSizeCalculator;
-use PHPUnit\Framework\MockObject\MockObject as MockObject;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class FullTest extends \PHPUnit\Framework\TestCase
+class FullTest extends TestCase
{
/**
* @var Full|MockObject
@@ -80,7 +81,7 @@ class FullTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->eavDecimalFactory = $this->createPartialMock(DecimalFactory::class, ['create']);
$this->eavSourceFactory = $this->createPartialMock(SourceFactory::class, ['create']);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowTest.php
index cbae3c28d6548..df8940d1f6a95 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowTest.php
@@ -3,29 +3,31 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Eav\Action;
+use Magento\Catalog\Model\Indexer\Product\Eav\Action\Row;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class RowTest extends \PHPUnit\Framework\TestCase
+class RowTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Eav\Action\Row
+ * @var Row
*/
protected $_model;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
- $this->_model = $objectManager->getObject(\Magento\Catalog\Model\Indexer\Product\Eav\Action\Row::class);
+ $this->_model = $objectManager->getObject(Row::class);
}
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage We can't rebuild the index for an undefined product.
- */
public function testEmptyId()
{
+ $this->expectException('Magento\Framework\Exception\InputException');
+ $this->expectExceptionMessage('We can\'t rebuild the index for an undefined product.');
$this->_model->execute(null);
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowsTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowsTest.php
index 4bfc28a6f9b01..1306b67642ee4 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/RowsTest.php
@@ -3,29 +3,31 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Eav\Action;
+use Magento\Catalog\Model\Indexer\Product\Eav\Action\Rows;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class RowsTest extends \PHPUnit\Framework\TestCase
+class RowsTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Eav\Action\Rows
+ * @var Rows
*/
protected $_model;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
- $this->_model = $objectManager->getObject(\Magento\Catalog\Model\Indexer\Product\Eav\Action\Rows::class);
+ $this->_model = $objectManager->getObject(Rows::class);
}
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Bad value was supplied.
- */
public function testEmptyIds()
{
+ $this->expectException('Magento\Framework\Exception\InputException');
+ $this->expectExceptionMessage('Bad value was supplied.');
$this->_model->execute(null);
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilterTest.php
index e4ee414e03ae0..642017c2ecf46 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilterTest.php
@@ -3,13 +3,22 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Eav\Plugin\AttributeSet;
-class IndexableAttributeFilterTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Eav\Plugin\AttributeSet\IndexableAttributeFilter;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory;
+use Magento\Eav\Model\Entity\Attribute\Group;
+use Magento\Eav\Model\Entity\Attribute\Set;
+use PHPUnit\Framework\TestCase;
+
+class IndexableAttributeFilterTest extends TestCase
{
public function testFilter()
{
- $catalogResourceMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
+ $catalogResourceMock = $this->getMockBuilder(Attribute::class)
->disableOriginalConstructor()
->setMethods(['load', 'isIndexable', '__wakeup'])
->getMock();
@@ -24,7 +33,7 @@ public function testFilter()
->will($this->returnValue(false));
$eavAttributeFactoryMock = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory::class
+ AttributeFactory::class
)
->disableOriginalConstructor()
->setMethods(['create'])
@@ -57,7 +66,7 @@ public function testFilter()
$attributes = [$attributeMock1, $attributeMock2];
- $groupMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Group::class)
+ $groupMock = $this->getMockBuilder(Group::class)
->disableOriginalConstructor()
->setMethods(['getAttributes', '__wakeup'])
->getMock();
@@ -65,7 +74,7 @@ public function testFilter()
->method('getAttributes')
->will($this->returnValue($attributes));
- $attributeSetMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Set::class)
+ $attributeSetMock = $this->getMockBuilder(Set::class)
->disableOriginalConstructor()
->setMethods(['getGroups', '__wakeup'])
->getMock();
@@ -73,7 +82,7 @@ public function testFilter()
->method('getGroups')
->will($this->returnValue([$groupMock]));
- $model = new \Magento\Catalog\Model\Indexer\Product\Eav\Plugin\AttributeSet\IndexableAttributeFilter(
+ $model = new IndexableAttributeFilter(
$eavAttributeFactoryMock
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSetTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSetTest.php
index de27dfed4fb30..e2c5fe6459b75 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSetTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/AttributeSetTest.php
@@ -3,16 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Eav\Plugin;
+use Magento\Catalog\Model\Indexer\Product\Eav\Plugin\AttributeSet;
use Magento\Catalog\Model\Indexer\Product\Eav\Plugin\AttributeSet\IndexableAttributeFilter;
+use Magento\Catalog\Model\Indexer\Product\Eav\Processor;
use Magento\Eav\Model\Entity\Attribute\Set as EavAttributeSet;
use Magento\Eav\Model\Entity\Attribute\SetFactory;
-use Magento\Catalog\Model\Indexer\Product\Eav\Processor;
-use Magento\Catalog\Model\Indexer\Product\Eav\Plugin\AttributeSet;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class AttributeSetTest extends \PHPUnit\Framework\TestCase
+class AttributeSetTest extends TestCase
{
/**
* @var ObjectManager
@@ -25,31 +29,31 @@ class AttributeSetTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var Processor|\PHPUnit_Framework_MockObject_MockObject
+ * @var Processor|MockObject
*/
private $eavProcessorMock;
/**
- * @var IndexableAttributeFilter|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexableAttributeFilter|MockObject
*/
private $filterMock;
/**
- * @var EavAttributeSet|\PHPUnit_Framework_MockObject_MockObject
+ * @var EavAttributeSet|MockObject
*/
private $subjectMock;
/**
- * @var SetFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var SetFactory|MockObject
*/
private $setFactoryMock;
/**
- * @var EavAttributeSet|\PHPUnit_Framework_MockObject_MockObject
+ * @var EavAttributeSet|MockObject
*/
private $originalSetMock;
- public function setUp()
+ public function setUp(): void
{
$this->filterMock = $this->createMock(IndexableAttributeFilter::class);
$this->subjectMock = $this->createMock(EavAttributeSet::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/ImportTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/ImportTest.php
index c342a6f41f714..ec7b531fb8b65 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/ImportTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/ImportTest.php
@@ -3,19 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Eav\Plugin;
-class ImportTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Eav\Processor;
+use Magento\ImportExport\Model\Import;
+use PHPUnit\Framework\TestCase;
+
+class ImportTest extends TestCase
{
public function testAfterImportSource()
{
- $eavProcessorMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Eav\Processor::class)
+ $eavProcessorMock = $this->getMockBuilder(Processor::class)
->disableOriginalConstructor()
->getMock();
$eavProcessorMock->expects($this->once())
->method('markIndexerAsInvalid');
- $subjectMock = $this->getMockBuilder(\Magento\ImportExport\Model\Import::class)
+ $subjectMock = $this->getMockBuilder(Import::class)
->disableOriginalConstructor()
->getMock();
$import = new \stdClass();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/StoreViewTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/StoreViewTest.php
index 3f280e30c61c8..a043c5f3cad28 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/StoreViewTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/StoreViewTest.php
@@ -3,9 +3,17 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Eav\Plugin;
-class StoreViewTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Eav\Plugin\StoreView;
+use Magento\Catalog\Model\Indexer\Product\Eav\Processor;
+use Magento\Framework\Model\AbstractModel;
+use Magento\Store\Model\ResourceModel\Store;
+use PHPUnit\Framework\TestCase;
+
+class StoreViewTest extends TestCase
{
/**
* @param array $data
@@ -13,18 +21,18 @@ class StoreViewTest extends \PHPUnit\Framework\TestCase
*/
public function testBeforeSave(array $data)
{
- $eavProcessorMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Eav\Processor::class)
+ $eavProcessorMock = $this->getMockBuilder(Processor::class)
->disableOriginalConstructor()
->getMock();
$matcher = $data['matcher'];
$eavProcessorMock->expects($this->$matcher())
->method('markIndexerAsInvalid');
- $subjectMock = $this->getMockBuilder(\Magento\Store\Model\ResourceModel\Store::class)
+ $subjectMock = $this->getMockBuilder(Store::class)
->disableOriginalConstructor()
->getMock();
- $objectMock = $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class)
+ $objectMock = $this->getMockBuilder(AbstractModel::class)
->disableOriginalConstructor()
->setMethods(['getId', 'dataHasChangedFor', 'getIsActive', '__wakeup'])
->getMock();
@@ -39,7 +47,7 @@ public function testBeforeSave(array $data)
->method('getIsActive')
->will($this->returnValue($data['is_active']));
- $model = new \Magento\Catalog\Model\Indexer\Product\Eav\Plugin\StoreView($eavProcessorMock);
+ $model = new StoreView($eavProcessorMock);
$model->beforeSave($subjectMock, $objectMock);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/EavTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/EavTest.php
index 892af61b3886f..41eb2281cf553 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/EavTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/EavTest.php
@@ -3,65 +3,76 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product;
-class EavTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Indexer\Product\Eav;
+use Magento\Catalog\Model\Indexer\Product\Eav\Action\Full;
+use Magento\Catalog\Model\Indexer\Product\Eav\Action\Row;
+use Magento\Catalog\Model\Indexer\Product\Eav\Action\Rows;
+use Magento\Catalog\Model\Product;
+use Magento\Framework\Indexer\CacheContext;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class EavTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Eav
- */
- protected $_model;
-
- /**
- * @var \Magento\Catalog\Model\Indexer\Product\Eav\Action\Row|\PHPUnit_Framework_MockObject_MockObject
+ * @var Row|MockObject
*/
protected $_productEavIndexerRow;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Eav\Action\Rows|\PHPUnit_Framework_MockObject_MockObject
+ * @var Rows|MockObject
*/
protected $_productEavIndexerRows;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Eav\Action\Full|\PHPUnit_Framework_MockObject_MockObject
+ * @var Full|MockObject
*/
protected $_productEavIndexerFull;
/**
- * @var \Magento\Framework\Indexer\CacheContext|\PHPUnit_Framework_MockObject_MockObject
+ * @var CacheContext|MockObject
*/
protected $cacheContextMock;
+ /**
+ * @var Eav
+ */
+ private $model;
- protected function setUp()
+ protected function setUp(): void
{
$this->_productEavIndexerRow = $this->getMockBuilder(
- \Magento\Catalog\Model\Indexer\Product\Eav\Action\Row::class
+ Row::class
)
->disableOriginalConstructor()
->getMock();
$this->_productEavIndexerRows = $this->getMockBuilder(
- \Magento\Catalog\Model\Indexer\Product\Eav\Action\Rows::class
+ Rows::class
)
->disableOriginalConstructor()
->getMock();
$this->_productEavIndexerFull = $this->getMockBuilder(
- \Magento\Catalog\Model\Indexer\Product\Eav\Action\Full::class
+ Full::class
)
->disableOriginalConstructor()
->getMock();
- $this->model = new \Magento\Catalog\Model\Indexer\Product\Eav(
+ $this->model = new Eav(
$this->_productEavIndexerRow,
$this->_productEavIndexerRows,
$this->_productEavIndexerFull
);
- $this->cacheContextMock = $this->createMock(\Magento\Framework\Indexer\CacheContext::class);
+ $this->cacheContextMock = $this->createMock(CacheContext::class);
$cacheContextProperty = new \ReflectionProperty(
- \Magento\Catalog\Model\Indexer\Product\Eav::class,
+ Eav::class,
'cacheContext'
);
$cacheContextProperty->setAccessible(true);
@@ -77,7 +88,7 @@ public function testExecute()
$this->cacheContextMock->expects($this->once())
->method('registerEntities')
- ->with(\Magento\Catalog\Model\Product::CACHE_TAG, $ids);
+ ->with(Product::CACHE_TAG, $ids);
$this->model->execute($ids);
}
@@ -102,8 +113,8 @@ public function testExecuteFull()
->method('registerTags')
->with(
[
- \Magento\Catalog\Model\Category::CACHE_TAG,
- \Magento\Catalog\Model\Product::CACHE_TAG
+ Category::CACHE_TAG,
+ Product::CACHE_TAG
]
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/EraserTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/EraserTest.php
index e1e2816d44220..a0b34626e9211 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/EraserTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/EraserTest.php
@@ -4,45 +4,56 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat\Action;
-class EraserTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Helper\Product\Flat\Indexer;
+use Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class EraserTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $connection;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $indexerHelper;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $storeManager;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser
+ * @var Eraser
*/
protected $model;
- protected function setUp()
+ protected function setUp(): void
{
- $resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
- $this->connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
+ $resource = $this->createMock(ResourceConnection::class);
+ $this->connection = $this->createMock(AdapterInterface::class);
$resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
- $this->indexerHelper = $this->createMock(\Magento\Catalog\Helper\Product\Flat\Indexer::class);
+ $this->indexerHelper = $this->createMock(Indexer::class);
$this->indexerHelper->expects($this->any())->method('getTable')->will($this->returnArgument(0));
$this->indexerHelper->expects($this->any())->method('getFlatTableName')->will($this->returnValueMap([
[1, 'store_1_flat'],
[2, 'store_2_flat'],
]));
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->model = new \Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser(
+ $this->storeManager = $this->createMock(StoreManagerInterface::class);
+ $this->model = new Eraser(
$resource,
$this->indexerHelper,
$this->storeManager
@@ -52,7 +63,7 @@ protected function setUp()
public function testRemoveDeletedProducts()
{
$productsToDeleteIds = [1, 2];
- $select = $this->createMock(\Magento\Framework\DB\Select::class);
+ $select = $this->createMock(Select::class);
$select->expects($this->once())
->method('from')
->with(['product_table' => 'catalog_product_entity'])
@@ -76,9 +87,9 @@ public function testRemoveDeletedProducts()
public function testDeleteProductsFromStoreForAllStores()
{
- $store1 = $this->createMock(\Magento\Store\Model\Store::class);
+ $store1 = $this->createMock(Store::class);
$store1->expects($this->any())->method('getId')->will($this->returnValue(1));
- $store2 = $this->createMock(\Magento\Store\Model\Store::class);
+ $store2 = $this->createMock(Store::class);
$store2->expects($this->any())->method('getId')->will($this->returnValue(2));
$this->storeManager->expects($this->once())->method('getStores')
->will($this->returnValue([$store1, $store2]));
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowTest.php
index 61fad897c6418..0abd305cb22fb 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowTest.php
@@ -3,20 +3,35 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat\Action;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser;
+use Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer;
+use Magento\Catalog\Model\Indexer\Product\Flat\Action\Row;
+use Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder;
+use Magento\Eav\Model\Entity\Attribute;
+use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use Magento\Framework\EntityManager\EntityMetadataInterface;
+use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class RowTest extends \PHPUnit\Framework\TestCase
+class RowTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\Action\Row
+ * @var Row
*/
protected $model;
@@ -63,40 +78,40 @@ class RowTest extends \PHPUnit\Framework\TestCase
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
$attributeTable = 'catalog_product_entity_int';
$statusId = 22;
- $this->connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
- $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
+ $this->connection = $this->createMock(AdapterInterface::class);
+ $this->resource = $this->createMock(ResourceConnection::class);
$this->resource->expects($this->any())->method('getConnection')
->with('default')
->willReturn($this->connection);
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->store = $this->createMock(\Magento\Store\Model\Store::class);
+ $this->storeManager = $this->createMock(StoreManagerInterface::class);
+ $this->store = $this->createMock(Store::class);
$this->store->expects($this->any())->method('getId')->willReturn('store_id_1');
$this->storeManager->expects($this->any())->method('getStores')->willReturn([$this->store]);
- $this->flatItemEraser = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser::class);
- $this->flatItemWriter = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer::class);
+ $this->flatItemEraser = $this->createMock(Eraser::class);
+ $this->flatItemWriter = $this->createMock(Indexer::class);
$this->flatTableBuilder = $this->createMock(
- \Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder::class
+ FlatTableBuilder::class
);
$this->productIndexerHelper = $this->createMock(\Magento\Catalog\Helper\Product\Flat\Indexer::class);
- $statusAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
+ $statusAttributeMock = $this->getMockBuilder(Attribute::class)
->disableOriginalConstructor()
->getMock();
$this->productIndexerHelper->expects($this->any())->method('getAttribute')
->with('status')
->willReturn($statusAttributeMock);
- $backendMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class)
+ $backendMock = $this->getMockBuilder(AbstractBackend::class)
->disableOriginalConstructor()
->getMock();
$backendMock->expects($this->any())->method('getTable')->willReturn($attributeTable);
$statusAttributeMock->expects($this->any())->method('getBackend')->willReturn($backendMock);
$statusAttributeMock->expects($this->any())->method('getId')->willReturn($statusId);
- $selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $selectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
$this->connection->expects($this->any())->method('select')->willReturn($selectMock);
@@ -111,15 +126,15 @@ protected function setUp()
$this->connection->expects($this->any())->method('query')->with($selectMock)->willReturn($pdoMock);
$pdoMock->expects($this->any())->method('fetchColumn')->willReturn('1');
- $metadataPool = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class);
- $productMetadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadataInterface::class)
+ $metadataPool = $this->createMock(MetadataPool::class);
+ $productMetadata = $this->getMockBuilder(EntityMetadataInterface::class)
->getMockForAbstractClass();
$metadataPool->expects($this->any())->method('getMetadata')->with(ProductInterface::class)
->willReturn($productMetadata);
$productMetadata->expects($this->any())->method('getLinkField')->willReturn('entity_id');
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Indexer\Product\Flat\Action\Row::class,
+ Row::class,
[
'resource' => $this->resource,
'storeManager' => $this->storeManager,
@@ -133,12 +148,10 @@ protected function setUp()
$objectManager->setBackwardCompatibleProperty($this->model, 'metadataPool', $metadataPool);
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage We can't rebuild the index for an undefined product.
- */
public function testExecuteWithEmptyId()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('We can\'t rebuild the index for an undefined product.');
$this->model->execute(null);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/Rows/TableDataTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/Rows/TableDataTest.php
index cdb3403d850aa..870595a832039 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/Rows/TableDataTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/Rows/TableDataTest.php
@@ -3,38 +3,47 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat\Action\Rows;
+use Magento\Catalog\Helper\Product\Flat\Indexer;
+use Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows\TableData;
use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class TableDataTest extends \PHPUnit\Framework\TestCase
+class TableDataTest extends TestCase
{
/**
- * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
protected $_connectionMock;
/**
- * @var \Magento\Catalog\Helper\Product\Flat\Indexer|\PHPUnit_Framework_MockObject_MockObject
+ * @var Indexer|MockObject
*/
protected $_productIndexerHelper;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $_objectManager;
/**
- * @var Resource|\PHPUnit_Framework_MockObject_MockObject
+ * @var Resource|MockObject
*/
protected $_resourceMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->_connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
- $this->_resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
- $this->_productIndexerHelper = $this->createMock(\Magento\Catalog\Helper\Product\Flat\Indexer::class);
+ $this->_objectManager = new ObjectManager($this);
+ $this->_connectionMock = $this->createMock(AdapterInterface::class);
+ $this->_resourceMock = $this->createMock(ResourceConnection::class);
+ $this->_productIndexerHelper = $this->createMock(Indexer::class);
}
public function testMoveWithNonExistentFlatTable()
@@ -71,7 +80,7 @@ public function testMoveWithNonExistentFlatTable()
);
$model = $this->_objectManager->getObject(
- \Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows\TableData::class,
+ TableData::class,
['resource' => $this->_resourceMock, 'productIndexerHelper' => $this->_productIndexerHelper]
);
@@ -96,7 +105,7 @@ public function testMoveWithExistentFlatTable()
'column_3' => 'column_definition',
];
- $selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
+ $selectMock = $this->createMock(Select::class);
$selectMock->expects(
$this->once()
)->method(
@@ -105,7 +114,7 @@ public function testMoveWithExistentFlatTable()
['tf' => sprintf('%s_tmp_indexer', $flatTable)],
['column_2', 'column_3']
);
- $sql = md5(time());
+ $sql = hash('md5', (string)time());
$selectMock->expects(
$this->once()
)->method(
@@ -166,7 +175,7 @@ public function testMoveWithExistentFlatTable()
);
$model = $this->_objectManager->getObject(
- \Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows\TableData::class,
+ TableData::class,
['resource' => $this->_resourceMock, 'productIndexerHelper' => $this->_productIndexerHelper]
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowsTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowsTest.php
index ecf4ffc7cb954..d55a64b652e57 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowsTest.php
@@ -3,82 +3,93 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat\Action;
+use Magento\Catalog\Helper\Product\Flat\Indexer;
+use Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser;
+use Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows;
+use Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class RowsTest extends \PHPUnit\Framework\TestCase
+class RowsTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows
+ * @var Rows
*/
protected $_model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_storeManager;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_store;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_productIndexerHelper;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_resource;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_connection;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_flatItemWriter;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_flatItemEraser;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_flatTableBuilder;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
- $this->_connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
- $this->_resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
+ $this->_connection = $this->createMock(AdapterInterface::class);
+ $this->_resource = $this->createMock(ResourceConnection::class);
$this->_resource->expects($this->any())->method('getConnection')
->with('default')
->will($this->returnValue($this->_connection));
- $this->_storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->_store = $this->createMock(\Magento\Store\Model\Store::class);
+ $this->_storeManager = $this->createMock(StoreManagerInterface::class);
+ $this->_store = $this->createMock(Store::class);
$this->_store->expects($this->any())->method('getId')->will($this->returnValue('store_id_1'));
$this->_storeManager->expects($this->any())->method('getStores')->will(
$this->returnValue([$this->_store])
);
- $this->_productIndexerHelper = $this->createMock(\Magento\Catalog\Helper\Product\Flat\Indexer::class);
- $this->_flatItemEraser = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser::class);
+ $this->_productIndexerHelper = $this->createMock(Indexer::class);
+ $this->_flatItemEraser = $this->createMock(Eraser::class);
$this->_flatItemWriter = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer::class);
$this->_flatTableBuilder = $this->createMock(
- \Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder::class
+ FlatTableBuilder::class
);
$this->_model = $objectManager->getObject(
- \Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows::class,
+ Rows::class,
[
'resource' => $this->_resource,
'storeManager' => $this->_storeManager,
@@ -90,12 +101,10 @@ protected function setUp()
);
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Bad value was supplied.
- */
public function testEmptyIds()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('Bad value was supplied.');
$this->_model->execute(null);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/FlatTableBuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/FlatTableBuilderTest.php
index 5bacba5457368..580e2d4ecd626 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/FlatTableBuilderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/FlatTableBuilderTest.php
@@ -3,92 +3,110 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Helper\Product\Flat\Indexer;
+use Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder;
+use Magento\Catalog\Model\Indexer\Product\Flat\TableDataInterface;
+use Magento\Eav\Model\Entity\Attribute;
+use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Ddl\Table;
+use Magento\Framework\DB\Select;
+use Magento\Framework\EntityManager\EntityMetadataInterface;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class FlatTableBuilderTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class FlatTableBuilderTest extends \PHPUnit\Framework\TestCase
+class FlatTableBuilderTest extends TestCase
{
/**
- * @var \Magento\Catalog\Helper\Product\Flat\Indexer|\PHPUnit_Framework_MockObject_MockObject
+ * @var Indexer|MockObject
*/
private $flatIndexerMock;
/**
- * @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceMock;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $scopeConfigMock;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManagerMock;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\TableDataInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var TableDataInterface|MockObject
*/
private $tableDataMock;
/**
- * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $connectionMock;
/**
- * @var \Magento\Framework\EntityManager\MetadataPool|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataPool|MockObject
*/
private $metadataPoolMock;
/**
- * @var \Magento\Framework\EntityManager\EntityMetadataInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var EntityMetadataInterface|MockObject
*/
private $metadataMock;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder
+ * @var FlatTableBuilder
*/
private $flatTableBuilder;
- protected function setUp()
+ protected function setUp(): void
{
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->flatIndexerMock = $this->getMockBuilder(\Magento\Catalog\Helper\Product\Flat\Indexer::class)
+ $objectManagerHelper = new ObjectManager($this);
+ $this->flatIndexerMock = $this->getMockBuilder(Indexer::class)
->disableOriginalConstructor()
->getMock();
- $this->resourceMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class)
+ $this->resourceMock = $this->getMockBuilder(ResourceConnection::class)
->disableOriginalConstructor()
->getMock();
- $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
+ $this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->tableDataMock = $this->getMockBuilder(
- \Magento\Catalog\Model\Indexer\Product\Flat\TableDataInterface::class
+ TableDataInterface::class
)->disableOriginalConstructor()->getMockForAbstractClass();
- $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
+ $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->metadataPoolMock = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class)
+ $this->metadataPoolMock = $this->getMockBuilder(MetadataPool::class)
->disableOriginalConstructor()
->getMock();
$this->metadataMock = $this->getMockBuilder(
- \Magento\Framework\EntityManager\EntityMetadataInterface::class
+ EntityMetadataInterface::class
)->disableOriginalConstructor()->getMockForAbstractClass();
$this->metadataMock->expects($this->any())->method('getLinkField')->willReturn('entity_id');
$this->flatTableBuilder = $objectManagerHelper->getObject(
- \Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder::class,
+ FlatTableBuilder::class,
[
'productIndexerHelper' => $this->flatIndexerMock,
'resource' => $this->resourceMock,
@@ -124,10 +142,10 @@ public function testBuild()
$this->flatIndexerMock->expects($this->exactly(3))->method('getFlatColumns')
->willReturnOnConsecutiveCalls([], [$eavCustomValueField => []], [$eavCustomValueField => []]);
$this->flatIndexerMock->expects($this->once())->method('getFlatIndexes')->willReturn([]);
- $statusAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
+ $statusAttributeMock = $this->getMockBuilder(Attribute::class)
->disableOriginalConstructor()
->getMock();
- $eavCustomAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
+ $eavCustomAttributeMock = $this->getMockBuilder(Attribute::class)
->disableOriginalConstructor()
->getMock();
$this->flatIndexerMock->expects($this->once())->method('getTablesStructure')
@@ -146,7 +164,7 @@ public function testBuild()
$this->flatIndexerMock->expects($this->once())->method('getAttribute')
->with('status')
->willReturn($statusAttributeMock);
- $backendMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class)
+ $backendMock = $this->getMockBuilder(AbstractBackend::class)
->disableOriginalConstructor()
->getMock();
$backendMock->expects($this->atLeastOnce())->method('getTable')->willReturn($attributeTable);
@@ -157,11 +175,11 @@ public function testBuild()
$backendMock
);
$statusAttributeMock->expects($this->atLeastOnce())->method('getId')->willReturn($statusId);
- $tableMock = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class)
+ $tableMock = $this->getMockBuilder(Table::class)
->disableOriginalConstructor()
->getMock();
$this->connectionMock->expects($this->any())->method('newTable')->willReturn($tableMock);
- $selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $selectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
$this->connectionMock->expects($this->atLeastOnce())->method('select')->willReturn($selectMock);
@@ -196,7 +214,7 @@ public function testBuild()
)->willReturnSelf();
$this->metadataPoolMock->expects($this->atLeastOnce())->method('getMetadata')->with(ProductInterface::class)
->willReturn($this->metadataMock);
- $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
+ $storeMock = $this->getMockBuilder(StoreInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->storeManagerMock->expects($this->once())->method('getStore')->with($storeId)->willReturn($storeMock);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/IndexerConfigDataTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/IndexerConfigDataTest.php
index 2f80f813f9a6e..7de2212562c1c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/IndexerConfigDataTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/IndexerConfigDataTest.php
@@ -3,14 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat\Plugin;
use Magento\Catalog\Model\Indexer\Product\Flat\Plugin\IndexerConfigData as IndexerConfigDataPlugin;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Catalog\Model\Indexer\Product\Flat\State as ProductFlatIndexerState;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Indexer\Model\Config\Data as ConfigData;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class IndexerConfigDataTest extends \PHPUnit\Framework\TestCase
+class IndexerConfigDataTest extends TestCase
{
/**
* @var IndexerConfigDataPlugin
@@ -23,16 +27,16 @@ class IndexerConfigDataTest extends \PHPUnit\Framework\TestCase
private $objectManagerHelper;
/**
- * @var ProductFlatIndexerState|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductFlatIndexerState|MockObject
*/
private $indexerStateMock;
/**
- * @var ConfigData|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConfigData|MockObject
*/
private $subjectMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->indexerStateMock = $this->getMockBuilder(ProductFlatIndexerState::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreGroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreGroupTest.php
index fdcb7ec449727..aa3dfcc8bc921 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreGroupTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreGroupTest.php
@@ -3,33 +3,42 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat\Plugin;
-class StoreGroupTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Flat\Plugin\StoreGroup;
+use Magento\Catalog\Model\Indexer\Product\Flat\Processor;
+use Magento\Store\Model\ResourceModel\Group;
+use Magento\Store\Model\Store;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class StoreGroupTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor|\PHPUnit_Framework_MockObject_MockObject
+ * @var Processor|MockObject
*/
protected $processorMock;
/**
- * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
+ * @var Store|MockObject
*/
protected $storeGroupMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $subjectMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->processorMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Product\Flat\Processor::class,
+ Processor::class,
['markIndexerAsInvalid']
);
- $this->subjectMock = $this->createMock(\Magento\Store\Model\ResourceModel\Group::class);
+ $this->subjectMock = $this->createMock(Group::class);
$this->storeGroupMock = $this->createPartialMock(
\Magento\Store\Model\Group::class,
['getId', '__wakeup', 'dataHasChangedFor']
@@ -47,7 +56,7 @@ public function testBeforeSave($matcherMethod, $storeId)
$this->storeGroupMock->expects($this->once())->method('getId')->will($this->returnValue($storeId));
- $model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\StoreGroup($this->processorMock);
+ $model = new StoreGroup($this->processorMock);
$model->beforeSave($this->subjectMock, $this->storeGroupMock);
}
@@ -72,7 +81,7 @@ public function testChangedWebsiteBeforeSave($matcherMethod, $websiteChanged)
$this->returnValue($websiteChanged)
);
- $model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\StoreGroup($this->processorMock);
+ $model = new StoreGroup($this->processorMock);
$model->beforeSave($this->subjectMock, $this->storeGroupMock);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreTest.php
index 5232ff6ad8c04..f8cf949b98701 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Plugin/StoreTest.php
@@ -3,35 +3,42 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat\Plugin;
-class StoreTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Flat\Processor;
+use Magento\Store\Model\Store;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class StoreTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor|\PHPUnit_Framework_MockObject_MockObject
+ * @var Processor|MockObject
*/
protected $processorMock;
/**
- * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
+ * @var Store|MockObject
*/
protected $storeMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $subjectMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->processorMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Product\Flat\Processor::class,
+ Processor::class,
['markIndexerAsInvalid']
);
$this->subjectMock = $this->createMock(\Magento\Store\Model\ResourceModel\Store::class);
$this->storeMock = $this->createPartialMock(
- \Magento\Store\Model\Store::class,
+ Store::class,
['getId', '__wakeup', 'dataHasChangedFor']
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php
index d30a8da0e77a2..b2f23d57a3119 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php
@@ -3,14 +3,22 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat;
use Magento\Catalog\Model\Indexer\Product\Flat\Processor;
-
-class ProcessorTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Flat\State;
+use Magento\Framework\Indexer\IndexerRegistry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Indexer\Model\Indexer;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ProcessorTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $_objectManager;
@@ -20,37 +28,37 @@ class ProcessorTest extends \PHPUnit\Framework\TestCase
protected $_model;
/**
- * @var \Magento\Indexer\Model\Indexer|\PHPUnit_Framework_MockObject_MockObject
+ * @var Indexer|MockObject
*/
protected $_indexerMock;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\State|\PHPUnit_Framework_MockObject_MockObject
+ * @var State|MockObject
*/
protected $_stateMock;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
protected $indexerRegistryMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->_objectManager = new ObjectManager($this);
- $this->_indexerMock = $this->createPartialMock(\Magento\Indexer\Model\Indexer::class, ['getId', 'invalidate']);
+ $this->_indexerMock = $this->createPartialMock(Indexer::class, ['getId', 'invalidate']);
$this->_indexerMock->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->_stateMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Product\Flat\State::class,
+ State::class,
['isFlatEnabled']
);
$this->indexerRegistryMock = $this->createPartialMock(
- \Magento\Framework\Indexer\IndexerRegistry::class,
+ IndexerRegistry::class,
['get']
);
$this->_model = $this->_objectManager->getObject(
- \Magento\Catalog\Model\Indexer\Product\Flat\Processor::class,
+ Processor::class,
[
'indexerRegistry' => $this->indexerRegistryMock,
'state' => $this->_stateMock
@@ -64,7 +72,7 @@ protected function setUp()
public function testGetIndexer()
{
$this->prepareIndexer();
- $this->assertInstanceOf(\Magento\Indexer\Model\Indexer::class, $this->_model->getIndexer());
+ $this->assertInstanceOf(Indexer::class, $this->_model->getIndexer());
}
/**
@@ -111,7 +119,7 @@ public function testReindexRow(
->method('isFlatEnabled')
->willReturn($isFlatEnabled);
- $indexerMock = $this->getMockBuilder(\Magento\Indexer\Model\Indexer::class)
+ $indexerMock = $this->getMockBuilder(Indexer::class)
->disableOriginalConstructor()
->getMock();
@@ -148,7 +156,7 @@ public function testReindexRowForce()
->method('isFlatEnabled')
->willReturn(true);
- $indexerMock = $this->getMockBuilder(\Magento\Indexer\Model\Indexer::class)
+ $indexerMock = $this->getMockBuilder(Indexer::class)
->disableOriginalConstructor()
->getMock();
@@ -183,7 +191,7 @@ public function testReindexList(
->method('isFlatEnabled')
->willReturn($isFlatEnabled);
- $indexerMock = $this->getMockBuilder(\Magento\Indexer\Model\Indexer::class)
+ $indexerMock = $this->getMockBuilder(Indexer::class)
->disableOriginalConstructor()
->getMock();
@@ -220,7 +228,7 @@ public function testReindexListForce()
->method('isFlatEnabled')
->willReturn(true);
- $indexerMock = $this->getMockBuilder(\Magento\Indexer\Model\Indexer::class)
+ $indexerMock = $this->getMockBuilder(Indexer::class)
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/StateTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/StateTest.php
index f4398b6800249..b93541f153251 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/StateTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/StateTest.php
@@ -3,29 +3,37 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat;
-class StateTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Flat\State;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Indexer\Model\Indexer;
+use PHPUnit\Framework\TestCase;
+
+class StateTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $_objectManager;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\State
+ * @var State
*/
protected $_model;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->_objectManager = new ObjectManager($this);
- $indexerMock = $this->createMock(\Magento\Indexer\Model\Indexer::class);
+ $indexerMock = $this->createMock(Indexer::class);
$flatIndexerHelperMock = $this->createMock(\Magento\Catalog\Helper\Product\Flat\Indexer::class);
- $configMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $configMock = $this->createMock(ScopeConfigInterface::class);
$this->_model = $this->_objectManager->getObject(
- \Magento\Catalog\Model\Indexer\Product\Flat\State::class,
+ State::class,
[
'scopeConfig' => $configMock,
'flatIndexer' => $indexerMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php
index 34cc5c70418b9..03b2ab7820635 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php
@@ -3,45 +3,56 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat\System\Config;
-class ModeTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Flat\Processor;
+use Magento\Catalog\Model\Indexer\Product\Flat\System\Config\Mode;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Indexer\IndexerInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Indexer\Model\Indexer\State;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ModeTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\System\Config\Mode
+ * @var Mode
*/
protected $model;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $configMock;
/**
- * @var \Magento\Indexer\Model\Indexer\State|\PHPUnit_Framework_MockObject_MockObject
+ * @var State|MockObject
*/
protected $indexerStateMock;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor|\PHPUnit_Framework_MockObject_MockObject
+ * @var Processor|MockObject
*/
protected $indexerProcessorMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->configMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $this->configMock = $this->createMock(ScopeConfigInterface::class);
$this->indexerStateMock = $this->createPartialMock(
- \Magento\Indexer\Model\Indexer\State::class,
+ State::class,
['loadByIndexer', 'setStatus', 'save', '__wakeup']
);
$this->indexerProcessorMock = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Product\Flat\Processor::class,
+ Processor::class,
['getIndexer']
);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Indexer\Product\Flat\System\Config\Mode::class,
+ Mode::class,
[
'config' => $this->configMock,
'indexerState' => $this->indexerStateMock,
@@ -173,7 +184,7 @@ public function testProcessValueOff($oldValue, $value)
$this->indexerStateMock->expects($this->never())->method('save');
$indexerMock = $this->getMockForAbstractClass(
- \Magento\Framework\Indexer\IndexerInterface::class,
+ IndexerInterface::class,
[],
'',
false,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Table/BuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Table/BuilderTest.php
index 2b43cd49d0628..d471ccb031453 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Table/BuilderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Table/BuilderTest.php
@@ -3,45 +3,51 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat\Table;
-/**
- * Class BuilderTest
- */
-class BuilderTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Flat\Table\Builder;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Ddl\Table;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class BuilderTest extends TestCase
{
/**
- * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $connectionMock;
public function testAddColumn()
{
- $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
+ $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class)
+ $table = $this->getMockBuilder(Table::class)
->disableOriginalConstructor()
->getMock();
$table->expects($this->once())->method('addColumn')
- ->with('test', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER)
+ ->with('test', Table::TYPE_INTEGER)
->willReturnSelf();
$tableName = 'test_table';
$this->connectionMock->expects($this->once())
->method('newTable')
->with($tableName)
->willReturn($table);
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
/**
- * @var $builder \Magento\Catalog\Model\Indexer\Product\Flat\Table\Builder
+ * @var Builder $builder
*/
$builder = $objectManagerHelper->getObject(
- \Magento\Catalog\Model\Indexer\Product\Flat\Table\Builder::class,
+ Builder::class,
[
'connection' => $this->connectionMock,
'tableName' => $tableName
]
);
- $this->assertEquals($builder, $builder->addColumn('test', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER));
+ $this->assertEquals($builder, $builder->addColumn('test', Table::TYPE_INTEGER));
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/TableDataTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/TableDataTest.php
index 5717c2f419cab..6caf40ab28481 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/TableDataTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/TableDataTest.php
@@ -3,32 +3,39 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Flat;
+use Magento\Catalog\Model\Indexer\Product\Flat\TableData;
use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class TableDataTest extends \PHPUnit\Framework\TestCase
+class TableDataTest extends TestCase
{
/**
- * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
protected $_connectionMock;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $_objectManager;
/**
- * @var Resource|\PHPUnit_Framework_MockObject_MockObject
+ * @var Resource|MockObject
*/
protected $_resourceMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->_connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
- $this->_resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
+ $this->_objectManager = new ObjectManager($this);
+ $this->_connectionMock = $this->createMock(AdapterInterface::class);
+ $this->_resourceMock = $this->createMock(ResourceConnection::class);
}
/**
@@ -74,7 +81,7 @@ public function testMove(
);
$model = $this->_objectManager->getObject(
- \Magento\Catalog\Model\Indexer\Product\Flat\TableData::class,
+ TableData::class,
['resource' => $this->_resourceMock]
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/FlatTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/FlatTest.php
index f45394b733dcf..d7bf299f166ed 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/FlatTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/FlatTest.php
@@ -3,60 +3,71 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Indexer\Product\Flat;
+use Magento\Catalog\Model\Indexer\Product\Flat\Action\Full;
+use Magento\Catalog\Model\Indexer\Product\Flat\Action\Row;
+use Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows;
+use Magento\Catalog\Model\Product;
+use Magento\Framework\Indexer\CacheContext;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class FlatTest extends \PHPUnit\Framework\TestCase
+class FlatTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat
+ * @var Flat
*/
private $model;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\Action\Row|\PHPUnit_Framework_MockObject_MockObject
+ * @var Row|MockObject
*/
private $productFlatIndexerRow;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows|\PHPUnit_Framework_MockObject_MockObject
+ * @var Rows|MockObject
*/
private $productFlatIndexerRows;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\Action\Full|\PHPUnit_Framework_MockObject_MockObject
+ * @var Full|MockObject
*/
private $productFlatIndexerFull;
/**
- * @var \Magento\Framework\Indexer\CacheContext|\PHPUnit_Framework_MockObject_MockObject
+ * @var CacheContext|MockObject
*/
protected $cacheContextMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->productFlatIndexerRow = $this->getMockBuilder(
- \Magento\Catalog\Model\Indexer\Product\Flat\Action\Row::class
+ Row::class
)
->disableOriginalConstructor()
->getMock();
$this->productFlatIndexerRows = $this->getMockBuilder(
- \Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows::class
+ Rows::class
)
->disableOriginalConstructor()
->getMock();
$this->productFlatIndexerFull = $this->getMockBuilder(
- \Magento\Catalog\Model\Indexer\Product\Flat\Action\Full::class
+ Full::class
)
->disableOriginalConstructor()
->getMock();
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Indexer\Product\Flat::class,
+ Flat::class,
[
'productFlatIndexerRow' => $this->productFlatIndexerRow,
'productFlatIndexerRows' => $this->productFlatIndexerRows,
@@ -64,10 +75,10 @@ protected function setUp()
]
);
- $this->cacheContextMock = $this->createMock(\Magento\Framework\Indexer\CacheContext::class);
+ $this->cacheContextMock = $this->createMock(CacheContext::class);
$cacheContextProperty = new \ReflectionProperty(
- \Magento\Catalog\Model\Indexer\Product\Flat::class,
+ Flat::class,
'cacheContext'
);
$cacheContextProperty->setAccessible(true);
@@ -81,7 +92,7 @@ public function testExecute()
$this->cacheContextMock->expects($this->once())
->method('registerEntities')
- ->with(\Magento\Catalog\Model\Product::CACHE_TAG, $ids);
+ ->with(Product::CACHE_TAG, $ids);
$this->model->execute($ids);
}
@@ -103,8 +114,8 @@ public function testExecuteFull()
->method('registerTags')
->with(
[
- \Magento\Catalog\Model\Category::CACHE_TAG,
- \Magento\Catalog\Model\Product::CACHE_TAG
+ Category::CACHE_TAG,
+ Product::CACHE_TAG
]
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/FullTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/FullTest.php
index de2c4eaf7dc67..2a3d95078396e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/FullTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/FullTest.php
@@ -3,23 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product;
use Magento\Catalog\Model\Indexer\Product\Full;
use Magento\Framework\Indexer\IndexerInterface;
-use PHPUnit\Framework\TestCase;
use Magento\Framework\Indexer\IndexerRegistry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
class FullTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManager;
/**
- * @var IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
private $indexerRegistryMock;
@@ -27,10 +30,10 @@ class FullTest extends TestCase
* @var Full
*/
private $full;
-
- public function setUp()
+
+ public function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
$this->indexerRegistryMock = $this->createMock(IndexerRegistry::class);
$this->full = $this->objectManager->getObject(
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowTest.php
index 336474f256ae1..d62316b0c3d6d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowTest.php
@@ -3,29 +3,32 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Price\Action;
+use Magento\Catalog\Model\Indexer\Product\Price\Action\Row;
+use Magento\Catalog\Model\Indexer\Product\Price\Action\Rows;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class RowTest extends \PHPUnit\Framework\TestCase
+class RowTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Price\Action\Rows
+ * @var Rows
*/
protected $_model;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
- $this->_model = $objectManager->getObject(\Magento\Catalog\Model\Indexer\Product\Price\Action\Row::class);
+ $this->_model = $objectManager->getObject(Row::class);
}
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage We can't rebuild the index for an undefined product.
- */
public function testEmptyId()
{
+ $this->expectException('Magento\Framework\Exception\InputException');
+ $this->expectExceptionMessage('We can\'t rebuild the index for an undefined product.');
$this->_model->execute(null);
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowsTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowsTest.php
index 31859ceb7ca2a..4242ab7b2e914 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Action/RowsTest.php
@@ -3,29 +3,31 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Price\Action;
+use Magento\Catalog\Model\Indexer\Product\Price\Action\Rows;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class RowsTest extends \PHPUnit\Framework\TestCase
+class RowsTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Price\Action\Rows
+ * @var Rows
*/
protected $_model;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
- $this->_model = $objectManager->getObject(\Magento\Catalog\Model\Indexer\Product\Price\Action\Rows::class);
+ $this->_model = $objectManager->getObject(Rows::class);
}
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Bad value was supplied.
- */
public function testEmptyIds()
{
+ $this->expectException('Magento\Framework\Exception\InputException');
+ $this->expectExceptionMessage('Bad value was supplied.');
$this->_model->execute(null);
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php
index 8e12ba7670638..2ca5cf9ef18d5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Price\Plugin;
use Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration;
@@ -14,11 +16,12 @@
use Magento\Framework\Indexer\DimensionFactory;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test for CustomerGroup plugin
*/
-class CustomerGroupTest extends \PHPUnit\Framework\TestCase
+class CustomerGroupTest extends TestCase
{
/**
* @var ObjectManager
@@ -50,7 +53,7 @@ class CustomerGroupTest extends \PHPUnit\Framework\TestCase
*/
private $proceedMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php
index f64789a2a3d82..6bea7d5105210 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php
@@ -3,48 +3,60 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Price\Plugin;
use Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration;
-
-class WebsiteTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website;
+use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer;
+use Magento\Framework\Indexer\Dimension;
+use Magento\Framework\Indexer\DimensionFactory;
+use Magento\Framework\Model\AbstractModel;
+use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Indexer\WebsiteDimensionProvider;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class WebsiteTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManager;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website
+ * @var Website
*/
protected $model;
/**
- * @var \Magento\Framework\Indexer\DimensionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var DimensionFactory|MockObject
*/
protected $dimensionFactory;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer|\PHPUnit_Framework_MockObject_MockObject
+ * @var TableMaintainer|MockObject
*/
protected $tableMaintainer;
/**
- * @var DimensionModeConfiguration|\PHPUnit_Framework_MockObject_MockObject
+ * @var DimensionModeConfiguration|MockObject
*/
protected $dimensionModeConfiguration;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
$this->dimensionFactory = $this->createPartialMock(
- \Magento\Framework\Indexer\DimensionFactory::class,
+ DimensionFactory::class,
['create']
);
$this->tableMaintainer = $this->createPartialMock(
- \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer::class,
+ TableMaintainer::class,
['dropTablesForDimensions', 'createTablesForDimensions']
);
@@ -54,7 +66,7 @@ protected function setUp()
);
$this->model = $this->objectManager->getObject(
- \Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website::class,
+ Website::class,
[
'dimensionFactory' => $this->dimensionFactory,
'tableMaintainer' => $this->tableMaintainer,
@@ -65,7 +77,7 @@ protected function setUp()
public function testAfterDelete()
{
- $dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class);
+ $dimensionMock = $this->createMock(Dimension::class);
$this->dimensionFactory->expects($this->once())->method('create')->willReturn(
$dimensionMock
@@ -75,12 +87,12 @@ public function testAfterDelete()
);
$this->dimensionModeConfiguration->expects($this->once())->method('getDimensionConfiguration')->willReturn(
- [\Magento\Store\Model\Indexer\WebsiteDimensionProvider::DIMENSION_NAME]
+ [WebsiteDimensionProvider::DIMENSION_NAME]
);
- $subjectMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class);
- $objectResourceMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class);
- $websiteMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class);
+ $subjectMock = $this->createMock(AbstractDb::class);
+ $objectResourceMock = $this->createMock(AbstractDb::class);
+ $websiteMock = $this->createMock(AbstractModel::class);
$websiteMock->expects($this->once())
->method('getId')
->willReturn(1);
@@ -93,7 +105,7 @@ public function testAfterDelete()
public function testAfterDeleteOnModeWithoutWebsiteDimension()
{
- $dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class);
+ $dimensionMock = $this->createMock(Dimension::class);
$this->dimensionFactory->expects($this->never())->method('create')->willReturn(
$dimensionMock
@@ -106,9 +118,9 @@ public function testAfterDeleteOnModeWithoutWebsiteDimension()
[]
);
- $subjectMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class);
- $objectResourceMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class);
- $websiteMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class);
+ $subjectMock = $this->createMock(AbstractDb::class);
+ $objectResourceMock = $this->createMock(AbstractDb::class);
+ $websiteMock = $this->createMock(AbstractModel::class);
$websiteMock->expects($this->once())
->method('getId')
->willReturn(1);
@@ -121,7 +133,7 @@ public function testAfterDeleteOnModeWithoutWebsiteDimension()
public function testAfterSave()
{
- $dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class);
+ $dimensionMock = $this->createMock(Dimension::class);
$this->dimensionFactory->expects($this->once())->method('create')->willReturn(
$dimensionMock
@@ -131,12 +143,12 @@ public function testAfterSave()
);
$this->dimensionModeConfiguration->expects($this->once())->method('getDimensionConfiguration')->willReturn(
- [\Magento\Store\Model\Indexer\WebsiteDimensionProvider::DIMENSION_NAME]
+ [WebsiteDimensionProvider::DIMENSION_NAME]
);
- $subjectMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class);
- $objectResourceMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class);
- $websiteMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class);
+ $subjectMock = $this->createMock(AbstractDb::class);
+ $objectResourceMock = $this->createMock(AbstractDb::class);
+ $websiteMock = $this->createMock(AbstractModel::class);
$websiteMock->expects($this->once())
->method('getId')
->willReturn(1);
@@ -152,7 +164,7 @@ public function testAfterSave()
public function testAfterSaveOnModeWithoutWebsiteDimension()
{
- $dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class);
+ $dimensionMock = $this->createMock(Dimension::class);
$this->dimensionFactory->expects($this->never())->method('create')->willReturn(
$dimensionMock
@@ -165,9 +177,9 @@ public function testAfterSaveOnModeWithoutWebsiteDimension()
[]
);
- $subjectMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class);
- $objectResourceMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class);
- $websiteMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class);
+ $subjectMock = $this->createMock(AbstractDb::class);
+ $objectResourceMock = $this->createMock(AbstractDb::class);
+ $websiteMock = $this->createMock(AbstractModel::class);
$websiteMock->expects($this->once())
->method('getId')
->willReturn(1);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php
index 4c26fdfbf4f64..2bf65e1b3ddbe 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php
@@ -3,47 +3,61 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Price\System\Config;
-class PriceScopeTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Price\Processor;
+use Magento\Catalog\Model\Indexer\Product\Price\System\Config\PriceScope;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Registry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Indexer\Model\Indexer;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class PriceScopeTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $_objectManager;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Price\System\Config\PriceScope
+ * @var PriceScope
*/
protected $_model;
/**
- * @var \Magento\Indexer\Model\Indexer|\PHPUnit_Framework_MockObject_MockObject
+ * @var Indexer|MockObject
*/
protected $_indexerMock;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
protected $indexerRegistryMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->_objectManager = new ObjectManager($this);
- $this->_indexerMock = $this->createPartialMock(\Magento\Indexer\Model\Indexer::class, ['load', 'invalidate']);
+ $this->_indexerMock = $this->createPartialMock(Indexer::class, ['load', 'invalidate']);
$this->indexerRegistryMock = $this->createPartialMock(
- \Magento\Framework\Indexer\IndexerRegistry::class,
+ IndexerRegistry::class,
['get']
);
- $contextMock = $this->createMock(\Magento\Framework\Model\Context::class);
- $registryMock = $this->createMock(\Magento\Framework\Registry::class);
- $storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $configMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $contextMock = $this->createMock(Context::class);
+ $registryMock = $this->createMock(Registry::class);
+ $storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $configMock = $this->createMock(ScopeConfigInterface::class);
$this->_model = $this->_objectManager->getObject(
- \Magento\Catalog\Model\Indexer\Product\Price\System\Config\PriceScope::class,
+ PriceScope::class,
[
'context' => $contextMock,
'registry' => $registryMock,
@@ -76,7 +90,7 @@ protected function prepareIndexer($countCall)
{
$this->indexerRegistryMock->expects($this->exactly($countCall))
->method('get')
- ->with(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID)
+ ->with(Processor::INDEXER_ID)
->will($this->returnValue($this->_indexerMock));
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/AvailabilityFlagTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/AvailabilityFlagTest.php
index 008fd04afadd4..0bbbf13d42409 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/AvailabilityFlagTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/AvailabilityFlagTest.php
@@ -3,12 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Category;
-use \Magento\Catalog\Model\Layer\Category\AvailabilityFlag;
+use Magento\Catalog\Model\Layer;
+use Magento\Catalog\Model\Layer\Category\AvailabilityFlag;
+use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
+use Magento\Catalog\Model\Layer\State;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class AvailabilityFlagTest extends \PHPUnit\Framework\TestCase
+class AvailabilityFlagTest extends TestCase
{
/**
* @var array
@@ -16,31 +22,31 @@ class AvailabilityFlagTest extends \PHPUnit\Framework\TestCase
protected $filters;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $filterMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $layerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $stateMock;
/**
- * @var \Magento\Catalog\Model\Layer\Category\AvailabilityFlag
+ * @var AvailabilityFlag
*/
protected $model;
- protected function setUp()
+ protected function setUp(): void
{
- $this->filterMock = $this->createMock(\Magento\Catalog\Model\Layer\Filter\AbstractFilter::class);
+ $this->filterMock = $this->createMock(AbstractFilter::class);
$this->filters = [$this->filterMock];
- $this->layerMock = $this->createMock(\Magento\Catalog\Model\Layer::class);
- $this->stateMock = $this->createMock(\Magento\Catalog\Model\Layer\State::class);
+ $this->layerMock = $this->createMock(Layer::class);
+ $this->stateMock = $this->createMock(State::class);
$this->model = new AvailabilityFlag();
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/CollectionFilterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/CollectionFilterTest.php
index d03efdc6994de..fdafb4a7b3ffa 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/CollectionFilterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/CollectionFilterTest.php
@@ -3,32 +3,39 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Category;
-use \Magento\Catalog\Model\Layer\Category\CollectionFilter;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Config;
+use Magento\Catalog\Model\Layer\Category\CollectionFilter;
+use Magento\Catalog\Model\Product\Visibility;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CollectionFilterTest extends \PHPUnit\Framework\TestCase
+class CollectionFilterTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $visibilityMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $catalogConfigMock;
/**
- * @var \Magento\Catalog\Model\Layer\Category\CollectionFilter
+ * @var CollectionFilter
*/
protected $model;
- protected function setUp()
+ protected function setUp(): void
{
- $this->visibilityMock = $this->createMock(\Magento\Catalog\Model\Product\Visibility::class);
- $this->catalogConfigMock = $this->createMock(\Magento\Catalog\Model\Config::class);
+ $this->visibilityMock = $this->createMock(Visibility::class);
+ $this->catalogConfigMock = $this->createMock(Config::class);
$this->model = new CollectionFilter($this->visibilityMock, $this->catalogConfigMock);
}
@@ -38,9 +45,9 @@ protected function setUp()
*/
public function testFilter()
{
- $collectionMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
+ $collectionMock = $this->createMock(Collection::class);
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(Category::class);
$categoryMock->expects($this->once())->method('getId');
$this->catalogConfigMock->expects($this->once())->method('getProductAttributes');
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/FilterableAttributeListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/FilterableAttributeListTest.php
index 8950dc7bec4d5..23c34bd881baa 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/FilterableAttributeListTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/FilterableAttributeListTest.php
@@ -3,36 +3,46 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Category;
-class FilterableAttributeListTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Layer\Search\FilterableAttributeList;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class FilterableAttributeListTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Layer\Search\FilterableAttributeList
+ * @var FilterableAttributeList
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory
+ * @var MockObject|CollectionFactory
*/
protected $collectionFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\StoreManagerInterface
+ * @var MockObject|StoreManagerInterface
*/
protected $storeManagerMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->collectionFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
- $this->model = new \Magento\Catalog\Model\Layer\Search\FilterableAttributeList(
+ $this->model = new FilterableAttributeList(
$this->collectionFactoryMock,
$this->storeManagerMock
);
@@ -40,13 +50,13 @@ protected function setUp()
public function testGetList()
{
- $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
+ $storeMock = $this->createMock(Store::class);
$this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock));
$storeId = 4321;
$storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId));
- $collectionMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class);
+ $collectionMock = $this->createMock(Collection::class);
$this->collectionFactoryMock
->expects($this->once())
->method('create')
@@ -55,7 +65,7 @@ public function testGetList()
$collectionMock
->expects($this->once())
->method('setItemObjectClass')
- ->with(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
+ ->with(Attribute::class)
->will($this->returnSelf());
$collectionMock
->expects($this->once())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/StateKeyTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/StateKeyTest.php
index 1f260475cd9db..c11bb0da1f274 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/StateKeyTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Category/StateKeyTest.php
@@ -3,32 +3,39 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Category;
-use \Magento\Catalog\Model\Layer\Category\StateKey;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Layer\Category\StateKey;
+use Magento\Customer\Model\Session;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class StateKeyTest extends \PHPUnit\Framework\TestCase
+class StateKeyTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $storeManagerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $customerSessionMock;
/**
- * @var \Magento\Catalog\Model\Layer\Category\StateKey
+ * @var StateKey
*/
protected $model;
- protected function setUp()
+ protected function setUp(): void
{
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class);
+ $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $this->customerSessionMock = $this->createMock(Session::class);
$this->model = new StateKey($this->storeManagerMock, $this->customerSessionMock);
}
@@ -38,10 +45,10 @@ protected function setUp()
*/
public function testToString()
{
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(Category::class);
$categoryMock->expects($this->once())->method('getId')->will($this->returnValue('1'));
- $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
+ $storeMock = $this->createMock(Store::class);
$this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock));
$storeMock->expects($this->once())->method('getId')->will($this->returnValue('2'));
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/AttributeTest.php
index cbf686f1cf8de..e5a80374bdd67 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/AttributeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/AttributeTest.php
@@ -3,18 +3,32 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Filter;
+use Magento\Catalog\Model\Layer;
+use Magento\Catalog\Model\Layer\Filter\Item;
+use Magento\Catalog\Model\Layer\Filter\Item\DataBuilder;
+use Magento\Catalog\Model\Layer\Filter\ItemFactory;
+use Magento\Catalog\Model\Layer\State;
+use Magento\Catalog\Model\ResourceModel\Layer\Filter\Attribute;
+use Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory;
+use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\Filter\StripTags;
+use Magento\Framework\Stdlib\StringUtils;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class AttributeTest extends \PHPUnit\Framework\TestCase
+class AttributeTest extends TestCase
{
- /** @var \Magento\Catalog\Model\ResourceModel\Layer\Filter\Attribute|MockObject */
+ /** @var Attribute|MockObject */
private $filterAttribute;
/**
@@ -22,62 +36,62 @@ class AttributeTest extends \PHPUnit\Framework\TestCase
*/
private $target;
- /** @var \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend|MockObject */
+ /** @var AbstractFrontend|MockObject */
private $frontend;
- /** @var \Magento\Catalog\Model\Layer\State|MockObject */
+ /** @var State|MockObject */
private $state;
/** @var \Magento\Eav\Model\Entity\Attribute|MockObject */
private $attribute;
- /** @var \Magento\Framework\App\RequestInterface|MockObject */
+ /** @var RequestInterface|MockObject */
private $request;
- /** @var \Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory|MockObject */
+ /** @var AttributeFactory|MockObject */
private $filterAttributeFactory;
- /** @var \Magento\Catalog\Model\Layer\Filter\ItemFactory|MockObject */
+ /** @var ItemFactory|MockObject */
private $filterItemFactory;
- /** @var \Magento\Store\Model\StoreManagerInterface|MockObject */
+ /** @var StoreManagerInterface|MockObject */
private $storeManager;
- /** @var \Magento\Catalog\Model\Layer|MockObject */
+ /** @var Layer|MockObject */
private $layer;
- /** @var \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder|MockObject */
+ /** @var DataBuilder|MockObject */
private $itemDataBuilder;
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- protected function setUp()
+ protected function setUp(): void
{
- /** @var \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory */
- $this->filterItemFactory = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\ItemFactory::class)
+ /** @var ItemFactory $filterItemFactory */
+ $this->filterItemFactory = $this->getMockBuilder(ItemFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */
- $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ /** @var StoreManagerInterface $storeManager */
+ $this->storeManager = $this->getMockBuilder(StoreManagerInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMockForAbstractClass();
- /** @var \Magento\Catalog\Model\Layer $layer */
- $this->layer = $this->getMockBuilder(\Magento\Catalog\Model\Layer::class)
+ /** @var Layer $layer */
+ $this->layer = $this->getMockBuilder(Layer::class)
->disableOriginalConstructor()
->setMethods(['getState'])
->getMock();
- /** @var \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder */
- $this->itemDataBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder::class)
+ /** @var DataBuilder $itemDataBuilder */
+ $this->itemDataBuilder = $this->getMockBuilder(DataBuilder::class)
->disableOriginalConstructor()
->setMethods(['addItemData', 'build'])
->getMock();
$this->filterAttribute = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Layer\Filter\Attribute::class
+ Attribute::class
)->disableOriginalConstructor()
->setMethods(['getCount', 'applyFilterToCollection'])
->getMock();
@@ -87,7 +101,7 @@ protected function setUp()
->will($this->returnSelf());
$this->filterAttributeFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory::class
+ AttributeFactory::class
)
->disableOriginalConstructor()
->setMethods(['create'])
@@ -97,7 +111,7 @@ protected function setUp()
->method('create')
->will($this->returnValue($this->filterAttribute));
- $this->state = $this->getMockBuilder(\Magento\Catalog\Model\Layer\State::class)
+ $this->state = $this->getMockBuilder(State::class)
->disableOriginalConstructor()
->setMethods(['addFilter'])
->getMock();
@@ -105,7 +119,7 @@ protected function setUp()
->method('getState')
->will($this->returnValue($this->state));
- $this->frontend = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend::class)
+ $this->frontend = $this->getMockBuilder(AbstractFrontend::class)
->disableOriginalConstructor()
->setMethods(['getOption', 'getSelectOptions'])
->getMock();
@@ -117,12 +131,12 @@ protected function setUp()
->method('getFrontend')
->will($this->returnValue($this->frontend));
- $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
+ $this->request = $this->getMockBuilder(RequestInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMockForAbstractClass();
- $stripTagsFilter = $this->getMockBuilder(\Magento\Framework\Filter\StripTags::class)
+ $stripTagsFilter = $this->getMockBuilder(StripTags::class)
->disableOriginalConstructor()
->setMethods(['filter'])
->getMock();
@@ -130,7 +144,7 @@ protected function setUp()
->method('filter')
->will($this->returnArgument(0));
- $string = $this->getMockBuilder(\Magento\Framework\Stdlib\StringUtils::class)
+ $string = $this->getMockBuilder(StringUtils::class)
->disableOriginalConstructor()
->setMethods(['strlen'])
->getMock();
@@ -254,11 +268,11 @@ public function testGetItems()
* @param string $label
* @param string $value
* @param int $count
- * @return \Magento\Catalog\Model\Layer\Filter\Item|MockObject
+ * @return Item|MockObject
*/
private function createFilterItem($index, $label, $value, $count)
{
- $filterItem = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Item::class)
+ $filterItem = $this->getMockBuilder(Item::class)
->disableOriginalConstructor()
->setMethods(['setFilter', 'setLabel', 'setValue', 'setCount'])
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/CategoryTest.php
index c9636005859e8..3761c0e69524c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/CategoryTest.php
@@ -3,25 +3,39 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Layer\Filter;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Layer;
+use Magento\Catalog\Model\Layer\Filter\DataProvider\Category as CategoryDataProvider;
+use Magento\Catalog\Model\Layer\Filter\DataProvider\CategoryFactory;
+use Magento\Catalog\Model\Layer\Filter\Item;
+use Magento\Catalog\Model\Layer\Filter\Item\DataBuilder;
+use Magento\Catalog\Model\Layer\Filter\ItemFactory;
+use Magento\Catalog\Model\Layer\State;
+use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollectionResourceModel;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\Escaper;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test for \Magento\Catalog\Model\Layer\Filter\Category
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CategoryTest extends \PHPUnit\Framework\TestCase
+class CategoryTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder
+ * @var DataBuilder
*/
private $itemDataBuilder;
/**
- * @var \Magento\Catalog\Model\Category|MockObject
+ * @var Category|MockObject
*/
private $category;
@@ -31,12 +45,12 @@ class CategoryTest extends \PHPUnit\Framework\TestCase
private $collection;
/**
- * @var \Magento\Catalog\Model\Layer|MockObject
+ * @var Layer|MockObject
*/
private $layer;
/**
- * @var \Magento\Catalog\Model\Layer\Filter\DataProvider\Category|MockObject
+ * @var CategoryDataProvider|MockObject
*/
private $dataProvider;
@@ -45,24 +59,24 @@ class CategoryTest extends \PHPUnit\Framework\TestCase
*/
private $target;
- /** @var \Magento\Framework\App\RequestInterface|MockObject */
+ /** @var RequestInterface|MockObject */
private $request;
- /** @var \Magento\Catalog\Model\Layer\Filter\ItemFactory|MockObject */
+ /** @var ItemFactory|MockObject */
private $filterItemFactory;
- protected function setUp()
+ protected function setUp(): void
{
- $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
+ $this->request = $this->getMockBuilder(RequestInterface::class)
->disableOriginalConstructor()
->setMethods(['getParam'])
->getMockForAbstractClass();
$dataProviderFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\Layer\Filter\DataProvider\CategoryFactory::class
+ CategoryFactory::class
)->disableOriginalConstructor()->setMethods(['create'])->getMock();
- $this->dataProvider = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\DataProvider\Category::class)
+ $this->dataProvider = $this->getMockBuilder(CategoryDataProvider::class)
->disableOriginalConstructor()
->setMethods(['setCategoryId', 'getCategory'])
->getMock();
@@ -71,7 +85,7 @@ protected function setUp()
->method('create')
->will($this->returnValue($this->dataProvider));
- $this->category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $this->category = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->setMethods(['getId', 'getChildrenCategories', 'getIsActive'])
->getMock();
@@ -80,12 +94,12 @@ protected function setUp()
->method('getCategory', 'isValid')
->will($this->returnValue($this->category));
- $this->layer = $this->getMockBuilder(\Magento\Catalog\Model\Layer::class)
+ $this->layer = $this->getMockBuilder(Layer::class)
->disableOriginalConstructor()
->setMethods(['getState', 'getProductCollection'])
->getMock();
- $this->state = $this->getMockBuilder(\Magento\Catalog\Model\Layer\State::class)
+ $this->state = $this->getMockBuilder(State::class)
->disableOriginalConstructor()
->setMethods(['addFilter'])
->getMock();
@@ -94,7 +108,7 @@ protected function setUp()
->will($this->returnValue($this->state));
$this->collection = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Product\Collection::class
+ ProductCollectionResourceModel::class
)
->disableOriginalConstructor()
->setMethods(['addCategoryFilter', 'getFacetedData', 'addCountToCategories'])
@@ -104,17 +118,17 @@ protected function setUp()
->method('getProductCollection')
->will($this->returnValue($this->collection));
- $this->itemDataBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder::class)
+ $this->itemDataBuilder = $this->getMockBuilder(DataBuilder::class)
->disableOriginalConstructor()
->setMethods(['addItemData', 'build'])
->getMock();
$this->filterItemFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\Layer\Filter\ItemFactory::class
+ ItemFactory::class
)->disableOriginalConstructor()->setMethods(['create'])->getMock();
$filterItem = $this->getMockBuilder(
- \Magento\Catalog\Model\Layer\Filter\Item::class
+ Item::class
)->disableOriginalConstructor()
->setMethods(['setFilter', 'setLabel', 'setValue', 'setCount'])
->getMock();
@@ -125,7 +139,7 @@ protected function setUp()
->method('create')
->will($this->returnValue($filterItem));
- $escaper = $this->getMockBuilder(\Magento\Framework\Escaper::class)
+ $escaper = $this->getMockBuilder(Escaper::class)
->disableOriginalConstructor()
->setMethods(['escapeHtml'])
->getMock();
@@ -146,7 +160,7 @@ protected function setUp()
);
}
- /** @var \Magento\Catalog\Model\Layer\State|MockObject */
+ /** @var State|MockObject */
private $state;
/**
@@ -244,7 +258,7 @@ public function testGetItems()
->method('getIsActive')
->will($this->returnValue(true));
- $category1 = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $category1 = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->setMethods(['getId', 'getName', 'getIsActive', 'getProductCount'])
->getMock();
@@ -261,7 +275,7 @@ public function testGetItems()
->method('getProductCount')
->will($this->returnValue(10));
- $category2 = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $category2 = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->setMethods(['getId', 'getName', 'getIsActive', 'getProductCount'])
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/CategoryTest.php
index 257a84e50248d..755b3267b14e7 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/CategoryTest.php
@@ -3,30 +3,37 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Filter\DataProvider;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\CategoryFactory;
+use Magento\Catalog\Model\Layer;
+use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Magento\Store\Model\Store;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test for \Magento\Catalog\Model\Layer\Filter\DataProvider\Category
*/
-class CategoryTest extends \PHPUnit\Framework\TestCase
+class CategoryTest extends TestCase
{
- /** @var \Magento\Catalog\Model\Category|MockObject */
+ /** @var Category|MockObject */
private $category;
- /** @var \Magento\Store\Model\Store|MockObject */
+ /** @var Store|MockObject */
private $store;
- /** @var \Magento\Catalog\Model\Layer|MockObject */
+ /** @var Layer|MockObject */
private $layer;
- /** @var \Magento\Catalog\Model\CategoryFactory|MockObject */
+ /** @var CategoryFactory|MockObject */
private $categoryFactory;
- /** @var \Magento\Framework\Registry|MockObject */
+ /** @var Registry|MockObject */
private $coreRegistry;
/**
@@ -37,29 +44,29 @@ class CategoryTest extends \PHPUnit\Framework\TestCase
/**
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
- protected function setUp()
+ protected function setUp(): void
{
- /** @var \Magento\Framework\Registry $var */
- $this->coreRegistry = $var = $this->getMockBuilder(\Magento\Framework\Registry::class)
+ /** @var Registry $var */
+ $this->coreRegistry = $var = $this->getMockBuilder(Registry::class)
->disableOriginalConstructor()
->setMethods(['register'])
->getMock();
- $this->category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $this->category = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->setMethods(['getId', 'setStoreId', 'load', 'getPathIds'])
->getMock();
- $this->categoryFactory = $this->getMockBuilder(\Magento\Catalog\Model\CategoryFactory::class)
+ $this->categoryFactory = $this->getMockBuilder(CategoryFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$this->categoryFactory->expects($this->any())
->method('create')
->will($this->returnValue($this->category));
- $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
+ $this->store = $this->getMockBuilder(Store::class)
->disableOriginalConstructor()
->setMethods(['getId'])
->getMock();
- $this->layer = $this->getMockBuilder(\Magento\Catalog\Model\Layer::class)
+ $this->layer = $this->getMockBuilder(Layer::class)
->disableOriginalConstructor()
->setMethods(['getCurrentStore', 'getCurrentCategory'])
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/DecimalTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/DecimalTest.php
index 4b87416e7a409..fb5350128dc7a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/DecimalTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/DecimalTest.php
@@ -3,21 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Filter\DataProvider;
+use Magento\Catalog\Model\Layer\Filter\FilterInterface;
+use Magento\Catalog\Model\ResourceModel\Layer\Filter\Decimal;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test for \Magento\Catalog\Model\Layer\Filter\DataProvider\Decimal
*/
-class DecimalTest extends \PHPUnit\Framework\TestCase
+class DecimalTest extends TestCase
{
- /** @var \Magento\Catalog\Model\Layer\Filter\FilterInterface|MockObject */
+ /** @var FilterInterface|MockObject */
private $filter;
- /** @var \Magento\Catalog\Model\ResourceModel\Layer\Filter\Decimal|MockObject */
+ /** @var Decimal|MockObject */
private $resource;
/**
@@ -25,13 +29,13 @@ class DecimalTest extends \PHPUnit\Framework\TestCase
*/
private $target;
- protected function setUp()
+ protected function setUp(): void
{
- $this->filter = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\FilterInterface::class)
+ $this->filter = $this->getMockBuilder(FilterInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMockForAbstractClass();
- $this->resource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Layer\Filter\Decimal::class)
+ $this->resource = $this->getMockBuilder(Decimal::class)
->disableOriginalConstructor()
->setMethods(['getMinMax', 'getCount'])
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php
index c59aa1988be55..5945582974d47 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php
@@ -3,29 +3,37 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Filter\DataProvider;
-use \Magento\Catalog\Model\Layer\Filter\DataProvider\Price;
-
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Layer;
+use Magento\Catalog\Model\Layer\Filter\DataProvider\Price;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Magento\Store\Model\ScopeInterface;
+
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test for \Magento\Catalog\Model\Layer\Filter\DataProvider\Price
*/
-class PriceTest extends \PHPUnit\Framework\TestCase
+class PriceTest extends TestCase
{
- /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection|MockObject */
+ /** @var Collection|MockObject */
private $productCollection;
- /** @var \Magento\Catalog\Model\Layer|MockObject */
+ /** @var Layer|MockObject */
private $layer;
- /** @var \Magento\Framework\Registry|MockObject */
+ /** @var Registry|MockObject */
private $coreRegistry;
- /** @var \Magento\Framework\App\Config\ScopeConfigInterface|MockObject */
+ /** @var ScopeConfigInterface|MockObject */
private $scopeConfig;
/** @var \Magento\Catalog\Model\ResourceModel\Layer\Filter\Price|MockObject */
@@ -36,24 +44,24 @@ class PriceTest extends \PHPUnit\Framework\TestCase
*/
private $target;
- protected function setUp()
+ protected function setUp(): void
{
- $this->productCollection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class)
+ $this->productCollection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->setMethods(['getMaxPrice'])
->getMock();
- $this->layer = $this->getMockBuilder(\Magento\Catalog\Model\Layer::class)
+ $this->layer = $this->getMockBuilder(Layer::class)
->disableOriginalConstructor()
->setMethods(['getProductCollection'])
->getMock();
$this->layer->expects($this->any())
->method('getProductCollection')
->will($this->returnValue($this->productCollection));
- $this->coreRegistry = $this->getMockBuilder(\Magento\Framework\Registry::class)
+ $this->coreRegistry = $this->getMockBuilder(Registry::class)
->disableOriginalConstructor()
->setMethods(['registry'])
->getMock();
- $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
+ $this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
->disableOriginalConstructor()
->setMethods(['getValue'])
->getMockForAbstractClass();
@@ -63,7 +71,7 @@ protected function setUp()
->getMock();
$objectManagerHelper = new ObjectManagerHelper($this);
$this->target = $objectManagerHelper->getObject(
- \Magento\Catalog\Model\Layer\Filter\DataProvider\Price::class,
+ Price::class,
[
'layer' => $this->layer,
'coreRegistry' => $this->coreRegistry,
@@ -108,8 +116,8 @@ function ($key, $scope) use ($map) {
public function testGetPriceRangeWithRangeInFilter()
{
- /** @var \Magento\Catalog\Model\Category|MockObject $category */
- $category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ /** @var Category|MockObject $category */
+ $category = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->setMethods(['getFilterPriceRange'])
->getMock();
@@ -126,8 +134,8 @@ public function testGetPriceRangeWithRangeInFilter()
public function testGetPriceRangeWithRangeCalculation()
{
- /** @var \Magento\Catalog\Model\Category|MockObject $category */
- $category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ /** @var Category|MockObject $category */
+ $category = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->setMethods(['getFilterPriceRange'])
->getMock();
@@ -205,23 +213,23 @@ private function getValueMap()
{
return [
Price::XML_PATH_RANGE_CALCULATION => [
- 'scope' => \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ 'scope' => ScopeInterface::SCOPE_STORE,
'value' => 111,
],
Price::XML_PATH_RANGE_STEP => [
- 'scope' => \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ 'scope' => ScopeInterface::SCOPE_STORE,
'value' => 222,
],
Price::XML_PATH_ONE_PRICE_INTERVAL => [
- 'scope' => \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ 'scope' => ScopeInterface::SCOPE_STORE,
'value' => 333,
],
Price::XML_PATH_INTERVAL_DIVISION_LIMIT => [
- 'scope' => \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ 'scope' => ScopeInterface::SCOPE_STORE,
'value' => 444,
],
Price::XML_PATH_RANGE_MAX_INTERVALS => [
- 'scope' => \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ 'scope' => ScopeInterface::SCOPE_STORE,
'value' => 555,
],
];
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DecimalTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DecimalTest.php
index c79ae4654a6f9..99c4212a58a9a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DecimalTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DecimalTest.php
@@ -3,28 +3,36 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Layer\Filter;
-class DecimalTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Layer\Filter\DataProvider\DecimalFactory;
+use Magento\Catalog\Model\Layer\Filter\Decimal;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
+class DecimalTest extends TestCase
{
public function testConstructorRequestVarIsOverwrittenCorrectlyInParent()
{
$attributeModel = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class,
+ Attribute::class,
['getAttributeCode', '__wakeup']
);
$attributeModel->expects($this->once())->method('getAttributeCode')->will($this->returnValue('price1'));
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$dataProviderFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\Layer\Filter\DataProvider\DecimalFactory::class
+ DecimalFactory::class
)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$instance = $objectManager->getObject(
- \Magento\Catalog\Model\Layer\Filter\Decimal::class,
+ Decimal::class,
[
'data' => [
'attribute_model' => $attributeModel,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/FactoryTest.php
index 64273e732166f..077c41880324e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/FactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/FactoryTest.php
@@ -3,34 +3,43 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Layer\Filter;
-class FactoryTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
+use Magento\Catalog\Model\Layer\Filter\Factory;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class FactoryTest extends TestCase
{
/**
- * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
protected $_objectManagerMock;
/**
- * @var \Magento\Catalog\Model\Layer\Filter\Factory
+ * @var Factory
*/
protected $_factory;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
+ $this->_objectManagerMock = $this->createMock(ObjectManagerInterface::class);
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
$this->_factory = $objectManagerHelper->getObject(
- \Magento\Catalog\Model\Layer\Filter\Factory::class,
+ Factory::class,
['objectManager' => $this->_objectManagerMock]
);
}
public function testCreate()
{
- $className = \Magento\Catalog\Model\Layer\Filter\AbstractFilter::class;
+ $className = AbstractFilter::class;
$filterMock = $this->createMock($className);
$this->_objectManagerMock->expects(
@@ -49,7 +58,7 @@ public function testCreate()
public function testCreateWithArguments()
{
- $className = \Magento\Catalog\Model\Layer\Filter\AbstractFilter::class;
+ $className = AbstractFilter::class;
$arguments = ['foo', 'bar'];
$filterMock = $this->createMock($className);
@@ -67,12 +76,10 @@ public function testCreateWithArguments()
$this->assertEquals($filterMock, $this->_factory->create($className, $arguments));
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage WrongClass doesn't extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
- */
public function testWrongTypeException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('WrongClass doesn\'t extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter');
$className = 'WrongClass';
$filterMock = $this->getMockBuilder($className)->disableOriginalConstructor()->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/Item/DataBuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/Item/DataBuilderTest.php
index 2a2ae9fb04e66..97e7311d7922f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/Item/DataBuilderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/Item/DataBuilderTest.php
@@ -3,23 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Filter\Item;
+use Magento\Catalog\Model\Layer\Filter\Item\DataBuilder;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\TestCase;
-class DataBuilderTest extends \PHPUnit\Framework\TestCase
+class DataBuilderTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder
+ * @var DataBuilder
*/
protected $dataBuilder;
- protected function setUp()
+ protected function setUp(): void
{
$objectManagerHelper = new ObjectManagerHelper($this);
$this->dataBuilder = $objectManagerHelper->getObject(
- \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder::class,
+ DataBuilder::class,
[]
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/PriceTest.php
index e1b9dc336bf1c..2dc96aaef8a2c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/PriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/PriceTest.php
@@ -3,24 +3,38 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Filter;
+use Magento\Catalog\Model\Layer;
+use Magento\Catalog\Model\Layer\Filter\DataProvider\Price;
+use Magento\Catalog\Model\Layer\Filter\DataProvider\PriceFactory;
+use Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory;
+use Magento\Catalog\Model\Layer\Filter\Dynamic\Auto;
+use Magento\Catalog\Model\Layer\Filter\Item;
+use Magento\Catalog\Model\Layer\Filter\Item\DataBuilder;
+use Magento\Catalog\Model\Layer\Filter\ItemFactory;
+use Magento\Catalog\Model\Layer\State;
+use Magento\Eav\Model\Entity\Attribute;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\Escaper;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test for \Magento\Catalog\Model\Layer\Filter\Price
* @SuppressWarnings(PHPMD.UnusedPrivateField)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class PriceTest extends \PHPUnit\Framework\TestCase
+class PriceTest extends TestCase
{
private $itemDataBuilder;
private $resource;
- /** @var \Magento\Catalog\Model\Layer\Filter\Dynamic\Auto|MockObject */
+ /** @var Auto|MockObject */
private $algorithm;
/**
@@ -29,12 +43,12 @@ class PriceTest extends \PHPUnit\Framework\TestCase
private $price;
/**
- * @var \Magento\Catalog\Model\Layer|MockObject
+ * @var Layer|MockObject
*/
private $layer;
/**
- * @var \Magento\Catalog\Model\Layer\Filter\DataProvider\Price|MockObject
+ * @var Price|MockObject
*/
private $dataProvider;
@@ -43,33 +57,33 @@ class PriceTest extends \PHPUnit\Framework\TestCase
*/
private $target;
- /** @var \Magento\Framework\App\RequestInterface|MockObject */
+ /** @var RequestInterface|MockObject */
private $request;
- /** @var \Magento\Catalog\Model\Layer\Filter\ItemFactory|MockObject */
+ /** @var ItemFactory|MockObject */
private $filterItemFactory;
- /** @var \Magento\Catalog\Model\Layer\State|MockObject */
+ /** @var State|MockObject */
private $state;
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
+ $this->request = $this->getMockBuilder(RequestInterface::class)
->disableOriginalConstructor()
->setMethods(['getParam'])
->getMockForAbstractClass();
$dataProviderFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\Layer\Filter\DataProvider\PriceFactory::class
+ PriceFactory::class
)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->dataProvider = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\DataProvider\Price::class)
+ $this->dataProvider = $this->getMockBuilder(Price::class)
->disableOriginalConstructor()
->setMethods(['setPriceId', 'getPrice', 'getResource'])
->getMock();
@@ -85,12 +99,12 @@ protected function setUp()
->method('create')
->will($this->returnValue($this->dataProvider));
- $this->layer = $this->getMockBuilder(\Magento\Catalog\Model\Layer::class)
+ $this->layer = $this->getMockBuilder(Layer::class)
->disableOriginalConstructor()
->setMethods(['getState'])
->getMock();
- $this->state = $this->getMockBuilder(\Magento\Catalog\Model\Layer\State::class)
+ $this->state = $this->getMockBuilder(State::class)
->disableOriginalConstructor()
->setMethods(['addFilter'])
->getMock();
@@ -98,20 +112,20 @@ protected function setUp()
->method('getState')
->will($this->returnValue($this->state));
- $this->itemDataBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Item\DataBuilder::class)
+ $this->itemDataBuilder = $this->getMockBuilder(DataBuilder::class)
->disableOriginalConstructor()
->setMethods(['addItemData', 'build'])
->getMock();
$this->filterItemFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\Layer\Filter\ItemFactory::class
+ ItemFactory::class
)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$filterItem = $this->getMockBuilder(
- \Magento\Catalog\Model\Layer\Filter\Item::class
+ Item::class
)
->disableOriginalConstructor()
->setMethods(['setFilter', 'setLabel', 'setValue', 'setCount'])
@@ -123,7 +137,7 @@ protected function setUp()
->method('create')
->will($this->returnValue($filterItem));
- $escaper = $this->getMockBuilder(\Magento\Framework\Escaper::class)
+ $escaper = $this->getMockBuilder(Escaper::class)
->disableOriginalConstructor()
->setMethods(['escapeHtml'])
->getMock();
@@ -131,16 +145,16 @@ protected function setUp()
->method('escapeHtml')
->will($this->returnArgument(0));
- $this->attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
+ $this->attribute = $this->getMockBuilder(Attribute::class)
->disableOriginalConstructor()
->setMethods(['getAttributeCode', 'getFrontend', 'getIsFilterable'])
->getMock();
- $algorithmFactory = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory::class)
+ $algorithmFactory = $this->getMockBuilder(AlgorithmFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->algorithm = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Dynamic\Auto::class)
+ $this->algorithm = $this->getMockBuilder(Auto::class)
->disableOriginalConstructor()
->setMethods(['getItemsData'])
->getMock();
@@ -217,7 +231,7 @@ public function applyWithEmptyRequestDataProvider()
];
}
- /** @var \Magento\Eav\Model\Entity\Attribute|MockObject */
+ /** @var Attribute|MockObject */
private $attribute;
public function testApply()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/FilterListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/FilterListTest.php
index 8fdd41281d807..e48d41de60e20 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/FilterListTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/FilterListTest.php
@@ -8,38 +8,41 @@
namespace Magento\Catalog\Test\Unit\Model\Layer;
use Magento\Catalog\Model\Config\LayerCategoryConfig;
-use \Magento\Catalog\Model\Layer\FilterList;
+use Magento\Catalog\Model\Layer;
+use Magento\Catalog\Model\Layer\Category\FilterableAttributeList;
+use Magento\Catalog\Model\Layer\FilterList;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Framework\ObjectManagerInterface;
use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Filter List Test
- *
* Check whenever the given filters list matches the expected result
*/
-class FilterListTest extends \PHPUnit\Framework\TestCase
+class FilterListTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $objectManagerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $attributeListMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $attributeMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $layerMock;
/**
- * @var \Magento\Catalog\Model\Layer\FilterList
+ * @var FilterList
*/
protected $model;
@@ -51,13 +54,13 @@ class FilterListTest extends \PHPUnit\Framework\TestCase
/**
* Set Up
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
+ $this->objectManagerMock = $this->createMock(ObjectManagerInterface::class);
$this->attributeListMock = $this->createMock(
- \Magento\Catalog\Model\Layer\Category\FilterableAttributeList::class
+ FilterableAttributeList::class
);
- $this->attributeMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
+ $this->attributeMock = $this->createMock(Attribute::class);
$filters = [
FilterList::CATEGORY_FILTER => 'CategoryFilterClass',
FilterList::PRICE_FILTER => 'PriceFilterClass',
@@ -65,7 +68,7 @@ protected function setUp()
FilterList::ATTRIBUTE_FILTER => 'AttributeFilterClass',
];
- $this->layerMock = $this->createMock(\Magento\Catalog\Model\Layer::class);
+ $this->layerMock = $this->createMock(Layer::class);
$this->layerCategoryConfigMock = $this->createMock(LayerCategoryConfig::class);
$this->model = new FilterList(
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/CollectionFilterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/CollectionFilterTest.php
index a7b4957411f17..1fc57c2c82c1c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/CollectionFilterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/CollectionFilterTest.php
@@ -3,43 +3,52 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Search;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Config;
+use Magento\Catalog\Model\Layer\Search\CollectionFilter;
+use Magento\Catalog\Model\Product\Visibility;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CollectionFilterTest extends \PHPUnit\Framework\TestCase
+class CollectionFilterTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $visibilityMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $catalogConfigMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $storeManagerMock;
/**
- * @var \Magento\Catalog\Model\Layer\Search\CollectionFilter
+ * @var CollectionFilter
*/
protected $model;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
- $this->visibilityMock = $this->createMock(\Magento\Catalog\Model\Product\Visibility::class);
- $this->catalogConfigMock = $this->createMock(\Magento\Catalog\Model\Config::class);
+ $this->visibilityMock = $this->createMock(Visibility::class);
+ $this->catalogConfigMock = $this->createMock(Config::class);
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Layer\Search\CollectionFilter::class,
+ CollectionFilter::class,
[
'catalogConfig' => $this->catalogConfigMock,
'storeManager' => $this->storeManagerMock,
@@ -54,11 +63,11 @@ protected function setUp()
*/
public function testFilter()
{
- $collectionMock = $this->createPartialMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class, [
+ $collectionMock = $this->createPartialMock(Collection::class, [
'addAttributeToSelect', 'setStore', 'addMinimalPrice', 'addFinalPrice',
'addTaxPercents', 'addStoreFilter', 'addUrlRewrite', 'setVisibility'
]);
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(Category::class);
$this->catalogConfigMock->expects($this->once())->method('getProductAttributes');
$this->visibilityMock->expects($this->once())->method('getVisibleInSearchIds');
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/FilterableAttributeListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/FilterableAttributeListTest.php
index 62d49a12c8981..17f621a2d5ce6 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/FilterableAttributeListTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/FilterableAttributeListTest.php
@@ -3,36 +3,46 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Search;
-class FilterableAttributeListTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Layer\Search\FilterableAttributeList;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class FilterableAttributeListTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Layer\Search\FilterableAttributeList
+ * @var FilterableAttributeList
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory
+ * @var MockObject|CollectionFactory
*/
protected $collectionFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\StoreManagerInterface
+ * @var MockObject|StoreManagerInterface
*/
protected $storeManagerMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->collectionFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
- $this->model = new \Magento\Catalog\Model\Layer\Search\FilterableAttributeList(
+ $this->model = new FilterableAttributeList(
$this->collectionFactoryMock,
$this->storeManagerMock
);
@@ -43,13 +53,13 @@ protected function setUp()
*/
public function testGetList()
{
- $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
+ $storeMock = $this->createMock(Store::class);
$this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock));
$storeId = 4321;
$storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId));
- $collectionMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class);
+ $collectionMock = $this->createMock(Collection::class);
$this->collectionFactoryMock
->expects($this->once())
->method('create')
@@ -58,7 +68,7 @@ public function testGetList()
$collectionMock
->expects($this->once())
->method('setItemObjectClass')
- ->with(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
+ ->with(Attribute::class)
->will($this->returnSelf());
$collectionMock
->expects($this->once())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/StateKeyTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/StateKeyTest.php
index ea8d1f59fd3a0..81ff7440b2e52 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/StateKeyTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Search/StateKeyTest.php
@@ -3,38 +3,47 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Layer\Search;
+use Magento\Catalog\Model\Category;
use Magento\CatalogSearch\Model\Layer\Search\StateKey;
+use Magento\Customer\Model\Session;
+use Magento\Search\Model\Query;
+use Magento\Search\Model\QueryFactory;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class StateKeyTest extends \PHPUnit\Framework\TestCase
+class StateKeyTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $storeManagerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $customerSessionMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $queryFactoryMock;
/**
- * @var \Magento\CatalogSearch\Model\Layer\Search\StateKey
+ * @var StateKey
*/
protected $model;
- protected function setUp()
+ protected function setUp(): void
{
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class);
- $this->queryFactoryMock = $this->createMock(\Magento\Search\Model\QueryFactory::class);
+ $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $this->customerSessionMock = $this->createMock(Session::class);
+ $this->queryFactoryMock = $this->createMock(QueryFactory::class);
$this->model = new StateKey($this->storeManagerMock, $this->customerSessionMock, $this->queryFactoryMock);
}
@@ -45,16 +54,16 @@ protected function setUp()
*/
public function testToString()
{
- $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $categoryMock = $this->createMock(Category::class);
$categoryMock->expects($this->once())->method('getId')->will($this->returnValue('1'));
- $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
+ $storeMock = $this->createMock(Store::class);
$this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock));
$storeMock->expects($this->once())->method('getId')->will($this->returnValue('2'));
$this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue('3'));
- $queryMock = $this->createPartialMock(\Magento\Search\Model\Query::class, ['getId']);
+ $queryMock = $this->createPartialMock(Query::class, ['getId']);
$queryMock->expects($this->once())->method('getId')->will($this->returnValue('4'));
$this->queryFactoryMock->expects($this->once())->method('get')->will($this->returnValue($queryMock));
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/StateTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/StateTest.php
index b15baee819a50..47987928fa272 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/StateTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/StateTest.php
@@ -3,37 +3,41 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Layer;
+use Magento\Catalog\Model\Layer\Filter\Item;
+use Magento\Catalog\Model\Layer\State;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class StateTest extends \PHPUnit\Framework\TestCase
+class StateTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Layer\State
+ * @var State
*/
private $model;
/**
- * @var \Magento\Catalog\Model\Layer\Filter\Item|\PHPUnit_Framework_MockObject_MockObject
+ * @var Item|MockObject
*/
private $item;
- protected function setUp()
+ protected function setUp(): void
{
- $this->item = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Item::class)
+ $this->item = $this->getMockBuilder(Item::class)
->disableOriginalConstructor()
->getMock();
$helper = new ObjectManager($this);
- $this->model = $helper->getObject(\Magento\Catalog\Model\Layer\State::class);
+ $this->model = $helper->getObject(State::class);
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- */
public function testSetFiltersException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
$this->model->setFilters($this->item);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/LayerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/LayerTest.php
index 08d655ae9b57f..b8154494daa81 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/LayerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/LayerTest.php
@@ -3,148 +3,167 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model;
+use Magento\Catalog\Api\CategoryRepositoryInterface;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Layer;
+use Magento\Catalog\Model\Layer\Category\CollectionFilter;
+use Magento\Catalog\Model\Layer\Category\StateKey;
+use Magento\Catalog\Model\Layer\ContextInterface;
+use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
+use Magento\Catalog\Model\Layer\Filter\Item;
+use Magento\Catalog\Model\Layer\ItemCollectionProviderInterface;
+use Magento\Catalog\Model\Layer\State;
+use Magento\Catalog\Model\Layer\StateFactory;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyFields)
*/
-class LayerTest extends \PHPUnit\Framework\TestCase
+class LayerTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Layer
+ * @var Layer
*/
private $model;
/**
- * @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject
+ * @var Category|MockObject
*/
private $category;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
private $registry;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManager;
/**
- * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
+ * @var Store|MockObject
*/
private $store;
/**
- * @var \Magento\Catalog\Model\Layer\ContextInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ContextInterface|MockObject
*/
private $context;
/**
- * @var \Magento\Catalog\Model\Layer\Category\StateKey|\PHPUnit_Framework_MockObject_MockObject
+ * @var StateKey|MockObject
*/
private $stateKeyGenerator;
/**
- * @var \Magento\Catalog\Model\Layer\StateFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var StateFactory|MockObject
*/
private $stateFactory;
/**
- * @var \Magento\Catalog\Model\Layer\State|\PHPUnit_Framework_MockObject_MockObject
+ * @var State|MockObject
*/
private $state;
/**
- * @var \Magento\Catalog\Model\Layer\Category\CollectionFilter|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFilter|MockObject
*/
private $collectionFilter;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Collection|\PHPUnit_Framework_MockObject_MockObject
+ * @var Collection|MockObject
*/
private $collection;
/**
- * @var \Magento\Catalog\Model\Layer\ItemCollectionProviderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ItemCollectionProviderInterface|MockObject
*/
private $collectionProvider;
/**
- * @var \Magento\Catalog\Model\Layer\Filter\Item|\PHPUnit_Framework_MockObject_MockObject
+ * @var Item|MockObject
*/
private $filter;
/**
- * @var \Magento\Catalog\Model\Layer\Filter\AbstractFilter|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractFilter|MockObject
*/
private $abstractFilter;
/**
- * @var \Magento\Catalog\Api\CategoryRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryRepositoryInterface|MockObject
*/
private $categoryRepository;
/**
- * @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject
+ * @var Category|MockObject
*/
private $currentCategory;
- protected function setUp()
+ protected function setUp(): void
{
$helper = new ObjectManager($this);
- $this->category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $this->category = $this->getMockBuilder(Category::class)
->setMethods(['getId', '__wakeup'])
->disableOriginalConstructor()
->getMock();
- $this->registry = $this->getMockBuilder(\Magento\Framework\Registry::class)
+ $this->registry = $this->getMockBuilder(Registry::class)
->setMethods(['registry'])
->disableOriginalConstructor()
->getMock();
- $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
+ $this->store = $this->getMockBuilder(Store::class)
->setMethods(['getRootCategoryId', 'getFilters', '__wakeup'])
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ $this->storeManager = $this->getMockBuilder(StoreManagerInterface::class)
->setMethods(['getStore'])
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->storeManager->expects($this->any())->method('getStore')
->will($this->returnValue($this->store));
- $this->stateKeyGenerator = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Category\StateKey::class)
+ $this->stateKeyGenerator = $this->getMockBuilder(StateKey::class)
->setMethods(['toString'])
->disableOriginalConstructor()
->getMock();
- $this->collectionFilter = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Category\CollectionFilter::class)
+ $this->collectionFilter = $this->getMockBuilder(CollectionFilter::class)
->setMethods(['filter'])
->disableOriginalConstructor()
->getMock();
$this->collectionProvider = $this->getMockBuilder(
- \Magento\Catalog\Model\Layer\ItemCollectionProviderInterface::class
+ ItemCollectionProviderInterface::class
)->disableOriginalConstructor()->getMockForAbstractClass();
- $this->filter = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\Item::class)
+ $this->filter = $this->getMockBuilder(Item::class)
->setMethods(['getFilter', 'getValueString'])
->disableOriginalConstructor()
->getMock();
- $this->abstractFilter = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Filter\AbstractFilter::class)
+ $this->abstractFilter = $this->getMockBuilder(AbstractFilter::class)
->setMethods(['getRequestVar'])
->disableOriginalConstructor()
->getMock();
- $this->context = $this->getMockBuilder(\Magento\Catalog\Model\Layer\ContextInterface::class)
+ $this->context = $this->getMockBuilder(ContextInterface::class)
->setMethods(['getStateKey', 'getCollectionFilter'])
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -155,28 +174,28 @@ protected function setUp()
$this->context->expects($this->any())->method('getCollectionProvider')
->will($this->returnValue($this->collectionProvider));
- $this->state = $this->getMockBuilder(\Magento\Catalog\Model\Layer\State::class)
+ $this->state = $this->getMockBuilder(State::class)
->disableOriginalConstructor()
->getMock();
- $this->stateFactory = $this->getMockBuilder(\Magento\Catalog\Model\Layer\StateFactory::class)
+ $this->stateFactory = $this->getMockBuilder(StateFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
$this->stateFactory->expects($this->any())->method('create')->will($this->returnValue($this->state));
- $this->collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class)
+ $this->collection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
- $this->categoryRepository = $this->createMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class);
+ $this->categoryRepository = $this->createMock(CategoryRepositoryInterface::class);
$this->currentCategory = $this->createPartialMock(
- \Magento\Catalog\Model\Category::class,
+ Category::class,
['getId', '__wakeup']
);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Layer::class,
+ Layer::class,
[
'registry' => $this->registry,
'storeManager' => $this->storeManager,
@@ -189,7 +208,7 @@ protected function setUp()
public function testGetState()
{
- $this->assertInstanceOf(\Magento\Catalog\Model\Layer\State::class, $this->model->getState());
+ $this->assertInstanceOf(State::class, $this->model->getState());
}
public function testGetStateKey()
@@ -220,9 +239,9 @@ public function testGetProductCollection()
->will($this->returnValue($this->collection));
$result = $this->model->getProductCollection();
- $this->assertInstanceOf(\Magento\Catalog\Model\ResourceModel\Product\Collection::class, $result);
+ $this->assertInstanceOf(Collection::class, $result);
$result = $this->model->getProductCollection();
- $this->assertInstanceOf(\Magento\Catalog\Model\ResourceModel\Product\Collection::class, $result);
+ $this->assertInstanceOf(Collection::class, $result);
}
public function testApply()
@@ -243,7 +262,7 @@ public function testApply()
$this->abstractFilter->expects($this->once())->method('getRequestVar')->will($this->returnValue('t'));
$result = $this->model->apply();
- $this->assertInstanceOf(\Magento\Catalog\Model\Layer::class, $result);
+ $this->assertInstanceOf(Layer::class, $result);
}
public function testPrepareProductCollection()
@@ -255,12 +274,12 @@ public function testPrepareProductCollection()
->with($this->equalTo($this->collection), $this->equalTo($this->category));
$result = $this->model->prepareProductCollection($this->collection);
- $this->assertInstanceOf(\Magento\Catalog\Model\Layer::class, $result);
+ $this->assertInstanceOf(Layer::class, $result);
}
public function testGetCurrentStore()
{
- $this->assertInstanceOf(\Magento\Store\Model\Store::class, $this->model->getCurrentStore());
+ $this->assertInstanceOf(Store::class, $this->model->getCurrentStore());
}
public function testSetNewCurrentCategoryIfCurrentCategoryIsAnother()
@@ -276,7 +295,7 @@ public function testSetNewCurrentCategoryIfCurrentCategoryIsAnother()
$this->registry->expects($this->once())->method('registry')->with('current_category')
->willReturn($this->currentCategory);
- $this->assertInstanceOf(\Magento\Catalog\Model\Layer::class, $this->model->setCurrentCategory($categoryId));
+ $this->assertInstanceOf(Layer::class, $this->model->setCurrentCategory($categoryId));
$this->assertEquals($this->currentCategory, $this->model->getData('current_category'));
}
@@ -291,37 +310,31 @@ public function testSetNewCurrentCategoryIfCurrentCategoryIsSame()
$this->registry->expects($this->once())->method('registry')->with('current_category')
->willReturn($this->category);
- $this->assertInstanceOf(\Magento\Catalog\Model\Layer::class, $this->model->setCurrentCategory($categoryId));
+ $this->assertInstanceOf(Layer::class, $this->model->setCurrentCategory($categoryId));
$this->assertEquals($this->category, $this->model->getData('current_category'));
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Please correct the category.
- */
public function testSetNewCurrentCategoryIfCategoryIsNotFound()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('Please correct the category.');
$this->categoryRepository->expects($this->once())->method('get')
->will($this->throwException(new NoSuchEntityException()));
$this->model->setCurrentCategory(1);
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Must be category model instance or its id.
- */
public function testSetCurrentCategoryInstanceOfException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('Must be category model instance or its id.');
$this->model->setCurrentCategory(null);
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Please correct the category.
- */
public function testSetCurrentCategoryNotFoundException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('Please correct the category.');
$this->category->expects($this->once())->method('getId')->will($this->returnValue(null));
$this->model->setCurrentCategory($this->category);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layout/DepersonalizePluginTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layout/DepersonalizePluginTest.php
index 89c588b5e32a2..bb2c9e7992437 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Layout/DepersonalizePluginTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Layout/DepersonalizePluginTest.php
@@ -43,7 +43,7 @@ class DepersonalizePluginTest extends TestCase
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->layoutMock = $this->getMockForAbstractClass(LayoutInterface::class);
$this->catalogSessionMock = $this->createPartialMock(CatalogSession::class, ['clearStorage']);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Locator/RegistryLocatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Locator/RegistryLocatorTest.php
index b2810ddea2413..cf0c42faf24d0 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Locator/RegistryLocatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Locator/RegistryLocatorTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Locator;
@@ -11,11 +12,10 @@
use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Store\Api\Data\StoreInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class RegistryLocatorTest
- */
-class RegistryLocatorTest extends \PHPUnit\Framework\TestCase
+class RegistryLocatorTest extends TestCase
{
/**
* @var ObjectManager
@@ -28,21 +28,21 @@ class RegistryLocatorTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registryMock;
/**
- * @var ProductInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductInterface|MockObject
*/
protected $productMock;
/**
- * @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreInterface|MockObject
*/
protected $storeMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
$this->registryMock = $this->getMockBuilder(Registry::class)
@@ -82,21 +82,17 @@ public function testGetStore()
$this->assertInstanceOf(StoreInterface::class, $this->model->getStore());
}
- /**
- * @expectedException \Magento\Framework\Exception\NotFoundException
- * @expectedExceptionMessage The product wasn't registered.
- */
public function testGetProductWithException()
{
+ $this->expectException('Magento\Framework\Exception\NotFoundException');
+ $this->expectExceptionMessage('The product wasn\'t registered.');
$this->assertInstanceOf(ProductInterface::class, $this->model->getProduct());
}
- /**
- * @expectedException \Magento\Framework\Exception\NotFoundException
- * @expectedExceptionMessage The store wasn't registered. Verify the store and try again.
- */
public function testGetStoreWithException()
{
+ $this->expectException('Magento\Framework\Exception\NotFoundException');
+ $this->expectExceptionMessage('The store wasn\'t registered. Verify the store and try again.');
$this->assertInstanceOf(StoreInterface::class, $this->model->getStore());
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Plugin/LogTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Plugin/LogTest.php
index 2b0a69a32819d..19c69f9952197 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Plugin/LogTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Plugin/LogTest.php
@@ -3,36 +3,44 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Plugin;
-class LogTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Plugin\Log;
+use Magento\Catalog\Model\Product\Compare\Item;
+use Magento\Customer\Model\ResourceModel\Visitor;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class LogTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Plugin\Log
+ * @var Log
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $compareItemMock;
/**
- * @var \Magento\Customer\Model\ResourceModel\Visitor|\PHPUnit_Framework_MockObject_MockObject
+ * @var Visitor|MockObject
*/
protected $logResourceMock;
/**
- * @var \Magento\Customer\Model\ResourceModel\Visitor|\PHPUnit_Framework_MockObject_MockObject
+ * @var Visitor|MockObject
*/
protected $subjectMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->logResourceMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Visitor::class);
- $this->compareItemMock = $this->createMock(\Magento\Catalog\Model\Product\Compare\Item::class);
- $this->subjectMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Visitor::class);
- $this->model = new \Magento\Catalog\Model\Plugin\Log($this->compareItemMock);
+ $this->logResourceMock = $this->createMock(Visitor::class);
+ $this->compareItemMock = $this->createMock(Item::class);
+ $this->subjectMock = $this->createMock(Visitor::class);
+ $this->model = new Log($this->compareItemMock);
}
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Plugin/ProductRepository/TransactionWrapperTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Plugin/ProductRepository/TransactionWrapperTest.php
index e42e4b58ee74d..5d21dd324f326 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Plugin/ProductRepository/TransactionWrapperTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Plugin/ProductRepository/TransactionWrapperTest.php
@@ -3,22 +3,31 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Plugin\ProductRepository;
-class TransactionWrapperTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\Plugin\ProductRepository\TransactionWrapper;
+use Magento\Catalog\Model\ResourceModel\Product;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class TransactionWrapperTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Plugin\ProductRepository\TransactionWrapper
+ * @var TransactionWrapper
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ResourceModel\Product
+ * @var MockObject|Product
*/
protected $resourceMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Api\ProductRepositoryInterface
+ * @var MockObject|ProductRepositoryInterface
*/
protected $subjectMock;
@@ -33,7 +42,7 @@ class TransactionWrapperTest extends \PHPUnit\Framework\TestCase
protected $rollbackClosureMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productMock;
@@ -44,11 +53,11 @@ class TransactionWrapperTest extends \PHPUnit\Framework\TestCase
const ERROR_MSG = "error occurred";
- protected function setUp()
+ protected function setUp(): void
{
- $this->resourceMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product::class);
- $this->subjectMock = $this->createMock(\Magento\Catalog\Api\ProductRepositoryInterface::class);
- $this->productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class);
+ $this->resourceMock = $this->createMock(Product::class);
+ $this->subjectMock = $this->createMock(ProductRepositoryInterface::class);
+ $this->productMock = $this->createMock(ProductInterface::class);
$productMock = $this->productMock;
$this->closureMock = function () use ($productMock) {
return $productMock;
@@ -57,7 +66,7 @@ protected function setUp()
throw new \Exception(self::ERROR_MSG);
};
- $this->model = new \Magento\Catalog\Model\Plugin\ProductRepository\TransactionWrapper($this->resourceMock);
+ $this->model = new TransactionWrapper($this->resourceMock);
}
public function testAroundSaveCommit()
@@ -71,12 +80,10 @@ public function testAroundSaveCommit()
);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage error occurred
- */
public function testAroundSaveRollBack()
{
+ $this->expectException('Exception');
+ $this->expectExceptionMessage('error occurred');
$this->resourceMock->expects($this->once())->method('beginTransaction');
$this->resourceMock->expects($this->once())->method('rollBack');
@@ -94,12 +101,10 @@ public function testAroundDeleteCommit()
);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage error occurred
- */
public function testAroundDeleteRollBack()
{
+ $this->expectException('Exception');
+ $this->expectExceptionMessage('error occurred');
$this->resourceMock->expects($this->once())->method('beginTransaction');
$this->resourceMock->expects($this->once())->method('rollBack');
@@ -122,12 +127,10 @@ public function testAroundDeleteByIdCommit()
);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage error occurred
- */
public function testAroundDeleteByIdRollBack()
{
+ $this->expectException('Exception');
+ $this->expectExceptionMessage('error occurred');
$this->resourceMock->expects($this->once())->method('beginTransaction');
$this->resourceMock->expects($this->once())->method('rollBack');
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Plugin/QuoteItemProductOptionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Plugin/QuoteItemProductOptionTest.php
index 89f848750de65..925e0926c2103 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Plugin/QuoteItemProductOptionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Plugin/QuoteItemProductOptionTest.php
@@ -3,21 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Plugin;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterface as ProductOption;
use Magento\Catalog\Model\Plugin\QuoteItemProductOption as QuoteItemProductOptionPlugin;
+use Magento\Catalog\Model\Product;
+use Magento\Framework\DataObject;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use Magento\Quote\Model\Quote\Item\ToOrderItem as QuoteToOrderItem;
use Magento\Quote\Model\Quote\Item\AbstractItem as AbstractQuoteItem;
use Magento\Quote\Model\Quote\Item\Option as QuoteItemOption;
-use Magento\Catalog\Model\Product;
-use Magento\Framework\DataObject;
-use Magento\Catalog\Api\Data\ProductCustomOptionInterface as ProductOption;
+use Magento\Quote\Model\Quote\Item\ToOrderItem as QuoteToOrderItem;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class QuoteItemProductOptionTest extends \PHPUnit\Framework\TestCase
+class QuoteItemProductOptionTest extends TestCase
{
/**
* @var QuoteItemProductOptionPlugin
@@ -30,26 +34,26 @@ class QuoteItemProductOptionTest extends \PHPUnit\Framework\TestCase
private $objectManagerHelper;
/**
- * @var QuoteToOrderItem|\PHPUnit_Framework_MockObject_MockObject
+ * @var QuoteToOrderItem|MockObject
*/
private $subjectMock;
/**
- * @var AbstractQuoteItem|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractQuoteItem|MockObject
*/
private $quoteItemMock;
/**
- * @var QuoteItemOption|\PHPUnit_Framework_MockObject_MockObject
+ * @var QuoteItemOption|MockObject
*/
private $quoteItemOptionMock;
/**
- * @var Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
private $productMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->subjectMock = $this->getMockBuilder(QuoteToOrderItem::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php
index a97e4650b49bd..45aa03ad82edd 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php
@@ -3,59 +3,78 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product;
-class ActionTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Indexer\Product\Category;
+use Magento\Catalog\Model\Product\Action;
+use Magento\Catalog\Model\Product\Website;
+use Magento\Catalog\Model\Product\WebsiteFactory;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Eav\Model\Config;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Indexer\Model\Indexer;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
+class ActionTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Action
+ * @var Action
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productWebsiteFactory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $resource;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productWebsite;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $categoryIndexer;
/**
- * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
protected $eavConfig;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var Attribute|MockObject
*/
protected $eavAttribute;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
protected $indexerRegistryMock;
- protected function setUp()
+ protected function setUp(): void
{
- $eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
+ $eventManagerMock = $this->createMock(ManagerInterface::class);
$this->productWebsiteFactory = $this->createPartialMock(
- \Magento\Catalog\Model\Product\WebsiteFactory::class,
+ WebsiteFactory::class,
['create']
);
$this->resource = $this->createPartialMock(
- \Magento\Framework\Model\ResourceModel\AbstractResource::class,
+ AbstractResource::class,
[
'updateAttributes',
'getConnection',
@@ -64,7 +83,7 @@ protected function setUp()
]
);
$this->productWebsite = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Website::class,
+ Website::class,
['addProducts', 'removeProducts', '__wakeup']
);
$this->productWebsiteFactory
@@ -72,22 +91,22 @@ protected function setUp()
->method('create')
->will($this->returnValue($this->productWebsite));
$this->categoryIndexer = $this->createPartialMock(
- \Magento\Indexer\Model\Indexer::class,
+ Indexer::class,
['getId', 'load', 'isScheduled', 'reindexList']
);
- $this->eavConfig = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['__wakeup', 'getAttribute']);
+ $this->eavConfig = $this->createPartialMock(Config::class, ['__wakeup', 'getAttribute']);
$this->eavAttribute = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class,
+ Attribute::class,
['__wakeup', 'isIndexable']
);
$this->indexerRegistryMock = $this->createPartialMock(
- \Magento\Framework\Indexer\IndexerRegistry::class,
+ IndexerRegistry::class,
['get']
);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Action::class,
+ Action::class,
[
'eventDispatcher' => $eventManagerMock,
'resource' => $this->resource,
@@ -179,7 +198,7 @@ protected function prepareIndexer()
{
$this->indexerRegistryMock->expects($this->once())
->method('get')
- ->with(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID)
+ ->with(Category::INDEXER_ID)
->will($this->returnValue($this->categoryIndexer));
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/AttributeSetFinderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/AttributeSetFinderTest.php
index 50833a99f233a..408b879449076 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/AttributeSetFinderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/AttributeSetFinderTest.php
@@ -4,6 +4,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute;
use Magento\Catalog\Api\Data\ProductInterface;
@@ -13,16 +15,18 @@
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Select;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class AttributeSetFinderTest extends \PHPUnit\Framework\TestCase
+class AttributeSetFinderTest extends TestCase
{
/**
- * @var Collection|\PHPUnit_Framework_MockObject_MockObject
+ * @var Collection|MockObject
*/
protected $productCollection;
/**
- * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
protected $productCollectionFactory;
@@ -31,7 +35,7 @@ class AttributeSetFinderTest extends \PHPUnit\Framework\TestCase
*/
protected $attributeSetFinder;
- protected function setUp()
+ protected function setUp(): void
{
$this->productCollection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/BooleanTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/BooleanTest.php
index 35f69bee90e1f..0b72318e3c4d4 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/BooleanTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/BooleanTest.php
@@ -3,17 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Backend;
use Magento\Catalog\Model\Product\Attribute\Backend\Boolean as BooleanBackend;
use Magento\Catalog\Model\Product\Attribute\Source\Boolean as BooleanSource;
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
use Magento\Framework\DataObject;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class BooleanTest extends \PHPUnit\Framework\TestCase
+class BooleanTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|AbstractAttribute
+ * @var MockObject|AbstractAttribute
*/
private $attributeMock;
@@ -22,7 +26,7 @@ class BooleanTest extends \PHPUnit\Framework\TestCase
*/
private $model;
- protected function setUp()
+ protected function setUp(): void
{
$this->attributeMock = $this->getMockForAbstractClass(
AbstractAttribute::class,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/CategoryTest.php
index 99f49ea2b2ad6..f5733f586bd14 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/CategoryTest.php
@@ -3,20 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Backend;
-class CategoryTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product\Attribute\Backend\Category;
+use Magento\Framework\DataObject;
+use PHPUnit\Framework\TestCase;
+
+class CategoryTest extends TestCase
{
public function testAfterLoad()
{
$categoryIds = [1, 2, 3, 4, 5];
- $product = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getCategoryIds', 'setData']);
+ $product = $this->createPartialMock(DataObject::class, ['getCategoryIds', 'setData']);
$product->expects($this->once())->method('getCategoryIds')->will($this->returnValue($categoryIds));
$product->expects($this->once())->method('setData')->with('category_ids', $categoryIds);
- $categoryAttribute = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getAttributeCode']);
+ $categoryAttribute = $this->createPartialMock(DataObject::class, ['getAttributeCode']);
$categoryAttribute->expects(
$this->once()
)->method(
@@ -25,7 +31,7 @@ public function testAfterLoad()
$this->returnValue('category_ids')
);
- $model = new \Magento\Catalog\Model\Product\Attribute\Backend\Category();
+ $model = new Category();
$model->setAttribute($categoryAttribute);
$model->afterLoad($product);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/GroupPrice/AbstractTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/GroupPrice/AbstractTest.php
index b2e1401479301..d145ad53a5dcd 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/GroupPrice/AbstractTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/GroupPrice/AbstractTest.php
@@ -3,12 +3,28 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Backend\GroupPrice;
+use Magento\Catalog\Helper\Data;
+use Magento\Catalog\Model\Attribute\ScopeOverriddenValue;
+use Magento\Catalog\Model\Product\Attribute\Backend\GroupPrice\AbstractGroupPrice;
+use Magento\Catalog\Model\Product\Type;
+use Magento\Customer\Api\GroupManagementInterface;
+use Magento\Directory\Model\CurrencyFactory;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\DataObject;
+use Magento\Framework\Locale\FormatInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class AbstractTest extends \PHPUnit\Framework\TestCase
+class AbstractTest extends TestCase
{
/**
* @var \Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\GroupPrice\AbstractGroupPrice
@@ -18,24 +34,24 @@ class AbstractTest extends \PHPUnit\Framework\TestCase
/**
* Catalog helper
*
- * @var \Magento\Catalog\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var Data|MockObject
*/
protected $_helper;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_helper = $this->createPartialMock(\Magento\Catalog\Helper\Data::class, ['isPriceGlobal']);
+ $this->_helper = $this->createPartialMock(Data::class, ['isPriceGlobal']);
$this->_helper->expects($this->any())->method('isPriceGlobal')->will($this->returnValue(true));
- $currencyFactoryMock = $this->createPartialMock(\Magento\Directory\Model\CurrencyFactory::class, ['create']);
- $storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $productTypeMock = $this->createMock(\Magento\Catalog\Model\Product\Type::class);
- $configMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
- $localeFormatMock = $this->createMock(\Magento\Framework\Locale\FormatInterface::class);
- $groupManagement = $this->createMock(\Magento\Customer\Api\GroupManagementInterface::class);
- $scopeOverriddenValue = $this->createMock(\Magento\Catalog\Model\Attribute\ScopeOverriddenValue::class);
+ $currencyFactoryMock = $this->createPartialMock(CurrencyFactory::class, ['create']);
+ $storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $productTypeMock = $this->createMock(Type::class);
+ $configMock = $this->createMock(ScopeConfigInterface::class);
+ $localeFormatMock = $this->createMock(FormatInterface::class);
+ $groupManagement = $this->createMock(GroupManagementInterface::class);
+ $scopeOverriddenValue = $this->createMock(ScopeOverriddenValue::class);
$this->_model = $this->getMockForAbstractClass(
- \Magento\Catalog\Model\Product\Attribute\Backend\GroupPrice\AbstractGroupPrice::class,
+ AbstractGroupPrice::class,
[
'currencyFactory' => $currencyFactoryMock,
'storeManager' => $storeManagerMock,
@@ -59,7 +75,7 @@ public function testGetAffectedFields()
$attributeId = 42;
$attribute = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
+ AbstractAttribute::class,
['getBackendTable', 'isStatic', 'getAttributeId', 'getName', '__wakeup']
);
$attribute->expects($this->any())->method('getAttributeId')->will($this->returnValue($attributeId));
@@ -68,7 +84,7 @@ public function testGetAffectedFields()
$attribute->expects($this->any())->method('getName')->will($this->returnValue('tier_price'));
$this->_model->setAttribute($attribute);
- $object = new \Magento\Framework\DataObject();
+ $object = new DataObject();
$object->setTierPrice([['price_id' => 10]]);
$object->setId(555);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/EntryConverterPoolTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/EntryConverterPoolTest.php
index 0a38609f647b2..fdf80cde115c3 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/EntryConverterPoolTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/EntryConverterPoolTest.php
@@ -3,52 +3,59 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Backend\Media;
-/**
- * Class aggregate all Media Gallery Entry Converters
- */
-class EntryConverterPoolTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool;
+use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
+use Magento\Framework\DataObject;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\ProductVideo\Model\Product\Attribute\Media\ExternalVideoEntryConverter;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class EntryConverterPoolTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
* |\Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter
*/
protected $imageMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
* |\Magento\ProductVideo\Model\Product\Attribute\Media\ExternalVideoEntryConverter
*/
protected $videoMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\DataObject
+ * @var MockObject|DataObject
*/
protected $dataObjectMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->imageMock =
- $this->createMock(\Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter::class);
+ $this->createMock(ImageEntryConverter::class);
$this->imageMock->expects($this->any())->method('getMediaEntryType')->willReturn('image');
$this->videoMock =
- $this->createMock(\Magento\ProductVideo\Model\Product\Attribute\Media\ExternalVideoEntryConverter::class);
+ $this->createMock(ExternalVideoEntryConverter::class);
$this->videoMock->expects($this->any())->method('getMediaEntryType')->willReturn('external-video');
- $this->dataObjectMock = $this->createMock(\Magento\Framework\DataObject::class);
+ $this->dataObjectMock = $this->createMock(DataObject::class);
}
public function testGetConverterByMediaTypeImage()
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$converterPool = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool::class,
+ EntryConverterPool::class,
[
'mediaGalleryEntryConvertersCollection' => [$this->imageMock, $this->videoMock]
]
@@ -60,10 +67,10 @@ public function testGetConverterByMediaTypeImage()
public function testGetConverterByMediaTypeVideo()
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$converterPool = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool::class,
+ EntryConverterPool::class,
[
'mediaGalleryEntryConvertersCollection' => [$this->imageMock, $this->videoMock]
]
@@ -77,10 +84,10 @@ public function testConstructException()
{
$this->expectException('\InvalidArgumentException');
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$converterPool = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool::class,
+ EntryConverterPool::class,
[
'mediaGalleryEntryConvertersCollection' => [$this->dataObjectMock]
]
@@ -91,16 +98,16 @@ public function testConstructException()
public function testGetConverterByMediaTypeImageException()
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$converterPool = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool::class,
+ EntryConverterPool::class,
[
'mediaGalleryEntryConvertersCollection' => [$this->imageMock, $this->videoMock]
]
);
- $this->expectException(\Magento\Framework\Exception\LocalizedException::class);
+ $this->expectException(LocalizedException::class);
$converterPool->getConverterByMediaType('something_wrong');
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/ImageEntryConverterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/ImageEntryConverterTest.php
index 65be7887eb62c..90457660ee38b 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/ImageEntryConverterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/Media/ImageEntryConverterTest.php
@@ -3,50 +3,60 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Backend\Media;
-class ImageEntryConverterTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
+use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
+use Magento\Framework\Api\Data\ImageContentInterface;
+use Magento\Framework\Api\DataObjectHelper;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ImageEntryConverterTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
* |\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory
*/
protected $mediaGalleryEntryFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
* |\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntry
*/
protected $mediaGalleryEntryMock;
/**
- * @var \Magento\Framework\Api\DataObjectHelper
- * |\PHPUnit_Framework_MockObject_MockObject
+ * @var DataObjectHelper|MockObject
*/
protected $dataObjectHelperMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product
+ * @var MockObject|Product
*/
protected $productMock;
/**
- * @var \Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter
+ * @var ImageEntryConverter
* |\Magento\Framework\TestFramework\Unit\Helper\ObjectManager
*/
protected $modelObject;
- protected function setUp()
+ protected function setUp(): void
{
$this->mediaGalleryEntryFactoryMock =
$this->createPartialMock(
- \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory::class,
+ ProductAttributeMediaGalleryEntryInterfaceFactory::class,
['create']
);
$this->mediaGalleryEntryMock =
- $this->createPartialMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class, [
+ $this->createPartialMock(ProductAttributeMediaGalleryEntryInterface::class, [
'getId',
'setId',
'getMediaType',
@@ -71,14 +81,14 @@ protected function setUp()
$this->mediaGalleryEntryMock
);
- $this->dataObjectHelperMock = $this->createMock(\Magento\Framework\Api\DataObjectHelper::class);
+ $this->dataObjectHelperMock = $this->createMock(DataObjectHelper::class);
- $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $this->productMock = $this->createMock(Product::class);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->modelObject = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter::class,
+ ImageEntryConverter::class,
[
'mediaGalleryEntryFactory' => $this->mediaGalleryEntryFactoryMock,
'dataObjectHelper' => $this->dataObjectHelperMock
@@ -164,7 +174,7 @@ public function testConvertFrom()
1 => 'swatch_image',
]
);
- $imageContentInterface = $this->createMock(\Magento\Framework\Api\Data\ImageContentInterface::class);
+ $imageContentInterface = $this->createMock(ImageContentInterface::class);
$imageContentInterface->expects($this->once())->method('getBase64EncodedData')->willReturn(
base64_encode('some_content')
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/PriceTest.php
index 432251f361484..47095f9e999af 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/PriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/PriceTest.php
@@ -3,51 +3,59 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Backend;
+declare(strict_types=1);
-use Magento\Store\Model\Store;
+namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Backend;
-/**
- * Class PriceTest
- */
-class PriceTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Attribute\Backend\Price;
+use Magento\Directory\Model\CurrencyFactory;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
+use Magento\Framework\Locale\Format;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class PriceTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Attribute\Backend\Price
+ * @var Price
*/
private $model;
/**
- * @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractAttribute|MockObject
*/
private $attribute;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManager;
- /** @var \Magento\Directory\Model\CurrencyFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var CurrencyFactory|MockObject */
private $currencyFactory;
- protected function setUp()
+ protected function setUp(): void
{
- $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $localeFormat = $objectHelper->getObject(\Magento\Framework\Locale\Format::class);
- $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ $objectHelper = new ObjectManager($this);
+ $localeFormat = $objectHelper->getObject(Format::class);
+ $this->storeManager = $this->getMockBuilder(StoreManagerInterface::class)
->getMockForAbstractClass();
- $this->currencyFactory = $this->getMockBuilder(\Magento\Directory\Model\CurrencyFactory::class)
+ $this->currencyFactory = $this->getMockBuilder(CurrencyFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()->getMock();
$this->model = $objectHelper->getObject(
- \Magento\Catalog\Model\Product\Attribute\Backend\Price::class,
+ Price::class,
[
'localeFormat' => $localeFormat,
'storeManager' => $this->storeManager,
'currencyFactory' => $this->currencyFactory
]
);
- $this->attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $this->attribute = $this->getMockBuilder(AbstractAttribute::class)
->setMethods(['getAttributeCode', 'isScopeWebsite', 'getIsGlobal'])
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -61,7 +69,7 @@ protected function setUp()
*/
public function testValidate($value)
{
- $object = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $object = $this->createMock(Product::class);
$object->expects($this->once())->method('getData')->willReturn($value);
$this->assertTrue($this->model->validate($object));
@@ -86,12 +94,12 @@ public function dataProviderValidate()
/**
* Tests for the cases that expect to fail validation
*
- * @expectedException \Magento\Framework\Exception\LocalizedException
* @dataProvider dataProviderValidateForFailure
*/
public function testValidateForFailure($value)
{
- $object = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $object = $this->createMock(Product::class);
$object->expects($this->once())->method('getData')->willReturn($value);
$this->model->validate($object);
@@ -118,7 +126,7 @@ public function testAfterSaveWithDifferentStores()
$attributeCode = 'price';
$defaultStoreId = 0;
$allStoreIds = [1, 2, 3];
- $object = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()->getMock();
+ $object = $this->getMockBuilder(Product::class)->disableOriginalConstructor()->getMock();
$object->expects($this->any())->method('getData')->with($attributeCode)->willReturn($newPrice);
$object->expects($this->any())->method('getOrigData')->with($attributeCode)->willReturn('7.77');
$object->expects($this->any())->method('getStoreId')->willReturn($defaultStoreId);
@@ -126,7 +134,7 @@ public function testAfterSaveWithDifferentStores()
$object->expects($this->never())->method('getWebsiteStoreIds');
$this->attribute->expects($this->any())->method('getAttributeCode')->willReturn($attributeCode);
$this->attribute->expects($this->any())->method('isScopeWebsite')
- ->willReturn(\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE);
+ ->willReturn(ScopedAttributeInterface::SCOPE_WEBSITE);
$this->storeManager->expects($this->never())->method('getStore');
$object->expects($this->any())->method('addAttributeUpdate')->withConsecutive(
@@ -153,12 +161,12 @@ public function testAfterSaveWithOldPrice()
{
$attributeCode = 'price';
- $object = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()->getMock();
+ $object = $this->getMockBuilder(Product::class)->disableOriginalConstructor()->getMock();
$object->expects($this->any())->method('getData')->with($attributeCode)->willReturn('7.77');
$object->expects($this->any())->method('getOrigData')->with($attributeCode)->willReturn('7.77');
$this->attribute->expects($this->any())->method('getAttributeCode')->willReturn($attributeCode);
$this->attribute->expects($this->any())->method('getIsGlobal')
- ->willReturn(\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE);
+ ->willReturn(ScopedAttributeInterface::SCOPE_WEBSITE);
$object->expects($this->never())->method('addAttributeUpdate');
$this->assertEquals($this->model, $this->model->afterSave($object));
@@ -168,12 +176,12 @@ public function testAfterSaveWithGlobalPrice()
{
$attributeCode = 'price';
- $object = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()->getMock();
+ $object = $this->getMockBuilder(Product::class)->disableOriginalConstructor()->getMock();
$object->expects($this->any())->method('getData')->with($attributeCode)->willReturn('9.99');
$object->expects($this->any())->method('getOrigData')->with($attributeCode)->willReturn('7.77');
$this->attribute->expects($this->any())->method('getAttributeCode')->willReturn($attributeCode);
$this->attribute->expects($this->any())->method('getIsGlobal')
- ->willReturn(\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL);
+ ->willReturn(ScopedAttributeInterface::SCOPE_GLOBAL);
$object->expects($this->never())->method('addAttributeUpdate');
$this->assertEquals($this->model, $this->model->afterSave($object));
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/StockTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/StockTest.php
index c9a2c5febcec4..38404aa018371 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/StockTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/StockTest.php
@@ -3,40 +3,51 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Backend;
-class StockTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product\Attribute\Backend\Stock;
+use Magento\CatalogInventory\Model\Stock\Item;
+use Magento\CatalogInventory\Model\StockRegistry;
+use Magento\Framework\DataObject;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Store;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class StockTest extends TestCase
{
const ATTRIBUTE_NAME = 'quantity_and_stock_status';
/**
- * @var \Magento\Catalog\Model\Product\Attribute\Backend\Stock
+ * @var Stock
*/
protected $model;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectHelper;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
protected $stockItemMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $stockRegistry;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->stockRegistry = $this->getMockBuilder(\Magento\CatalogInventory\Model\StockRegistry::class)
+ $this->objectHelper = new ObjectManager($this);
+ $this->stockRegistry = $this->getMockBuilder(StockRegistry::class)
->disableOriginalConstructor()
->setMethods(['getStockItem', '__wakeup'])
->getMock();
$this->stockItemMock = $this->createPartialMock(
- \Magento\CatalogInventory\Model\Stock\Item::class,
+ Item::class,
['getIsInStock', 'getQty', '__wakeup']
);
@@ -44,10 +55,10 @@ protected function setUp()
->method('getStockItem')
->will($this->returnValue($this->stockItemMock));
$this->model = $this->objectHelper->getObject(
- \Magento\Catalog\Model\Product\Attribute\Backend\Stock::class,
+ Stock::class,
['stockRegistry' => $this->stockRegistry]
);
- $attribute = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getAttributeCode']);
+ $attribute = $this->createPartialMock(DataObject::class, ['getAttributeCode']);
$attribute->expects($this->atLeastOnce())
->method('getAttributeCode')
->will($this->returnValue(self::ATTRIBUTE_NAME));
@@ -61,11 +72,11 @@ public function testAfterLoad()
$this->stockItemMock->expects($this->once())->method('getIsInStock')->will($this->returnValue(1));
$this->stockItemMock->expects($this->once())->method('getQty')->will($this->returnValue(5));
- $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getWebsiteId', '__wakeup']);
+ $store = $this->createPartialMock(Store::class, ['getWebsiteId', '__wakeup']);
$store->expects($this->once())
->method('getWebsiteId')
->will($this->returnValue(10));
- $object = new \Magento\Framework\DataObject(['id' => $productId, 'store' => $store]);
+ $object = new DataObject(['id' => $productId, 'store' => $store]);
$this->model->afterLoad($object);
$data = $object->getData();
$this->assertEquals(1, $data[self::ATTRIBUTE_NAME]['is_in_stock']);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/TierpriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/TierpriceTest.php
index db103c3017e04..c8f212824ebec 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/TierpriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/TierpriceTest.php
@@ -3,36 +3,48 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Backend;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\Tierprice;
+use Magento\Customer\Api\Data\GroupInterface;
+use Magento\Customer\Api\GroupManagementInterface;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Framework\Locale\FormatInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* Unit test for Tierprice model.
*/
-class TierpriceTest extends \PHPUnit\Framework\TestCase
+class TierpriceTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\Tierprice
- * |\PHPUnit_Framework_MockObject_MockObject
+ * @var Tierprice|MockObject
*/
private $productAttributeBackendTierprice;
/**
- * @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractAttribute|MockObject
*/
private $attribute;
/**
- * @var \Magento\Framework\Locale\FormatInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var FormatInterface|MockObject
*/
private $localeFormat;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManager;
/**
- * @var \Magento\Customer\Api\GroupManagementInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupManagementInterface|MockObject
*/
private $groupManagement;
@@ -46,23 +58,23 @@ class TierpriceTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->productAttributeBackendTierprice = $this
- ->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\Tierprice::class)
+ ->getMockBuilder(Tierprice::class)
->disableOriginalConstructor()->getMock();
- $this->attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $this->attribute = $this->getMockBuilder(AbstractAttribute::class)
->setMethods(['getName', 'isScopeGlobal'])
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->localeFormat = $this->getMockBuilder(\Magento\Framework\Locale\FormatInterface::class)
+ $this->localeFormat = $this->getMockBuilder(FormatInterface::class)
->disableOriginalConstructor()->getMock();
- $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ $this->storeManager = $this->getMockBuilder(StoreManagerInterface::class)
->disableOriginalConstructor()->getMock();
- $this->groupManagement = $this->getMockBuilder(\Magento\Customer\Api\GroupManagementInterface::class)
+ $this->groupManagement = $this->getMockBuilder(GroupManagementInterface::class)
->disableOriginalConstructor()->getMock();
- $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectHelper = new ObjectManager($this);
$this->tierprice = $objectHelper->getObject(
\Magento\Catalog\Model\Product\Attribute\Backend\Tierprice::class,
[
@@ -97,7 +109,7 @@ public function testValidate()
'price_qty' => 1,
]
];
- $object = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $object = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()->getMock();
$this->attribute->expects($this->atLeastOnce())->method('getName')->willReturn($attributeName);
$object->expects($this->atLeastOnce())->method('getData')->with($attributeName)->willReturn($tierPrices);
@@ -111,11 +123,11 @@ public function testValidate()
* Test for validate method with exception.
*
* @return void
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Percentage value must be a number between 0 and 100.
*/
public function testValidateWithException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('Percentage value must be a number between 0 and 100.');
$attributeName = 'tier_price';
$tierPrices = [
[
@@ -125,7 +137,7 @@ public function testValidateWithException()
'price_qty' => 1,
]
];
- $object = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $object = $this->createMock(Product::class);
$this->attribute->expects($this->atLeastOnce())->method('getName')->willReturn($attributeName);
$object->expects($this->atLeastOnce())->method('getData')->with($attributeName)->willReturn($tierPrices);
$this->localeFormat->expects($this->once())->method('getNumber')->with(-10)->willReturnArgument(0);
@@ -176,9 +188,9 @@ public function testSetPriceData()
'website_price' => 18,
],
];
- $object = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $object = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()->getMock();
- $allCustomersGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)
+ $allCustomersGroup = $this->getMockBuilder(GroupInterface::class)
->disableOriginalConstructor()->getMock();
$this->groupManagement
->expects($this->exactly(2))
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/WeightTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/WeightTest.php
index bc9a9bc7dbfd5..4eaff9785b128 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/WeightTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/WeightTest.php
@@ -3,35 +3,47 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Backend;
-class WeightTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Attribute\Backend\Weight;
+use Magento\Directory\Model\CurrencyFactory;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Framework\App\ScopeResolverInterface;
+use Magento\Framework\Locale\Format;
+use Magento\Framework\Locale\ResolverInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
+class WeightTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Attribute\Backend\Weight
+ * @var Weight
*/
protected $model;
- protected function setUp()
+ protected function setUp(): void
{
- $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectHelper = new ObjectManager($this);
// we want to use an actual implementation of \Magento\Framework\Locale\FormatInterface
$scopeResolver = $this->getMockForAbstractClass(
- \Magento\Framework\App\ScopeResolverInterface::class,
+ ScopeResolverInterface::class,
[],
'',
false
);
$localeResolver = $this->getMockForAbstractClass(
- \Magento\Framework\Locale\ResolverInterface::class,
+ ResolverInterface::class,
[],
'',
false
);
- $currencyFactory = $this->createMock(\Magento\Directory\Model\CurrencyFactory::class);
+ $currencyFactory = $this->createMock(CurrencyFactory::class);
$localeFormat = $objectHelper->getObject(
- \Magento\Framework\Locale\Format::class,
+ Format::class,
[
'scopeResolver' => $scopeResolver,
'localeResolver' => $localeResolver,
@@ -41,12 +53,12 @@ protected function setUp()
// the model we are testing
$this->model = $objectHelper->getObject(
- \Magento\Catalog\Model\Product\Attribute\Backend\Weight::class,
+ Weight::class,
['localeFormat' => $localeFormat]
);
$attribute = $this->getMockForAbstractClass(
- \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
+ AbstractAttribute::class,
[],
'',
false
@@ -61,7 +73,7 @@ protected function setUp()
*/
public function testValidate($value)
{
- $object = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $object = $this->createMock(Product::class);
$object->expects($this->once())->method('getData')->willReturn($value);
$this->assertTrue($this->model->validate($object));
@@ -86,12 +98,12 @@ public function dataProviderValidate()
/**
* Tests for the cases that expect to fail validation
*
- * @expectedException \Magento\Framework\Exception\LocalizedException
* @dataProvider dataProviderValidateForFailure
*/
public function testValidateForFailure($value)
{
- $object = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $object = $this->createMock(Product::class);
$object->expects($this->once())->method('getData')->willReturn($value);
$this->model->validate($object);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/ImageTest.php
index 3ceedddc2b713..515c521443456 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/ImageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/ImageTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Frontend;
@@ -44,7 +45,7 @@ public function getUrlDataProvider(): array
];
}
- protected function setUp()
+ protected function setUp(): void
{
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/InputType/PresentationTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/InputType/PresentationTest.php
index d3d0285614f08..dfd96f8ac6f2a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/InputType/PresentationTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/InputType/PresentationTest.php
@@ -7,22 +7,27 @@
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Frontend\InputType;
-class PresentationTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class PresentationTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation
+ * @var Presentation
*/
private $presentation;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute| \PHPUnit_Framework_MockObject_MockObject
+ * @var Attribute|MockObject
*/
private $attributeMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->presentation = new \Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation();
- $this->attributeMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
+ $this->presentation = new Presentation();
+ $this->attributeMock = $this->getMockBuilder(Attribute::class)
->disableOriginalConstructor()
->getMock();
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/GroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/GroupTest.php
index 2d0f1026ec9b8..3aa0393ef686a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/GroupTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/GroupTest.php
@@ -3,15 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute;
+use Magento\Catalog\Model\Product\Attribute\Group;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory;
use Magento\Framework\DataObject;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class GroupTest extends \PHPUnit\Framework\TestCase
+class GroupTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Attribute\Group
+ * @var Group
*/
private $model;
@@ -21,11 +27,11 @@ public function testHasSystemAttributes()
$this->assertTrue($this->model->hasSystemAttributes());
}
- protected function setUp()
+ protected function setUp(): void
{
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Product\Attribute\Group::class,
+ Group::class,
[
'attributeCollectionFactory' => $this->getMockedCollectionFactory()
]
@@ -33,14 +39,14 @@ protected function setUp()
}
/**
- * @return \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory
+ * @return CollectionFactory
*/
private function getMockedCollectionFactory()
{
$mockedCollection = $this->getMockedCollection();
$mockBuilder = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class
+ CollectionFactory::class
);
$mock = $mockBuilder->setMethods(['create'])
->disableOriginalConstructor()
@@ -54,11 +60,11 @@ private function getMockedCollectionFactory()
}
/**
- * @return \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection
+ * @return Collection
*/
private function getMockedCollection()
{
- $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class);
+ $mockBuilder = $this->getMockBuilder(Collection::class);
$mock = $mockBuilder->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/ManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/ManagementTest.php
index fb1985b04d062..2843318cabff5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/ManagementTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/ManagementTest.php
@@ -4,25 +4,32 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute;
-class ManagementTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
+use Magento\Catalog\Model\Product\Attribute\Management;
+use Magento\Eav\Api\AttributeManagementInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ManagementTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Attribute\Management
+ * @var Management
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $attrManagementMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->attrManagementMock = $this->createMock(\Magento\Eav\Api\AttributeManagementInterface::class);
- $this->model = new \Magento\Catalog\Model\Product\Attribute\Management($this->attrManagementMock);
+ $this->attrManagementMock = $this->createMock(AttributeManagementInterface::class);
+ $this->model = new Management($this->attrManagementMock);
}
public function testAssign()
@@ -35,7 +42,7 @@ public function testAssign()
$this->attrManagementMock->expects($this->once())
->method('assign')
->with(
- \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
$attributeSetId,
$attributeGroupId,
$attributeCode,
@@ -60,12 +67,12 @@ public function testUnassign()
public function testGetAttributes()
{
$attributeSetId = 1;
- $attributeMock = $this->createMock(\Magento\Catalog\Api\Data\ProductAttributeInterface::class);
+ $attributeMock = $this->createMock(ProductAttributeInterface::class);
$this->attrManagementMock->expects($this->once())
->method('getAttributes')
->with(
- \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
$attributeSetId
)->willReturn([$attributeMock]);
$this->assertEquals([$attributeMock], $this->model->getAttributes($attributeSetId));
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/OptionManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/OptionManagementTest.php
index 430e1dc05ee15..55d602dad09c2 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/OptionManagementTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/OptionManagementTest.php
@@ -3,24 +3,33 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute;
-class OptionManagementTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
+use Magento\Catalog\Model\Product\Attribute\OptionManagement;
+use Magento\Eav\Api\AttributeOptionManagementInterface;
+use Magento\Eav\Api\Data\AttributeOptionInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class OptionManagementTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Attribute\OptionManagement
+ * @var OptionManagement
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $eavOptionManagementMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->eavOptionManagementMock = $this->createMock(\Magento\Eav\Api\AttributeOptionManagementInterface::class);
- $this->model = new \Magento\Catalog\Model\Product\Attribute\OptionManagement(
+ $this->eavOptionManagementMock = $this->createMock(AttributeOptionManagementInterface::class);
+ $this->model = new OptionManagement(
$this->eavOptionManagementMock
);
}
@@ -30,7 +39,7 @@ public function testGetItems()
$attributeCode = 10;
$this->eavOptionManagementMock->expects($this->once())
->method('getItems')
- ->with(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode)
+ ->with(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode)
->willReturn([]);
$this->assertEquals([], $this->model->getItems($attributeCode));
}
@@ -38,9 +47,9 @@ public function testGetItems()
public function testAdd()
{
$attributeCode = 42;
- $optionMock = $this->createMock(\Magento\Eav\Api\Data\AttributeOptionInterface::class);
+ $optionMock = $this->createMock(AttributeOptionInterface::class);
$this->eavOptionManagementMock->expects($this->once())->method('add')->with(
- \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
$attributeCode,
$optionMock
)->willReturn(true);
@@ -52,19 +61,17 @@ public function testDelete()
$attributeCode = 'atrCde';
$optionId = 'opt';
$this->eavOptionManagementMock->expects($this->once())->method('delete')->with(
- \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
$attributeCode,
$optionId
)->willReturn(true);
$this->assertTrue($this->model->delete($attributeCode, $optionId));
}
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Invalid option id
- */
public function testDeleteWithInvalidOption()
{
+ $this->expectException('Magento\Framework\Exception\InputException');
+ $this->expectExceptionMessage('Invalid option id');
$attributeCode = 'atrCde';
$optionId = '';
$this->eavOptionManagementMock->expects($this->never())->method('delete');
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php
index 1b42b09e5dd32..4dcab7023608c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php
@@ -4,17 +4,34 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Api\ProductAttributeOptionManagementInterface;
+use Magento\Catalog\Helper\Product;
use Magento\Catalog\Model\Product\Attribute\Repository;
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Eav\Api\AttributeOptionManagementInterface;
+use Magento\Eav\Api\AttributeRepositoryInterface;
+use Magento\Eav\Api\Data\AttributeFrontendLabelInterface;
+use Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\Attribute\FrontendLabel;
+use Magento\Framework\Api\SearchCriteria;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\Api\SearchResultsInterface;
+use Magento\Framework\DataObject;
+use Magento\Framework\Filter\FilterManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class RepositoryTest extends \PHPUnit\Framework\TestCase
+class RepositoryTest extends TestCase
{
/**
* @var Repository
@@ -22,79 +39,79 @@ class RepositoryTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $attributeResourceMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productHelperMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $filterManagerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $eavAttributeRepositoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $eavConfigMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $validatorFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $metadataConfigMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $searchCriteriaBuilderMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $searchResultMock;
/**
- * @var \Magento\Eav\Api\AttributeOptionManagementInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeOptionManagementInterface|MockObject
*/
private $optionManagementMock;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->attributeResourceMock =
$this->createMock(\Magento\Catalog\Model\ResourceModel\Attribute::class);
$this->productHelperMock =
- $this->createMock(\Magento\Catalog\Helper\Product::class);
+ $this->createMock(Product::class);
$this->filterManagerMock =
- $this->createMock(\Magento\Framework\Filter\FilterManager::class);
+ $this->createMock(FilterManager::class);
$this->eavAttributeRepositoryMock =
- $this->createMock(\Magento\Eav\Api\AttributeRepositoryInterface::class);
- $this->eavConfigMock = $this->createMock(\Magento\Eav\Model\Config::class);
+ $this->createMock(AttributeRepositoryInterface::class);
+ $this->eavConfigMock = $this->createMock(Config::class);
$this->eavConfigMock->expects($this->any())->method('getEntityType')
- ->willReturn(new \Magento\Framework\DataObject(['default_attribute_set_id' => 4]));
+ ->willReturn(new DataObject(['default_attribute_set_id' => 4]));
$this->validatorFactoryMock = $this->createPartialMock(
- \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory::class,
+ ValidatorFactory::class,
['create']
);
$this->searchCriteriaBuilderMock =
- $this->createMock(\Magento\Framework\Api\SearchCriteriaBuilder::class);
+ $this->createMock(SearchCriteriaBuilder::class);
$this->searchResultMock =
- $this->createPartialMock(\Magento\Framework\Api\SearchResultsInterface::class, [
+ $this->createPartialMock(SearchResultsInterface::class, [
'getItems',
'getSearchCriteria',
'getTotalCount',
@@ -104,7 +121,7 @@ protected function setUp()
'__wakeup',
]);
$this->optionManagementMock =
- $this->createMock(\Magento\Catalog\Api\ProductAttributeOptionManagementInterface::class);
+ $this->createMock(ProductAttributeOptionManagementInterface::class);
$this->model = new Repository(
$this->attributeResourceMock,
@@ -127,7 +144,7 @@ public function testGet()
$this->eavAttributeRepositoryMock->expects($this->once())
->method('get')
->with(
- \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
$attributeCode
);
$this->model->get($attributeCode);
@@ -138,11 +155,11 @@ public function testGet()
*/
public function testGetList()
{
- $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteria::class);
+ $searchCriteriaMock = $this->createMock(SearchCriteria::class);
$this->eavAttributeRepositoryMock->expects($this->once())
->method('getList')
->with(
- \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
$searchCriteriaMock
);
@@ -154,7 +171,7 @@ public function testGetList()
*/
public function testDelete()
{
- $attributeMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
+ $attributeMock = $this->createMock(Attribute::class);
$this->attributeResourceMock->expects($this->once())->method('delete')->with($attributeMock);
$this->assertEquals(true, $this->model->delete($attributeMock));
@@ -166,11 +183,11 @@ public function testDelete()
public function testDeleteById()
{
$attributeCode = 'some attribute code';
- $attributeMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
+ $attributeMock = $this->createMock(Attribute::class);
$this->eavAttributeRepositoryMock->expects($this->once())
->method('get')
->with(
- \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
$attributeCode
)->willReturn($attributeMock);
$this->attributeResourceMock->expects($this->once())->method('delete')->with($attributeMock);
@@ -183,13 +200,13 @@ public function testDeleteById()
*/
public function testGetCustomAttributesMetadata()
{
- $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteria::class);
+ $searchCriteriaMock = $this->createMock(SearchCriteria::class);
$this->searchCriteriaBuilderMock->expects($this->once())->method('create')->willReturn($searchCriteriaMock);
- $itemMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class);
+ $itemMock = $this->createMock(ProductInterface::class);
$this->eavAttributeRepositoryMock->expects($this->once())
->method('getList')
->with(
- \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
$searchCriteriaMock
)->willReturn($this->searchResultMock);
$this->searchResultMock->expects($this->once())->method('getItems')->willReturn([$itemMock]);
@@ -198,21 +215,19 @@ public function testGetCustomAttributesMetadata()
$this->assertEquals($expected, $this->model->getCustomAttributesMetadata());
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage No such entity with attribute_code = test attribute code
- */
public function testSaveNoSuchEntityException()
{
- $attributeMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
- $existingModelMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage('No such entity with attribute_code = test attribute code');
+ $attributeMock = $this->createMock(Attribute::class);
+ $existingModelMock = $this->createMock(Attribute::class);
$attributeMock->expects($this->once())->method('getAttributeId')->willReturn('12');
$attributeCode = 'test attribute code';
$attributeMock->expects($this->once())->method('getAttributeCode')->willReturn($attributeCode);
$this->eavAttributeRepositoryMock->expects($this->once())
->method('get')
->with(
- \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
$attributeCode
)
->willReturn($existingModelMock);
@@ -222,14 +237,12 @@ public function testSaveNoSuchEntityException()
$this->model->save($attributeMock);
}
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage "frontend_label" is required. Enter and try again.
- */
public function testSaveInputExceptionRequiredField()
{
+ $this->expectException('Magento\Framework\Exception\InputException');
+ $this->expectExceptionMessage('"frontend_label" is required. Enter and try again.');
$attributeMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class,
+ Attribute::class,
['getFrontendLabels', 'getDefaultFrontendLabel', '__wakeup', 'getAttributeId', 'setAttributeId']
);
$attributeMock->expects($this->once())->method('getAttributeId')->willReturn(null);
@@ -240,19 +253,17 @@ public function testSaveInputExceptionRequiredField()
$this->model->save($attributeMock);
}
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Invalid value of "" provided for the frontend_label field.
- */
public function testSaveInputExceptionInvalidFieldValue()
{
+ $this->expectException('Magento\Framework\Exception\InputException');
+ $this->expectExceptionMessage('Invalid value of "" provided for the frontend_label field.');
$attributeMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class,
+ Attribute::class,
['getFrontendLabels', 'getDefaultFrontendLabel', 'getAttributeId', '__wakeup', 'setAttributeId']
);
$attributeMock->expects($this->once())->method('getAttributeId')->willReturn(null);
$attributeMock->expects($this->once())->method('setAttributeId')->with(null)->willReturnSelf();
- $labelMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\FrontendLabel::class);
+ $labelMock = $this->createMock(FrontendLabel::class);
$attributeMock->expects($this->any())->method('getFrontendLabels')->willReturn([$labelMock]);
$attributeMock->expects($this->any())->method('getDefaultFrontendLabel')->willReturn(null);
$labelMock->expects($this->once())->method('getStoreId')->willReturn(0);
@@ -294,7 +305,7 @@ public function testSaveDoesNotSaveAttributeOptionsIfOptionsAreAbsentInPayload()
*/
public function testSaveSavesDefaultFrontendLabelIfItIsPresentInPayload()
{
- $labelMock = $this->createMock(\Magento\Eav\Api\Data\AttributeFrontendLabelInterface::class);
+ $labelMock = $this->createMock(AttributeFrontendLabelInterface::class);
$labelMock->expects($this->any())->method('getStoreId')->willReturn(1);
$labelMock->expects($this->any())->method('getLabel')->willReturn('Store Scope Label');
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetManagementTest.php
index 1f4c4dd378206..9e24ce18bbccd 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetManagementTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetManagementTest.php
@@ -4,37 +4,49 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute;
-class SetManagementTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Attribute\SetManagement;
+use Magento\Eav\Api\AttributeSetManagementInterface;
+use Magento\Eav\Api\AttributeSetRepositoryInterface;
+use Magento\Eav\Api\Data\AttributeSetInterface;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\Type;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class SetManagementTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Attribute\SetManagement
+ * @var SetManagement
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $attrSetManagementMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $attributeSetRepository;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $eavConfig;
- protected function setUp()
+ protected function setUp(): void
{
- $this->attrSetManagementMock = $this->createMock(\Magento\Eav\Api\AttributeSetManagementInterface::class);
- $this->attributeSetRepository = $this->createMock(\Magento\Eav\Api\AttributeSetRepositoryInterface::class);
- $this->eavConfig = $this->createMock(\Magento\Eav\Model\Config::class);
- $this->model = new \Magento\Catalog\Model\Product\Attribute\SetManagement(
+ $this->attrSetManagementMock = $this->createMock(AttributeSetManagementInterface::class);
+ $this->attributeSetRepository = $this->createMock(AttributeSetRepositoryInterface::class);
+ $this->eavConfig = $this->createMock(Config::class);
+ $this->model = new SetManagement(
$this->attrSetManagementMock,
$this->attributeSetRepository,
$this->eavConfig
@@ -44,50 +56,48 @@ protected function setUp()
public function testCreate()
{
$skeletonId = 1;
- $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class);
- $skeletonSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class);
+ $attributeSetMock = $this->createMock(AttributeSetInterface::class);
+ $skeletonSetMock = $this->createMock(AttributeSetInterface::class);
$this->attributeSetRepository->expects($this->once())
->method('get')
->with($skeletonId)
->willReturn($skeletonSetMock);
- $typeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class);
+ $typeMock = $this->createMock(Type::class);
$typeMock->expects($this->once())->method('getId')->willReturn(4);
$this->eavConfig->expects($this->once())
->method('getEntityType')
- ->with(\Magento\Catalog\Model\Product::ENTITY)
+ ->with(Product::ENTITY)
->willReturn($typeMock);
$skeletonSetMock->expects($this->once())->method('getEntityTypeId')->willReturn(4);
$this->attrSetManagementMock->expects($this->once())
->method('create')
->with(
- \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
$attributeSetMock,
$skeletonId
)->willReturn($attributeSetMock);
$this->assertEquals($attributeSetMock, $this->model->create($attributeSetMock, $skeletonId));
}
- /**
- * @expectedException \Magento\Framework\Exception\StateException
- */
public function testCreateNonProductAttributeSet()
{
+ $this->expectException('Magento\Framework\Exception\StateException');
$skeletonId = 1;
- $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class);
- $skeletonSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class);
+ $attributeSetMock = $this->createMock(AttributeSetInterface::class);
+ $skeletonSetMock = $this->createMock(AttributeSetInterface::class);
$this->attributeSetRepository->expects($this->once())
->method('get')
->with($skeletonId)
->willReturn($skeletonSetMock);
- $typeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class);
+ $typeMock = $this->createMock(Type::class);
$typeMock->expects($this->once())->method('getId')->willReturn(4);
$this->eavConfig->expects($this->once())
->method('getEntityType')
- ->with(\Magento\Catalog\Model\Product::ENTITY)
+ ->with(Product::ENTITY)
->willReturn($typeMock);
$skeletonSetMock->expects($this->once())->method('getEntityTypeId')->willReturn(3);
$this->model->create($attributeSetMock, $skeletonId);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php
index aba9f6d8fa4d4..5879a33a0eb7a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php
@@ -4,46 +4,63 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute;
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Attribute\SetRepository;
+use Magento\Eav\Api\AttributeSetRepositoryInterface;
+use Magento\Eav\Api\Data\AttributeSetInterface;
+use Magento\Eav\Api\Data\AttributeSetSearchResultsInterface;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\Type;
+use Magento\Framework\Api\Filter;
+use Magento\Framework\Api\FilterBuilder;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\Api\SearchCriteriaInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class SetRepositoryTest extends \PHPUnit\Framework\TestCase
+class SetRepositoryTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Attribute\SetRepository
+ * @var SetRepository
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $attrSetRepositoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $searchCriteriaBuilderMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $filterBuilderMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $eavConfig;
- protected function setUp()
+ protected function setUp(): void
{
- $this->attrSetRepositoryMock = $this->createMock(\Magento\Eav\Api\AttributeSetRepositoryInterface::class);
- $this->searchCriteriaBuilderMock = $this->createMock(\Magento\Framework\Api\SearchCriteriaBuilder::class);
- $this->filterBuilderMock = $this->createMock(\Magento\Framework\Api\FilterBuilder::class);
- $this->eavConfig = $this->createMock(\Magento\Eav\Model\Config::class);
+ $this->attrSetRepositoryMock = $this->createMock(AttributeSetRepositoryInterface::class);
+ $this->searchCriteriaBuilderMock = $this->createMock(SearchCriteriaBuilder::class);
+ $this->filterBuilderMock = $this->createMock(FilterBuilder::class);
+ $this->eavConfig = $this->createMock(Config::class);
- $this->model = new \Magento\Catalog\Model\Product\Attribute\SetRepository(
+ $this->model = new SetRepository(
$this->attrSetRepositoryMock,
$this->searchCriteriaBuilderMock,
$this->filterBuilderMock,
@@ -53,7 +70,7 @@ protected function setUp()
public function testSave()
{
- $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class);
+ $attributeSetMock = $this->createMock(AttributeSetInterface::class);
$this->setMockForValidation($attributeSetMock, 4);
$this->attrSetRepositoryMock->expects($this->once())
@@ -63,13 +80,11 @@ public function testSave()
$this->assertEquals($attributeSetMock, $this->model->save($attributeSetMock));
}
- /**
- * @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Provided Attribute set non product Attribute set.
- */
public function testSaveNonProductAttributeSet()
{
- $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class);
+ $this->expectException('Magento\Framework\Exception\StateException');
+ $this->expectExceptionMessage('Provided Attribute set non product Attribute set.');
+ $attributeSetMock = $this->createMock(AttributeSetInterface::class);
$this->setMockForValidation($attributeSetMock, 3);
$this->attrSetRepositoryMock->expects($this->never())->method('save');
$this->model->save($attributeSetMock);
@@ -78,7 +93,7 @@ public function testSaveNonProductAttributeSet()
public function testGet()
{
$attributeSetId = 1;
- $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class);
+ $attributeSetMock = $this->createMock(AttributeSetInterface::class);
$this->setMockForValidation($attributeSetMock, 4);
$this->attrSetRepositoryMock->expects($this->once())
@@ -88,14 +103,12 @@ public function testGet()
$this->assertEquals($attributeSetMock, $this->model->get($attributeSetId));
}
- /**
- * @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Provided Attribute set non product Attribute set.
- */
public function testGetNonProductAttributeSet()
{
+ $this->expectException('Magento\Framework\Exception\StateException');
+ $this->expectExceptionMessage('Provided Attribute set non product Attribute set.');
$attributeSetId = 1;
- $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class);
+ $attributeSetMock = $this->createMock(AttributeSetInterface::class);
$this->setMockForValidation($attributeSetMock, 3);
$this->attrSetRepositoryMock->expects($this->once())
@@ -107,7 +120,7 @@ public function testGetNonProductAttributeSet()
public function testDelete()
{
- $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class);
+ $attributeSetMock = $this->createMock(AttributeSetInterface::class);
$this->setMockForValidation($attributeSetMock, 4);
$this->attrSetRepositoryMock->expects($this->once())
->method('delete')
@@ -116,13 +129,11 @@ public function testDelete()
$this->assertTrue($this->model->delete($attributeSetMock));
}
- /**
- * @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Provided Attribute set non product Attribute set.
- */
public function testDeleteNonProductAttributeSet()
{
- $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class);
+ $this->expectException('Magento\Framework\Exception\StateException');
+ $this->expectExceptionMessage('Provided Attribute set non product Attribute set.');
+ $attributeSetMock = $this->createMock(AttributeSetInterface::class);
$this->setMockForValidation($attributeSetMock, 3);
$this->attrSetRepositoryMock->expects($this->never())
->method('delete');
@@ -132,7 +143,7 @@ public function testDeleteNonProductAttributeSet()
public function testDeleteById()
{
$attributeSetId = 1;
- $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class);
+ $attributeSetMock = $this->createMock(AttributeSetInterface::class);
$this->setMockForValidation($attributeSetMock, 4);
$this->attrSetRepositoryMock->expects($this->once())
@@ -149,13 +160,13 @@ public function testDeleteById()
public function testGetList()
{
- $searchResultMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetSearchResultsInterface::class);
+ $searchResultMock = $this->createMock(AttributeSetSearchResultsInterface::class);
- $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteriaInterface::class);
+ $searchCriteriaMock = $this->createMock(SearchCriteriaInterface::class);
$searchCriteriaMock->expects($this->once())->method('getCurrentPage')->willReturn(1);
$searchCriteriaMock->expects($this->once())->method('getPageSize')->willReturn(2);
- $filterMock = $this->createMock(\Magento\Framework\Api\Filter::class);
+ $filterMock = $this->createMock(Filter::class);
$this->filterBuilderMock->expects($this->once())
->method('setField')
@@ -163,7 +174,7 @@ public function testGetList()
->willReturnSelf();
$this->filterBuilderMock->expects($this->once())
->method('setValue')
- ->with(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE)
+ ->with(ProductAttributeInterface::ENTITY_TYPE_CODE)
->willReturnSelf();
$this->filterBuilderMock->expects($this->once())
->method('setConditionType')
@@ -185,7 +196,7 @@ public function testGetList()
->willReturnSelf();
$this->searchCriteriaBuilderMock->expects($this->once())
->method('create')
- ->willReturn($this->createMock(\Magento\Framework\Api\SearchCriteriaInterface::class));
+ ->willReturn($this->createMock(SearchCriteriaInterface::class));
$this->attrSetRepositoryMock->expects($this->once())
->method('getList')
@@ -197,18 +208,18 @@ public function testGetList()
/**
* Set mock for attribute set validation
*
- * @param \PHPUnit_Framework_MockObject_MockObject $attributeSetMock
+ * @param MockObject $attributeSetMock
* @param $setEntityTypeId
*/
protected function setMockForValidation(
- \PHPUnit_Framework_MockObject_MockObject $attributeSetMock,
+ MockObject $attributeSetMock,
$setEntityTypeId
) {
- $typeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class);
+ $typeMock = $this->createMock(Type::class);
$typeMock->expects($this->once())->method('getId')->willReturn(4);
$this->eavConfig->expects($this->once())
->method('getEntityType')
- ->with(\Magento\Catalog\Model\Product::ENTITY)
+ ->with(Product::ENTITY)
->willReturn($typeMock);
$attributeSetMock->expects($this->once())->method('getEntityTypeId')->willReturn($setEntityTypeId);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/BooleanTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/BooleanTest.php
index 9ea6177bc2b37..88212c0862ab8 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/BooleanTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/BooleanTest.php
@@ -3,14 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Source;
use Magento\Catalog\Model\Product\Attribute\Source\Boolean as BooleanSource;
+use Magento\Eav\Model\ResourceModel\Entity\AttributeFactory;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class BooleanTest extends \PHPUnit\Framework\TestCase
+class BooleanTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $attributeFactoryMock;
@@ -19,10 +24,10 @@ class BooleanTest extends \PHPUnit\Framework\TestCase
*/
private $model;
- protected function setUp()
+ protected function setUp(): void
{
$this->attributeFactoryMock = $this->createMock(
- \Magento\Eav\Model\ResourceModel\Entity\AttributeFactory::class
+ AttributeFactory::class
);
$this->model = new BooleanSource($this->attributeFactoryMock);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php
index e541114a7644b..0bbe778c94233 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php
@@ -3,48 +3,57 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Source;
+use Magento\Catalog\Model\Product\Attribute\Source\Countryofmanufacture;
+use Magento\Framework\App\Cache\Type\Config;
use Magento\Framework\Serialize\SerializerInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CountryofmanufactureTest extends \PHPUnit\Framework\TestCase
+class CountryofmanufactureTest extends TestCase
{
/**
- * @var \Magento\Store\Model\StoreManagerInterface
+ * @var StoreManagerInterface
*/
protected $storeManagerMock;
/**
- * @var \Magento\Store\Model\Store
+ * @var Store
*/
protected $storeMock;
/**
- * @var \Magento\Framework\App\Cache\Type\Config
+ * @var Config
*/
protected $cacheConfig;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManagerHelper;
- /** @var \Magento\Catalog\Model\Product\Attribute\Source\Countryofmanufacture */
+ /** @var Countryofmanufacture */
private $countryOfManufacture;
/**
- * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var SerializerInterface|MockObject
*/
private $serializerMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class);
- $this->cacheConfig = $this->createMock(\Magento\Framework\App\Cache\Type\Config::class);
- $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $this->storeMock = $this->createMock(Store::class);
+ $this->cacheConfig = $this->createMock(Config::class);
+ $this->objectManagerHelper = new ObjectManager($this);
$this->countryOfManufacture = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Model\Product\Attribute\Source\Countryofmanufacture::class,
+ Countryofmanufacture::class,
[
'storeManager' => $this->storeManagerMock,
'configCacheType' => $this->cacheConfig,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/InputtypeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/InputtypeTest.php
index ef3a00e535576..bf9a812fcbbc1 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/InputtypeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/InputtypeTest.php
@@ -3,29 +3,34 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Source;
+use Magento\Catalog\Model\Product\Attribute\Source\Inputtype;
+use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class InputtypeTest extends \PHPUnit\Framework\TestCase
+class InputtypeTest extends TestCase
{
- /** @var \Magento\Catalog\Model\Product\Attribute\Source\Inputtype */
+ /** @var Inputtype */
protected $inputtypeModel;
/** @var ObjectManagerHelper */
protected $objectManagerHelper;
- /** @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Registry|MockObject */
protected $registry;
- protected function setUp()
+ protected function setUp(): void
{
- $this->registry = $this->createMock(\Magento\Framework\Registry::class);
+ $this->registry = $this->createMock(Registry::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->inputtypeModel = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Model\Product\Attribute\Source\Inputtype::class,
+ Inputtype::class,
[
'coreRegistry' => $this->registry,
'optionsArray' => $this->getInputTypeSet()
@@ -35,7 +40,6 @@ protected function setUp()
public function testToOptionArray()
{
-
$extraValues = [
['value' => 'price', 'label' => 'Price'],
['value' => 'media_image', 'label' => 'Media Image']
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/LayoutTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/LayoutTest.php
index c228806b5c662..6e2b711263136 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/LayoutTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/LayoutTest.php
@@ -3,32 +3,37 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Source;
+use Magento\Catalog\Model\Product\Attribute\Source\Layout;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\View\Model\PageLayout\Config\BuilderInterface;
+use Magento\Framework\View\PageLayout\Config;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class LayoutTest extends \PHPUnit\Framework\TestCase
+class LayoutTest extends TestCase
{
- /** @var \Magento\Catalog\Model\Product\Attribute\Source\Layout */
+ /** @var Layout */
protected $layoutModel;
/** @var ObjectManagerHelper */
protected $objectManagerHelper;
- /** @var \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface
- * |\PHPUnit_Framework_MockObject_MockObject */
+ /** @var BuilderInterface|MockObject */
protected $pageLayoutBuilder;
- protected function setUp()
+ protected function setUp(): void
{
$this->pageLayoutBuilder = $this->getMockBuilder(
- \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface::class
+ BuilderInterface::class
)->disableOriginalConstructor()->getMock();
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->layoutModel = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Model\Product\Attribute\Source\Layout::class,
+ Layout::class,
[
'pageLayoutBuilder' => $this->pageLayoutBuilder
]
@@ -41,7 +46,7 @@ public function testGetAllOptions()
'0' => ['value' => '', 'label' => 'No layout updates'],
'1' => ['value' => 'option_value', 'label' => 'option_label'],
];
- $mockPageLayoutConfig = $this->getMockBuilder(\Magento\Framework\View\PageLayout\Config::class)
+ $mockPageLayoutConfig = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
$mockPageLayoutConfig->expects($this->any())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/StatusTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/StatusTest.php
index eb96de9b0c491..5d78b485feea3 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/StatusTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/StatusTest.php
@@ -3,39 +3,49 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Source;
+use Magento\Catalog\Model\Entity\Attribute;
+use Magento\Catalog\Model\Product\Attribute\Backend\Sku;
+use Magento\Catalog\Model\Product\Attribute\Source\Status;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
use Magento\Eav\Model\Entity\AbstractEntity;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
+use Magento\Eav\Model\Entity\Collection\AbstractCollection;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class StatusTest extends \PHPUnit\Framework\TestCase
+class StatusTest extends TestCase
{
- /** @var \Magento\Catalog\Model\Product\Attribute\Source\Status */
+ /** @var Status */
protected $status;
/** @var ObjectManagerHelper */
protected $objectManagerHelper;
- /** @var \Magento\Eav\Model\Entity\Collection\AbstractCollection|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var AbstractCollection|MockObject */
protected $collection;
- /** @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var AbstractAttribute|MockObject */
protected $attributeModel;
- /** @var \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var AbstractBackend|MockObject */
protected $backendAttributeModel;
/**
- * @var AbstractEntity|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractEntity|MockObject
*/
protected $entity;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->collection = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\Collection::class,
+ Collection::class,
[
'__wakeup',
'getSelect',
@@ -47,7 +57,7 @@ protected function setUp()
]
);
$this->attributeModel = $this->createPartialMock(
- \Magento\Catalog\Model\Entity\Attribute::class,
+ Attribute::class,
[
'__wakeup',
'getAttributeCode',
@@ -59,11 +69,11 @@ protected function setUp()
]
);
$this->backendAttributeModel = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Attribute\Backend\Sku::class,
+ Sku::class,
['__wakeup', 'getTable']
);
$this->status = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Model\Product\Attribute\Source\Status::class
+ Status::class
);
$this->attributeModel->expects($this->any())->method('getAttribute')
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/TypesListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/TypesListTest.php
index d3a2d85ed72af..f27468ffd5c18 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/TypesListTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/TypesListTest.php
@@ -4,12 +4,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute;
+use Magento\Catalog\Api\Data\ProductAttributeTypeInterface;
+use Magento\Catalog\Api\Data\ProductAttributeTypeInterfaceFactory;
+use Magento\Catalog\Model\Product\Attribute\Source\Inputtype;
+use Magento\Catalog\Model\Product\Attribute\Source\InputtypeFactory;
use Magento\Catalog\Model\Product\Attribute\TypesList;
+use Magento\Framework\Api\DataObjectHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class TypesListTest extends \PHPUnit\Framework\TestCase
+class TypesListTest extends TestCase
{
/**
* @var TypesList
@@ -17,32 +25,32 @@ class TypesListTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $inputTypeFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $attributeTypeFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Api\DataObjectHelper
+ * @var MockObject|DataObjectHelper
*/
protected $dataObjectHelperMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->inputTypeFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Attribute\Source\InputtypeFactory::class,
+ InputtypeFactory::class,
['create', '__wakeup']
);
$this->attributeTypeFactoryMock =
- $this->createPartialMock(\Magento\Catalog\Api\Data\ProductAttributeTypeInterfaceFactory::class, [
+ $this->createPartialMock(ProductAttributeTypeInterfaceFactory::class, [
'create',
]);
- $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class)
+ $this->dataObjectHelperMock = $this->getMockBuilder(DataObjectHelper::class)
->disableOriginalConstructor()
->getMock();
$this->model = new TypesList(
@@ -54,13 +62,13 @@ protected function setUp()
public function testGetItems()
{
- $inputTypeMock = $this->createMock(\Magento\Catalog\Model\Product\Attribute\Source\Inputtype::class);
+ $inputTypeMock = $this->createMock(Inputtype::class);
$this->inputTypeFactoryMock->expects($this->once())->method('create')->willReturn($inputTypeMock);
$inputTypeMock->expects($this->once())->method('toOptionArray')->willReturn(['option' => ['value']]);
- $attributeTypeMock = $this->createMock(\Magento\Catalog\Api\Data\ProductAttributeTypeInterface::class);
+ $attributeTypeMock = $this->createMock(ProductAttributeTypeInterface::class);
$this->dataObjectHelperMock->expects($this->once())
->method('populateWithArray')
- ->with($attributeTypeMock, ['value'], \Magento\Catalog\Api\Data\ProductAttributeTypeInterface::class)
+ ->with($attributeTypeMock, ['value'], ProductAttributeTypeInterface::class)
->willReturnSelf();
$this->attributeTypeFactoryMock->expects($this->once())->method('create')->willReturn($attributeTypeMock);
$this->assertEquals([$attributeTypeMock], $this->model->getItems());
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CartConfigurationTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CartConfigurationTest.php
index 2144cf34c2a09..a4114b767c1e2 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CartConfigurationTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CartConfigurationTest.php
@@ -3,9 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product;
-class CartConfigurationTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\CartConfiguration;
+use PHPUnit\Framework\TestCase;
+
+class CartConfigurationTest extends TestCase
{
/**
* @param string $productType
@@ -15,8 +21,8 @@ class CartConfigurationTest extends \PHPUnit\Framework\TestCase
*/
public function testIsProductConfigured($productType, $config, $expected)
{
- $cartConfiguration = new \Magento\Catalog\Model\Product\CartConfiguration();
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $cartConfiguration = new CartConfiguration();
+ $productMock = $this->createMock(Product::class);
$productMock->expects($this->once())->method('getTypeId')->will($this->returnValue($productType));
$this->assertEquals($expected, $cartConfiguration->isProductConfigured($productMock, $config));
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CatalogPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CatalogPriceTest.php
index aadce1ab5b03e..0dfbb27ef7ee7 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CatalogPriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CatalogPriceTest.php
@@ -3,38 +3,47 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product;
-class CatalogPriceTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\CatalogPrice;
+use Magento\Catalog\Model\Product\CatalogPriceFactory;
+use Magento\Catalog\Model\Product\CatalogPriceInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class CatalogPriceTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\CatalogPrice
+ * @var CatalogPrice
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $priceFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $catalogPriceInterfaceMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->priceFactoryMock = $this->createMock(\Magento\Catalog\Model\Product\CatalogPriceFactory::class);
- $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $this->priceFactoryMock = $this->createMock(CatalogPriceFactory::class);
+ $this->productMock = $this->createMock(Product::class);
$this->catalogPriceInterfaceMock = $this->createMock(
- \Magento\Catalog\Model\Product\CatalogPriceInterface::class
+ CatalogPriceInterface::class
);
- $this->model = new \Magento\Catalog\Model\Product\CatalogPrice(
+ $this->model = new CatalogPrice(
$this->priceFactoryMock,
['custom_product_type' => 'CustomProduct/Model/CatalogPrice']
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Compare/ItemTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Compare/ItemTest.php
index 449c222d81ae1..59a2f26558112 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Compare/ItemTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Compare/ItemTest.php
@@ -3,22 +3,28 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Compare;
-class ItemTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product\Compare\Item;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
+class ItemTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Compare\Item
+ * @var Item
*/
protected $model;
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->model = $objectManager->getObject(\Magento\Catalog\Model\Product\Compare\Item::class);
+ $objectManager = new ObjectManager($this);
+ $this->model = $objectManager->getObject(Item::class);
}
- protected function tearDown()
+ protected function tearDown(): void
{
$this->model = null;
}
@@ -28,7 +34,7 @@ public function testGetIdentities()
$id = 1;
$this->model->setId($id);
$this->assertEquals(
- [\Magento\Catalog\Model\Product\Compare\Item::CACHE_TAG . '_' . $id],
+ [Item::CACHE_TAG . '_' . $id],
$this->model->getIdentities()
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ConditionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ConditionTest.php
index 09ed3fcb74273..fb1befa95f041 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ConditionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ConditionTest.php
@@ -3,17 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product;
+use Magento\Catalog\Model\Product\Condition;
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Select;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class ConditionTest extends \PHPUnit\Framework\TestCase
+class ConditionTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Condition
+ * @var Condition
*/
private $model;
@@ -21,7 +25,7 @@ public function testApplyToCollection()
{
$collection = $this->getMockedAbstractCollection();
$this->assertInstanceOf(
- \Magento\Catalog\Model\Product\Condition::class,
+ Condition::class,
$this->model->applyToCollection($collection)
);
}
@@ -29,15 +33,15 @@ public function testApplyToCollection()
public function testGetIdsSelect()
{
$connection = $this->getMockedAdapterInterface();
- $this->assertInstanceOf(\Magento\Framework\DB\Select::class, $this->model->getIdsSelect($connection));
+ $this->assertInstanceOf(Select::class, $this->model->getIdsSelect($connection));
$this->model->setTable(null);
$this->assertEmpty($this->model->getIdsSelect($connection));
}
- protected function setUp()
+ protected function setUp(): void
{
$helper = new ObjectManager($this);
- $this->model = $helper->getObject(\Magento\Catalog\Model\Product\Condition::class);
+ $this->model = $helper->getObject(Condition::class);
$this->model->setTable('testTable')
->setPkFieldName('testFieldName');
}
@@ -47,7 +51,7 @@ protected function setUp()
*/
private function getMockedAbstractCollection()
{
- $mockBuilder = $this->getMockBuilder(\Magento\Eav\Model\Entity\Collection\AbstractCollection::class)
+ $mockBuilder = $this->getMockBuilder(AbstractCollection::class)
->setMethods(['joinTable'])
->disableOriginalConstructor();
$mock = $mockBuilder->getMockForAbstractClass();
@@ -65,7 +69,7 @@ private function getMockedAdapterInterface()
{
$mockedDbSelect = $this->getMockedDbSelect();
- $mockBuilder = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
+ $mockBuilder = $this->getMockBuilder(AdapterInterface::class)
->setMethods(['select'])
->disableOriginalConstructor();
$mock = $mockBuilder->getMockForAbstractClass();
@@ -82,7 +86,7 @@ private function getMockedAdapterInterface()
*/
private function getMockedDbSelect()
{
- $mockBuilder = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $mockBuilder = $this->getMockBuilder(Select::class)
->setMethods(['from'])
->disableOriginalConstructor();
$mock = $mockBuilder->getMockForAbstractClass();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php
index c58a652fb5c1e..a5fa4d1fec80a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product;
@@ -21,6 +22,7 @@
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
use Magento\Framework\EntityManager\EntityMetadata;
use Magento\Framework\EntityManager\MetadataPool;
+use Magento\UrlRewrite\Model\Exception\UrlAlreadyExistsException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
@@ -69,7 +71,7 @@ class CopierTest extends TestCase
/**
* @ingeritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->copyConstructorMock = $this->createMock(CopyConstructorInterface::class);
$this->productFactoryMock = $this->createPartialMock(ProductFactory::class, ['create']);
@@ -286,7 +288,7 @@ public function testUrlAlreadyExistsExceptionWhileCopyStoresUrl(): void
]);
$entityMock = $this->getMockForAbstractClass(
- \Magento\Eav\Model\Entity\AbstractEntity::class,
+ AbstractEntity::class,
[],
'',
false,
@@ -299,7 +301,7 @@ public function testUrlAlreadyExistsExceptionWhileCopyStoresUrl(): void
->willReturn(true, false);
$attributeMock = $this->getMockForAbstractClass(
- \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
+ AbstractAttribute::class,
[],
'',
false,
@@ -354,7 +356,7 @@ public function testUrlAlreadyExistsExceptionWhileCopyStoresUrl(): void
)->method(
'setStatus'
)->with(
- \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED
+ Status::STATUS_DISABLED
);
$duplicateMock->expects($this->atLeastOnce())->method('setStoreId');
$duplicateMock->expects($this->once())->method('setCreatedAt')->with(null);
@@ -382,7 +384,7 @@ public function testUrlAlreadyExistsExceptionWhileCopyStoresUrl(): void
['linkField', null, '2'],
]);
- $this->expectException(\Magento\UrlRewrite\Model\Exception\UrlAlreadyExistsException::class);
+ $this->expectException(UrlAlreadyExistsException::class);
$this->_model->copy($this->productMock);
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CompositeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CompositeTest.php
index e2c0b387ae98d..84194f2221a5f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CompositeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CompositeTest.php
@@ -3,15 +3,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\CopyConstructor;
-class CompositeTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\CopyConstructor\Composite;
+use Magento\Catalog\Model\Product\CopyConstructorFactory;
+use Magento\Catalog\Model\Product\CopyConstructorInterface;
+use PHPUnit\Framework\TestCase;
+
+class CompositeTest extends TestCase
{
public function testBuild()
{
- $factoryMock = $this->createMock(\Magento\Catalog\Model\Product\CopyConstructorFactory::class);
+ $factoryMock = $this->createMock(CopyConstructorFactory::class);
- $constructorMock = $this->createMock(\Magento\Catalog\Model\Product\CopyConstructorInterface::class);
+ $constructorMock = $this->createMock(CopyConstructorInterface::class);
$factoryMock->expects(
$this->exactly(2)
@@ -23,12 +31,12 @@ public function testBuild()
$this->returnValue($constructorMock)
);
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $duplicateMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $productMock = $this->createMock(Product::class);
+ $duplicateMock = $this->createMock(Product::class);
$constructorMock->expects($this->exactly(2))->method('build')->with($productMock, $duplicateMock);
- $model = new \Magento\Catalog\Model\Product\CopyConstructor\Composite(
+ $model = new Composite(
$factoryMock,
['constructorInstance', 'constructorInstance']
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CrossSellTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CrossSellTest.php
index f83a9494a2ea1..532ebe2fc8a73 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CrossSellTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/CrossSellTest.php
@@ -3,48 +3,58 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\CopyConstructor;
-class CrossSellTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\CopyConstructor\CrossSell;
+use Magento\Catalog\Model\Product\Link;
+use Magento\Catalog\Model\ResourceModel\Product\Link\Collection;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class CrossSellTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\CopyConstructor\CrossSell
+ * @var CrossSell
*/
protected $_model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_productMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_duplicateMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_linkMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_linkCollectionMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_model = new \Magento\Catalog\Model\Product\CopyConstructor\CrossSell();
+ $this->_model = new CrossSell();
- $this->_productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $this->_productMock = $this->createMock(Product::class);
$this->_duplicateMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
['setCrossSellLinkData', '__wakeup']
);
$this->_linkMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Link::class,
+ Link::class,
['__wakeup', 'getAttributes', 'getCrossSellLinkCollection', 'useCrossSellLinks']
);
@@ -59,7 +69,7 @@ protected function setUp()
public function testBuild()
{
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $helper = new ObjectManager($this);
$expectedData = ['100500' => ['some' => 'data']];
$attributes = ['attributeOne' => ['code' => 'one'], 'attributeTwo' => ['code' => 'two']];
@@ -85,7 +95,7 @@ public function testBuild()
);
$collectionMock = $helper->getCollectionMock(
- \Magento\Catalog\Model\ResourceModel\Product\Link\Collection::class,
+ Collection::class,
[$productLinkMock]
);
$this->_productMock->expects(
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/RelatedTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/RelatedTest.php
index d7762151d81d5..ceb4c34efd688 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/RelatedTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/RelatedTest.php
@@ -3,9 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\CopyConstructor;
-class RelatedTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\CopyConstructor\Related;
+use Magento\Catalog\Model\Product\Link;
+use Magento\Catalog\Model\ResourceModel\Product\Link\Collection;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class RelatedTest extends TestCase
{
/**
* @var \\Magento\Catalog\Model\Product\CopyConstructor\Related
@@ -13,38 +23,38 @@ class RelatedTest extends \PHPUnit\Framework\TestCase
protected $_model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_productMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_duplicateMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_linkMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_linkCollectionMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_model = new \Magento\Catalog\Model\Product\CopyConstructor\Related();
+ $this->_model = new Related();
- $this->_productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $this->_productMock = $this->createMock(Product::class);
$this->_duplicateMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
['setRelatedLinkData', '__wakeup']
);
$this->_linkMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Link::class,
+ Link::class,
['__wakeup', 'getAttributes', 'getRelatedLinkCollection', 'useRelatedLinks']
);
@@ -59,7 +69,7 @@ protected function setUp()
public function testBuild()
{
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $helper = new ObjectManager($this);
$expectedData = ['100500' => ['some' => 'data']];
$attributes = ['attributeOne' => ['code' => 'one'], 'attributeTwo' => ['code' => 'two']];
@@ -85,7 +95,7 @@ public function testBuild()
);
$collectionMock = $helper->getCollectionMock(
- \Magento\Catalog\Model\ResourceModel\Product\Link\Collection::class,
+ Collection::class,
[$productLinkMock]
);
$this->_productMock->expects(
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/UpSellTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/UpSellTest.php
index 4ea2300a2d8d7..4885796d956df 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/UpSellTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructor/UpSellTest.php
@@ -3,48 +3,58 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\CopyConstructor;
-class UpSellTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\CopyConstructor\UpSell;
+use Magento\Catalog\Model\Product\Link;
+use Magento\Catalog\Model\ResourceModel\Product\Link\Collection;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class UpSellTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\CopyConstructor\UpSell
+ * @var UpSell
*/
protected $_model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_productMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_duplicateMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_linkMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_linkCollectionMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_model = new \Magento\Catalog\Model\Product\CopyConstructor\UpSell();
+ $this->_model = new UpSell();
- $this->_productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $this->_productMock = $this->createMock(Product::class);
$this->_duplicateMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
['setUpSellLinkData', '__wakeup']
);
$this->_linkMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Link::class,
+ Link::class,
['__wakeup', 'getAttributes', 'getUpSellLinkCollection', 'useUpSellLinks']
);
@@ -59,7 +69,7 @@ protected function setUp()
public function testBuild()
{
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $helper = new ObjectManager($this);
$expectedData = ['100500' => ['some' => 'data']];
$attributes = ['attributeOne' => ['code' => 'one'], 'attributeTwo' => ['code' => 'two']];
@@ -85,7 +95,7 @@ public function testBuild()
);
$collectionMock = $helper->getCollectionMock(
- \Magento\Catalog\Model\ResourceModel\Product\Link\Collection::class,
+ Collection::class,
[$productLinkMock]
);
$this->_productMock->expects(
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php
index 1c0ea6ee1ed39..499749a050613 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php
@@ -3,11 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product;
-use \Magento\Catalog\Model\Product\CopyConstructorFactory;
+use Magento\Catalog\Model\Product\CopyConstructor\Composite;
+use Magento\Catalog\Model\Product\CopyConstructorFactory;
+use Magento\Framework\DataObject;
+use Magento\Framework\ObjectManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CopyConstructorFactoryTest extends \PHPUnit\Framework\TestCase
+class CopyConstructorFactoryTest extends TestCase
{
/**
* @var CopyConstructorFactory
@@ -15,13 +22,13 @@ class CopyConstructorFactoryTest extends \PHPUnit\Framework\TestCase
protected $_model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_objectManagerMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
+ $this->_objectManagerMock = $this->createMock(ObjectManagerInterface::class);
$this->_model = new CopyConstructorFactory($this->_objectManagerMock);
}
@@ -32,7 +39,7 @@ public function testCreateWithInvalidType()
'Magento\Framework\DataObject does not implement \Magento\Catalog\Model\Product\CopyConstructorInterface'
);
$this->_objectManagerMock->expects($this->never())->method('create');
- $this->_model->create(\Magento\Framework\DataObject::class);
+ $this->_model->create(DataObject::class);
}
public function testCreateWithValidType()
@@ -42,13 +49,13 @@ public function testCreateWithValidType()
)->method(
'create'
)->with(
- \Magento\Catalog\Model\Product\CopyConstructor\Composite::class
+ Composite::class
)->will(
$this->returnValue('object')
);
$this->assertEquals(
'object',
- $this->_model->create(\Magento\Catalog\Model\Product\CopyConstructor\Composite::class)
+ $this->_model->create(Composite::class)
);
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Filter/DateTimeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Filter/DateTimeTest.php
index aefa0b1cf106d..629500ca91cdc 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Filter/DateTimeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Filter/DateTimeTest.php
@@ -7,15 +7,13 @@
namespace Magento\Catalog\Test\Unit\Model\Product\Filter;
+use Magento\Catalog\Model\Product\Filter\DateTime;
use Magento\Framework\Locale\Resolver;
use Magento\Framework\Locale\ResolverInterface;
use Magento\Framework\Stdlib\DateTime\Timezone;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\TestCase;
-/**
- * Test datetime filter
- */
class DateTimeTest extends TestCase
{
/**
@@ -23,14 +21,14 @@ class DateTimeTest extends TestCase
*/
private $locale;
/**
- * @var \Magento\Catalog\Model\Product\Filter\DateTime
+ * @var DateTime
*/
private $model;
/**
* @inheritDoc
*/
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$objectManager = new ObjectManager($this);
@@ -52,7 +50,7 @@ function () {
['localeDate' => $timezone]
);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Filter\DateTime::class,
+ DateTime::class,
[
'stdlibDateTimeFilter' => $stdlibDateTimeFilter
]
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php
index 30994eda87273..f77635c57d05f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php
@@ -4,53 +4,65 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Gallery;
+use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
+use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Gallery\GalleryManagement;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Framework\Api\AttributeValue;
+use Magento\Framework\Api\Data\ImageContentInterface;
+use Magento\Framework\Api\ImageContentValidatorInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* Tests for \Magento\Catalog\Model\Product\Gallery\GalleryManagement.
*/
-class GalleryManagementTest extends \PHPUnit\Framework\TestCase
+class GalleryManagementTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Gallery\GalleryManagement
+ * @var GalleryManagement
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productRepositoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $contentValidatorMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $mediaGalleryEntryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Api\AttributeValue
+ * @var MockObject|AttributeValue
*/
protected $attributeValueMock;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->productRepositoryMock = $this->createMock(\Magento\Catalog\Api\ProductRepositoryInterface::class);
- $this->contentValidatorMock = $this->createMock(\Magento\Framework\Api\ImageContentValidatorInterface::class);
+ $this->productRepositoryMock = $this->createMock(ProductRepositoryInterface::class);
+ $this->contentValidatorMock = $this->createMock(ImageContentValidatorInterface::class);
$this->productMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
[
'setStoreId',
'getData',
@@ -63,23 +75,21 @@ protected function setUp()
]
);
$this->mediaGalleryEntryMock =
- $this->createMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class);
- $this->model = new \Magento\Catalog\Model\Product\Gallery\GalleryManagement(
+ $this->createMock(ProductAttributeMediaGalleryEntryInterface::class);
+ $this->model = new GalleryManagement(
$this->productRepositoryMock,
$this->contentValidatorMock
);
- $this->attributeValueMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeValue::class)
+ $this->attributeValueMock = $this->getMockBuilder(AttributeValue::class)
->disableOriginalConstructor()
->getMock();
}
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage The image content is invalid. Verify the content and try again.
- */
public function testCreateWithInvalidImageException()
{
- $entryContentMock = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class)
+ $this->expectException('Magento\Framework\Exception\InputException');
+ $this->expectExceptionMessage('The image content is invalid. Verify the content and try again.');
+ $entryContentMock = $this->getMockBuilder(ImageContentInterface::class)
->disableOriginalConstructor()
->getMock();
$this->mediaGalleryEntryMock->expects($this->any())->method('getContent')->willReturn($entryContentMock);
@@ -90,17 +100,15 @@ public function testCreateWithInvalidImageException()
$this->model->create("sku", $this->mediaGalleryEntryMock);
}
- /**
- * @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage The product can't be saved.
- */
public function testCreateWithCannotSaveException()
{
+ $this->expectException('Magento\Framework\Exception\StateException');
+ $this->expectExceptionMessage('The product can\'t be saved.');
$productSku = 'mediaProduct';
- $entryContentMock = $this->getMockBuilder(\Magento\Framework\Api\Data\ImageContentInterface::class)
+ $entryContentMock = $this->getMockBuilder(ImageContentInterface::class)
->disableOriginalConstructor()
->getMock();
- $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $attributeMock = $this->getMockBuilder(AbstractAttribute::class)
->disableOriginalConstructor()
->getMock();
$this->mediaGalleryEntryMock->expects($this->any())->method('getContent')->willReturn($entryContentMock);
@@ -125,7 +133,7 @@ public function testCreate()
{
$productSku = 'mediaProduct';
$entryContentMock = $this->createMock(
- \Magento\Framework\Api\Data\ImageContentInterface::class
+ ImageContentInterface::class
);
$this->mediaGalleryEntryMock->expects($this->any())->method('getContent')->willReturn($entryContentMock);
@@ -143,7 +151,7 @@ public function testCreate()
$this->mediaGalleryEntryMock->expects($this->any())->method('getTypes')->willReturn(['small_image']);
- $newEntryMock = $this->createMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class);
+ $newEntryMock = $this->createMock(ProductAttributeMediaGalleryEntryInterface::class);
$newEntryMock->expects($this->exactly(2))->method('getId')->willReturn(42);
$this->productMock->expects($this->at(2))->method('getMediaGalleryEntries')
->willReturn([$newEntryMock]);
@@ -153,19 +161,17 @@ public function testCreate()
$this->assertEquals(42, $this->model->create($productSku, $this->mediaGalleryEntryMock));
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage No image with the provided ID was found. Verify the ID and try again.
- */
public function testUpdateWithNonExistingImage()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage('No image with the provided ID was found. Verify the ID and try again.');
$productSku = 'testProduct';
- $entryMock = $this->createMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class);
+ $entryMock = $this->createMock(ProductAttributeMediaGalleryEntryInterface::class);
$entryId = 42;
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
->willReturn($this->productMock);
$existingEntryMock = $this->createMock(
- \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
+ ProductAttributeMediaGalleryEntryInterface::class
);
$existingEntryMock->expects($this->once())->method('getId')->willReturn(43);
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
@@ -176,19 +182,17 @@ public function testUpdateWithNonExistingImage()
$this->model->update($productSku, $entryMock);
}
- /**
- * @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage The product can't be saved.
- */
public function testUpdateWithCannotSaveException()
{
+ $this->expectException('Magento\Framework\Exception\StateException');
+ $this->expectExceptionMessage('The product can\'t be saved.');
$productSku = 'testProduct';
- $entryMock = $this->createMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class);
+ $entryMock = $this->createMock(ProductAttributeMediaGalleryEntryInterface::class);
$entryId = 42;
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
->willReturn($this->productMock);
$existingEntryMock = $this->createMock(
- \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
+ ProductAttributeMediaGalleryEntryInterface::class
);
$existingEntryMock->expects($this->once())->method('getId')->willReturn($entryId);
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
@@ -209,16 +213,16 @@ public function testUpdateWithCannotSaveException()
public function testUpdate()
{
$productSku = 'testProduct';
- $entryMock = $this->createMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class);
+ $entryMock = $this->createMock(ProductAttributeMediaGalleryEntryInterface::class);
$entryId = 42;
$entrySecondId = 43;
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
->willReturn($this->productMock);
$existingEntryMock = $this->createMock(
- \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
+ ProductAttributeMediaGalleryEntryInterface::class
);
$existingSecondEntryMock = $this->createMock(
- \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
+ ProductAttributeMediaGalleryEntryInterface::class
);
$existingEntryMock->expects($this->once())->method('getId')->willReturn($entryId);
@@ -241,18 +245,16 @@ public function testUpdate()
$this->assertTrue($this->model->update($productSku, $entryMock));
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage No image with the provided ID was found. Verify the ID and try again.
- */
public function testRemoveWithNonExistingImage()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage('No image with the provided ID was found. Verify the ID and try again.');
$productSku = 'testProduct';
$entryId = 42;
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
->willReturn($this->productMock);
$existingEntryMock = $this->createMock(
- \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
+ ProductAttributeMediaGalleryEntryInterface::class
);
$existingEntryMock->expects($this->once())->method('getId')->willReturn(43);
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
@@ -267,7 +269,7 @@ public function testRemove()
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
->willReturn($this->productMock);
$existingEntryMock = $this->createMock(
- \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
+ ProductAttributeMediaGalleryEntryInterface::class
);
$existingEntryMock->expects($this->once())->method('getId')->willReturn(42);
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
@@ -278,12 +280,10 @@ public function testRemove()
$this->assertTrue($this->model->remove($productSku, $entryId));
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage The product doesn't exist. Verify and try again.
- */
public function testGetWithNonExistingProduct()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage('The product doesn\'t exist. Verify and try again.');
$productSku = 'testProduct';
$imageId = 42;
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
@@ -291,18 +291,16 @@ public function testGetWithNonExistingProduct()
$this->model->get($productSku, $imageId);
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage The image doesn't exist. Verify and try again.
- */
public function testGetWithNonExistingImage()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage('The image doesn\'t exist. Verify and try again.');
$productSku = 'testProduct';
$imageId = 43;
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
->willReturn($this->productMock);
$existingEntryMock = $this->createMock(
- \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
+ ProductAttributeMediaGalleryEntryInterface::class
);
$existingEntryMock->expects($this->once())->method('getId')->willReturn(44);
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
@@ -317,7 +315,7 @@ public function testGet()
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
->willReturn($this->productMock);
$existingEntryMock = $this->createMock(
- \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
+ ProductAttributeMediaGalleryEntryInterface::class
);
$existingEntryMock->expects($this->once())->method('getId')->willReturn(42);
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
@@ -330,7 +328,7 @@ public function testGetList()
$productSku = 'testProductSku';
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
->willReturn($this->productMock);
- $entryMock = $this->createMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class);
+ $entryMock = $this->createMock(ProductAttributeMediaGalleryEntryInterface::class);
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
->willReturn([$entryMock]);
$this->assertEquals([$entryMock], $this->model->getList($productSku));
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/MimeTypeExtensionMapTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/MimeTypeExtensionMapTest.php
index 2e96f96aa0d33..e9e1fb099955f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/MimeTypeExtensionMapTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/MimeTypeExtensionMapTest.php
@@ -4,19 +4,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Gallery;
-class MimeTypeExtensionMapTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product\Gallery\MimeTypeExtensionMap;
+use PHPUnit\Framework\TestCase;
+
+class MimeTypeExtensionMapTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Gallery\MimeTypeExtensionMap
+ * @var MimeTypeExtensionMap
*/
protected $model;
- protected function setUp()
+ protected function setUp(): void
{
- $this->model = new \Magento\Catalog\Model\Product\Gallery\MimeTypeExtensionMap();
+ $this->model = new MimeTypeExtensionMap();
}
public function testGetMimeTypeExtension()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php
index 15f003282dc04..931eb6690789a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php
@@ -3,80 +3,98 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Gallery;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Attribute\Repository;
+use Magento\Catalog\Model\Product\Gallery\Processor;
+use Magento\Catalog\Model\Product\Media\Config;
+use Magento\Catalog\Model\ResourceModel\Product\Gallery;
+use Magento\Eav\Model\Entity\Attribute;
+use Magento\Framework\DataObject;
+use Magento\Framework\Filesystem;
+use Magento\Framework\Filesystem\Directory\Write;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\MediaStorage\Helper\File\Storage\Database;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* Unit test for catalog product Media Gallery attribute processor.
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ProcessorTest extends \PHPUnit\Framework\TestCase
+class ProcessorTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Gallery\Processor
+ * @var Processor
*/
protected $model;
/**
- * @var \Magento\Catalog\Model\Product\Attribute\Repository|\PHPUnit_Framework_MockObject_MockObject
+ * @var Repository|MockObject
*/
protected $attributeRepository;
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectHelper;
/**
- * @var \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject
+ * @var DataObject|MockObject
*/
protected $dataObject;
/**
- * @var \Magento\Catalog\Model\Product\Media\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
protected $mediaConfig;
/**
- * @var \Magento\Framework\Filesystem\Directory\Write|\PHPUnit_Framework_MockObject_MockObject
+ * @var Write|MockObject
*/
protected $mediaDirectory;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectHelper = new ObjectManager($this);
$this->attributeRepository = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Attribute\Repository::class,
+ Repository::class,
['get']
);
- $fileStorageDb = $this->createMock(\Magento\MediaStorage\Helper\File\Storage\Database::class);
+ $fileStorageDb = $this->createMock(Database::class);
- $this->mediaConfig = $this->createMock(\Magento\Catalog\Model\Product\Media\Config::class);
+ $this->mediaConfig = $this->createMock(Config::class);
- $this->mediaDirectory = $this->createMock(\Magento\Framework\Filesystem\Directory\Write::class);
+ $this->mediaDirectory = $this->createMock(Write::class);
- $filesystem = $this->createMock(\Magento\Framework\Filesystem::class);
+ $filesystem = $this->createMock(Filesystem::class);
$filesystem->expects($this->once())
->method('getDirectoryWrite')
->willReturn($this->mediaDirectory);
$resourceModel = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\Gallery::class,
+ Gallery::class,
['getMainTable']
);
$resourceModel->expects($this->any())
->method('getMainTable')
->willReturn(
- \Magento\Catalog\Model\ResourceModel\Product\Gallery::GALLERY_TABLE
+ Gallery::GALLERY_TABLE
);
$this->dataObject = $this->createPartialMock(
- \Magento\Framework\DataObject::class,
+ DataObject::class,
['getIsDuplicate', 'isLockedAttribute', 'getMediaAttributes']
);
$this->model = $this->objectHelper->getObject(
- \Magento\Catalog\Model\Product\Gallery\Processor::class,
+ Processor::class,
[
'attributeRepository' => $this->attributeRepository,
'fileStorageDb' => $fileStorageDb,
@@ -93,7 +111,7 @@ public function testGetAffectedFields()
$attributeId = 345345;
$attribute = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute::class,
+ Attribute::class,
['getBackendTable', 'isStatic', 'getAttributeId', 'getName', '__wakeup']
);
$attribute->expects($this->any())->method('getName')->will($this->returnValue('image'));
@@ -106,13 +124,13 @@ public function testGetAffectedFields()
->with('media_gallery')
->willReturn($attribute);
- $object = new \Magento\Framework\DataObject();
+ $object = new DataObject();
$object->setImage(['images' => [['value_id' => $valueId]]]);
$object->setId(555);
$this->assertEquals(
[
- \Magento\Catalog\Model\ResourceModel\Product\Gallery::GALLERY_TABLE => [
+ Gallery::GALLERY_TABLE => [
['value_id' => $valueId, 'attribute_id' => 345345, 'entity_id' => $object->getId()],
],
],
@@ -128,10 +146,10 @@ public function testValidate($value)
{
$attributeCode = 'attr_code';
$attribute = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute::class,
+ Attribute::class,
['getAttributeCode', 'getIsRequired', 'isValueEmpty', 'getIsUnique', 'getEntity', '__wakeup']
);
- $attributeEntity = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\AbstractResource::class)
+ $attributeEntity = $this->getMockBuilder(AbstractResource::class)
->setMethods(['checkAttributeUniqueValue'])
->getMockForAbstractClass();
@@ -170,7 +188,7 @@ public function validateDataProvider()
*/
public function testClearMediaAttribute($setDataExpectsCalls, $setDataArgument, $mediaAttribute)
{
- $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Image/CacheTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Image/CacheTest.php
index 3ff3601da8ccc..4792c38547ed2 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Image/CacheTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Image/CacheTest.php
@@ -3,74 +3,86 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Image;
+use Magento\Catalog\Helper\Image;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Image\Cache;
use Magento\Framework\App\Area;
+use Magento\Framework\Config\View;
+use Magento\Framework\DataObject;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\ConfigInterface;
+use Magento\Theme\Model\ResourceModel\Theme\Collection;
+use Magento\Theme\Model\Theme;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CacheTest extends \PHPUnit\Framework\TestCase
+class CacheTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManager;
/**
- * @var \Magento\Catalog\Model\Product\Image\Cache
+ * @var Cache
*/
protected $model;
/**
- * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
protected $product;
/**
- * @var \Magento\Framework\View\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConfigInterface|MockObject
*/
protected $viewConfig;
/**
- * @var \Magento\Framework\Config\View|\PHPUnit_Framework_MockObject_MockObject
+ * @var View|MockObject
*/
protected $config;
/**
- * @var \Magento\Theme\Model\ResourceModel\Theme\Collection|\PHPUnit_Framework_MockObject_MockObject
+ * @var Collection|MockObject
*/
protected $themeCollection;
/**
- * @var \Magento\Catalog\Helper\Image|\PHPUnit_Framework_MockObject_MockObject
+ * @var Image|MockObject
*/
protected $imageHelper;
/**
- * @var \Magento\Framework\Data\Collection|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\Data\Collection|MockObject
*/
protected $mediaGalleryCollection;
- protected function setUp()
+ protected function setUp(): void
{
- $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $this->product = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
- $this->viewConfig = $this->getMockBuilder(\Magento\Framework\View\ConfigInterface::class)
+ $this->viewConfig = $this->getMockBuilder(ConfigInterface::class)
->getMockForAbstractClass();
- $this->config = $this->getMockBuilder(\Magento\Framework\Config\View::class)
+ $this->config = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
->getMock();
- $this->themeCollection = $this->getMockBuilder(\Magento\Theme\Model\ResourceModel\Theme\Collection::class)
+ $this->themeCollection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
- $this->imageHelper = $this->getMockBuilder(\Magento\Catalog\Helper\Image::class)
+ $this->imageHelper = $this->getMockBuilder(Image::class)
->disableOriginalConstructor()
->getMock();
@@ -80,7 +92,7 @@ protected function setUp()
$this->objectManager = new ObjectManager($this);
$this->model = $this->objectManager->getObject(
- \Magento\Catalog\Model\Product\Image\Cache::class,
+ Cache::class,
[
'viewConfig' => $this->viewConfig,
'themeCollection' => $this->themeCollection,
@@ -96,7 +108,7 @@ public function testGenerate()
{
$imageFile = 'image.jpg';
$imageItem = $this->objectManager->getObject(
- \Magento\Framework\DataObject::class,
+ DataObject::class,
[
'data' => ['file' => $imageFile]
]
@@ -115,7 +127,7 @@ public function testGenerate()
->with('Magento_Catalog')
->willReturn($data);
- $themeMock = $this->getMockBuilder(\Magento\Theme\Model\Theme::class)
+ $themeMock = $this->getMockBuilder(Theme::class)
->disableOriginalConstructor()
->getMock();
$themeMock->expects($this->exactly(3))
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Image/ParamsBuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Image/ParamsBuilderTest.php
index 68239c8fa8aed..edcbeb8d88f2c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Image/ParamsBuilderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Image/ParamsBuilderTest.php
@@ -44,7 +44,7 @@ class ParamsBuilderTest extends TestCase
/**
* @inheritDoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
$this->scopeConfig = $this->createMock(ScopeConfigInterface::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php
index 430db70701356..d4a2ba547086f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ImageTest.php
@@ -3,125 +3,143 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product;
+use Magento\Catalog\Model\Product\Image;
use Magento\Catalog\Model\Product\Image\ParamsBuilder;
-use Magento\Catalog\Model\View\Asset\Image\ContextFactory;
+use Magento\Catalog\Model\Product\Media\Config;
use Magento\Catalog\Model\View\Asset\ImageFactory;
use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
+use Magento\Framework\App\CacheInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\Filesystem;
+use Magento\Framework\Filesystem\Directory\Write;
+use Magento\Framework\Filesystem\Directory\WriteInterface;
+use Magento\Framework\Image\Factory;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Serialize\SerializerInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Asset\LocalInterface;
+use Magento\MediaStorage\Helper\File\Storage\Database;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManager;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Store\Model\Website;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyFields)
*/
-class ImageTest extends \PHPUnit\Framework\TestCase
+class ImageTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Image
+ * @var Image
*/
private $image;
/**
- * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $context;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManager;
/**
- * @var \Magento\Catalog\Model\Product\Media\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $config;
/**
- * @var \Magento\MediaStorage\Helper\File\Storage\Database|\PHPUnit_Framework_MockObject_MockObject
+ * @var Database|MockObject
*/
private $coreFileHelper;
/**
- * @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject
+ * @var Filesystem|MockObject
*/
private $filesystem;
/**
- * @var \Magento\Framework\Image\Factory|\PHPUnit_Framework_MockObject_MockObject
+ * @var Factory|MockObject
*/
private $factory;
/**
- * @var \Magento\Framework\Filesystem\Directory\WriteInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriteInterface|MockObject
*/
private $mediaDirectory;
/**
- * @var \Magento\Framework\View\Asset\LocalInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LocalInterface|MockObject
*/
private $imageAsset;
/**
- * @var ImageFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ImageFactory|MockObject
*/
private $viewAssetImageFactory;
/**
- * @var PlaceholderFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var PlaceholderFactory|MockObject
*/
private $viewAssetPlaceholderFactory;
/**
- * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var SerializerInterface|MockObject
*/
private $serializer;
/**
- * @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CacheInterface|MockObject
*/
private $cacheManager;
/**
- * @var ParamsBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var ParamsBuilder|MockObject
*/
private $paramsBuilder;
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->context = $this->createMock(\Magento\Framework\Model\Context::class);
- $this->cacheManager = $this->getMockBuilder(\Magento\Framework\App\CacheInterface::class)
+ $objectManager = new ObjectManager($this);
+ $this->context = $this->createMock(Context::class);
+ $this->cacheManager = $this->getMockBuilder(CacheInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->context->expects($this->any())->method('getCacheManager')->will($this->returnValue($this->cacheManager));
- $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManager::class)
+ $this->storeManager = $this->getMockBuilder(StoreManager::class)
->disableOriginalConstructor()
->setMethods(['getStore', 'getWebsite'])->getMock();
- $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()
+ $store = $this->getMockBuilder(Store::class)->disableOriginalConstructor()
->setMethods(['getId', '__sleep', '__wakeup', 'getBaseUrl'])->getMock();
$store->expects($this->any())->method('getId')->will($this->returnValue(1));
$store->expects($this->any())->method('getBaseUrl')->will($this->returnValue('http://magento.com/media/'));
$this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
- $this->config = $this->getMockBuilder(\Magento\Catalog\Model\Product\Media\Config::class)
+ $this->config = $this->getMockBuilder(Config::class)
->setMethods(['getBaseMediaPath'])->disableOriginalConstructor()->getMock();
$this->config->expects($this->any())->method('getBaseMediaPath')->will($this->returnValue('catalog/product'));
- $this->coreFileHelper = $this->getMockBuilder(\Magento\MediaStorage\Helper\File\Storage\Database::class)
+ $this->coreFileHelper = $this->getMockBuilder(Database::class)
->setMethods(['saveFile', 'deleteFolder'])->disableOriginalConstructor()->getMock();
- $this->mediaDirectory = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\Write::class)
+ $this->mediaDirectory = $this->getMockBuilder(Write::class)
->disableOriginalConstructor()
->setMethods(['create', 'isFile', 'isExist', 'getAbsolutePath'])
->getMock();
- $this->filesystem = $this->createMock(\Magento\Framework\Filesystem::class);
+ $this->filesystem = $this->createMock(Filesystem::class);
$this->filesystem->expects($this->once())->method('getDirectoryWrite')
->with(DirectoryList::MEDIA)
->will($this->returnValue($this->mediaDirectory));
- $this->factory = $this->createMock(\Magento\Framework\Image\Factory::class);
+ $this->factory = $this->createMock(Factory::class);
$this->viewAssetImageFactory = $this->getMockBuilder(ImageFactory::class)
->disableOriginalConstructor()
@@ -132,7 +150,7 @@ protected function setUp()
->setMethods(['create'])
->getMock();
$this->serializer = $this->getMockBuilder(
- \Magento\Framework\Serialize\SerializerInterface::class
+ SerializerInterface::class
)->getMockForAbstractClass();
$this->serializer->expects($this->any())
->method('serialize')
@@ -153,7 +171,7 @@ function ($value) {
->getMock();
$this->image = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Image::class,
+ Image::class,
[
'context' => $this->context,
'storeManager' => $this->storeManager,
@@ -168,7 +186,7 @@ function ($value) {
]
);
- $this->imageAsset = $this->getMockBuilder(\Magento\Framework\View\Asset\LocalInterface::class)
+ $this->imageAsset = $this->getMockBuilder(LocalInterface::class)
->getMockForAbstractClass();
$objectManager->setBackwardCompatibleProperty(
$this->image,
@@ -310,7 +328,7 @@ public function testSetAngle()
public function testSetWatermark()
{
- $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()
+ $website = $this->getMockBuilder(Website::class)->disableOriginalConstructor()
->setMethods(['getId', '__sleep', '__wakeup'])->getMock();
$website->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->storeManager->expects($this->any())->method('getWebsite')->will($this->returnValue($website));
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Initialization/Helper/ProductLinksTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Initialization/Helper/ProductLinksTest.php
index ff0e82abe1d47..22bae1deea9ad 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Initialization/Helper/ProductLinksTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Initialization/Helper/ProductLinksTest.php
@@ -3,15 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Initialization\Helper;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class ProductLinksTest extends \PHPUnit\Framework\TestCase
+class ProductLinksTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks
+ * @var ProductLinks
*/
private $model;
@@ -19,15 +23,15 @@ public function testInitializeLinks()
{
$links = ['related' => ['data'], 'upsell' => ['data'], 'crosssell' => ['data']];
$this->assertInstanceOf(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
$this->model->initializeLinks($this->getMockedProduct(), $links)
);
}
- protected function setUp()
+ protected function setUp(): void
{
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->model = $helper->getObject(\Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks::class);
+ $helper = new ObjectManager($this);
+ $this->model = $helper->getObject(ProductLinks::class);
}
/**
@@ -35,7 +39,7 @@ protected function setUp()
*/
private function getMockedProduct()
{
- $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $mockBuilder = $this->getMockBuilder(Product::class)
->setMethods(
[
'getRelatedReadonly',
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Link/ConverterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Link/ConverterTest.php
index c0d7c63ee7cfa..17a74de937459 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Link/ConverterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Link/ConverterTest.php
@@ -3,18 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Link;
+use Magento\Catalog\Api\Data\ProductLinkInterface;
+use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Link\Converter;
+use Magento\Catalog\Model\Product\Type\AbstractType;
+use Magento\Framework\Api\ExtensionAttributesInterface;
+use PHPUnit\Framework\TestCase;
-class ConverterTest extends \PHPUnit\Framework\TestCase
+class ConverterTest extends TestCase
{
/**
* @var Converter
*/
protected $converter;
- protected function setUp()
+ protected function setUp(): void
{
$this->converter = new Converter();
}
@@ -24,12 +31,12 @@ public function testConvertLinksToGroupedArray()
$linkedProductSku = 'linkedProductSample';
$linkedProductId = '2016';
$linkType = 'associated';
- $linkMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductLinkInterface::class)
+ $linkMock = $this->getMockBuilder(ProductLinkInterface::class)
->disableOriginalConstructor()
->setMethods(['getData', 'getLinkType', 'getLinkedProductSku', 'getExtensionAttributes'])
->getMockForAbstractClass();
$basicData = [$linkMock];
- $linkedProductMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $linkedProductMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
$associatedProducts = [$linkedProductSku => $linkedProductMock];
@@ -37,12 +44,12 @@ public function testConvertLinksToGroupedArray()
$infoFinal = [100, 300, 500, 'id' => $linkedProductId, 'qty' => 33];
$linksAsArray = [$linkType => [$infoFinal]];
- $typeMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\AbstractType::class)
+ $typeMock = $this->getMockBuilder(AbstractType::class)
->setMethods(['getAssociatedProducts'])
->disableOriginalConstructor()
->getMockForAbstractClass();
- $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
$productMock->expects($this->once())
@@ -70,7 +77,7 @@ public function testConvertLinksToGroupedArray()
$linkedProductMock->expects($this->once())
->method('getId')
->willReturn($linkedProductId);
- $attributeMock = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttributesInterface::class)
+ $attributeMock = $this->getMockBuilder(ExtensionAttributesInterface::class)
->setMethods(['__toArray'])
->getMockForAbstractClass();
$linkMock->expects($this->once())
@@ -79,7 +86,7 @@ public function testConvertLinksToGroupedArray()
$attributeMock->expects($this->once())
->method('__toArray')
->willReturn(['qty' => 33]);
-
+
$this->assertEquals($linksAsArray, $this->converter->convertLinksToGroupedArray($productMock));
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Link/ResolverTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Link/ResolverTest.php
index dd960f3e24958..e20dfb640be1e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Link/ResolverTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Link/ResolverTest.php
@@ -3,14 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Link;
use Magento\Catalog\Model\Product\Link\Resolver;
+use Magento\Framework\App\RequestInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ResolverTest extends \PHPUnit\Framework\TestCase
+class ResolverTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $requestMock;
@@ -19,9 +24,9 @@ class ResolverTest extends \PHPUnit\Framework\TestCase
*/
protected $resolver;
- protected function setUp()
+ protected function setUp(): void
{
- $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
+ $this->requestMock = $this->getMockBuilder(RequestInterface::class)
->getMockForAbstractClass();
$this->resolver = new Resolver($this->requestMock);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTest.php
index a8e1e7602afd6..3687fd83f59b8 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTest.php
@@ -3,11 +3,22 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Catalog\Test\Unit\Model\Product;
+declare(strict_types=1);
-use \Magento\Catalog\Model\Product\Link;
+namespace Magento\Catalog\Test\Unit\Model\Product;
-class LinkTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Link;
+use Magento\Catalog\Model\Product\Link\SaveHandler;
+use Magento\Catalog\Model\ResourceModel\Product\Link\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\Link\CollectionFactory;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class LinkTest extends TestCase
{
/**
* @var Link
@@ -15,30 +26,30 @@ class LinkTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var \Magento\Framework\Model\ResourceModel\AbstractResource|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractResource|MockObject
*/
protected $resource;
/**
- * @var \Magento\Catalog\Model\Product\Link\SaveHandler|\PHPUnit_Framework_MockObject_MockObject
+ * @var SaveHandler|MockObject
*/
protected $saveProductLinksMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productCollection;
- protected function setUp()
+ protected function setUp(): void
{
$linkCollection = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Product\Link\Collection::class
+ Collection::class
)->disableOriginalConstructor()->setMethods(
['setLinkModel']
)->getMock();
$linkCollection->expects($this->any())->method('setLinkModel')->will($this->returnSelf());
$linkCollectionFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Product\Link\CollectionFactory::class
+ CollectionFactory::class
)->disableOriginalConstructor()->setMethods(
['create']
)->getMock();
@@ -61,7 +72,7 @@ protected function setUp()
->will($this->returnValue($this->productCollection));
$this->resource = $this->createPartialMock(
- \Magento\Framework\Model\ResourceModel\AbstractResource::class,
+ AbstractResource::class,
[
'saveProductLinks',
'getAttributeTypeTable',
@@ -73,13 +84,13 @@ protected function setUp()
]
);
- $this->saveProductLinksMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Link\SaveHandler::class)
+ $this->saveProductLinksMock = $this->getMockBuilder(SaveHandler::class)
->disableOriginalConstructor()
->getMock();
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Link::class,
+ Link::class,
[
'linkCollectionFactory' => $linkCollectionFactory,
'productCollectionFactory' => $productCollectionFactory,
@@ -136,7 +147,7 @@ public function testGetProductCollection()
public function testGetLinkCollection()
{
$this->assertInstanceOf(
- \Magento\Catalog\Model\ResourceModel\Product\Link\Collection::class,
+ Collection::class,
$this->model->getLinkCollection()
);
}
@@ -155,13 +166,13 @@ public function testGetAttributes()
public function testSaveProductRelations()
{
- $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $product = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
$this->saveProductLinksMock
->expects($this->once())
->method('execute')
- ->with(\Magento\Catalog\Api\Data\ProductInterface::class, $product);
+ ->with(ProductInterface::class, $product);
$this->model->saveProductRelations($product);
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTypeProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTypeProviderTest.php
index e242b77f1a5fc..7f5d281169f7d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTypeProviderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTypeProviderTest.php
@@ -3,28 +3,40 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product;
-class LinkTypeProviderTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Api\Data\ProductLinkAttributeInterface;
+use Magento\Catalog\Api\Data\ProductLinkAttributeInterfaceFactory;
+use Magento\Catalog\Api\Data\ProductLinkTypeInterface;
+use Magento\Catalog\Api\Data\ProductLinkTypeInterfaceFactory;
+use Magento\Catalog\Model\Product\Link;
+use Magento\Catalog\Model\Product\LinkFactory;
+use Magento\Catalog\Model\Product\LinkTypeProvider;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class LinkTypeProviderTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\LinkTypeProvider
+ * @var LinkTypeProvider
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $linkTypeFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $linkAttributeFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $linkFactoryMock;
@@ -33,18 +45,18 @@ class LinkTypeProviderTest extends \PHPUnit\Framework\TestCase
*/
protected $linkTypes;
- protected function setUp()
+ protected function setUp(): void
{
$this->linkTypeFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Api\Data\ProductLinkTypeInterfaceFactory::class,
+ ProductLinkTypeInterfaceFactory::class,
['create']
);
$this->linkAttributeFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Api\Data\ProductLinkAttributeInterfaceFactory::class,
+ ProductLinkAttributeInterfaceFactory::class,
['create']
);
$this->linkFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\LinkFactory::class,
+ LinkFactory::class,
['create']
);
$this->linkTypes = [
@@ -52,9 +64,9 @@ protected function setUp()
'test_product_link_2' => 'test_code_2',
'test_product_link_3' => 'test_code_3',
];
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Product\LinkTypeProvider::class,
+ LinkTypeProvider::class,
[
'linkTypeFactory' => $this->linkTypeFactoryMock,
'linkAttributeFactory' => $this->linkAttributeFactoryMock,
@@ -73,7 +85,7 @@ public function testGetItems()
$linkTypeMocks = [];
foreach ($this->linkTypes as $type => $typeCode) {
$value = ['name' => $type, 'code' => $typeCode];
- $linkTypeMock = $this->createMock(\Magento\Catalog\Api\Data\ProductLinkTypeInterface::class);
+ $linkTypeMock = $this->createMock(ProductLinkTypeInterface::class);
$linkTypeMock->expects($this->once())
->method('setName')
->with($type)
@@ -99,7 +111,7 @@ public function testGetItemAttributes($type, $typeId)
$attributes = [
['code' => 'test_code_1', 'type' => 'test_type_1'],
];
- $linkAttributeMock = $this->createMock(\Magento\Catalog\Api\Data\ProductLinkAttributeInterface::class);
+ $linkAttributeMock = $this->createMock(ProductLinkAttributeInterface::class);
$linkAttributeMock->expects($this->once())
->method('setCode')
->with($attributes[0]['code'])
@@ -111,7 +123,7 @@ public function testGetItemAttributes($type, $typeId)
$expectedResult = [
$linkAttributeMock,
];
- $linkMock = $this->createPartialMock(\Magento\Catalog\Model\Product\Link::class, ['getAttributes']);
+ $linkMock = $this->createPartialMock(Link::class, ['getAttributes']);
$linkMock->expects($this->once())->method('getAttributes')->willReturn($attributes);
$this->linkFactoryMock->expects($this->once())->method('create')->with($typeId)->willReturn($linkMock);
$this->linkAttributeFactoryMock->expects($this->once())->method('create')->willReturn($linkAttributeMock);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Media/AttributeManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Media/AttributeManagementTest.php
index 7143b16ade685..8c5d7e8b92325 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Media/AttributeManagementTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Media/AttributeManagementTest.php
@@ -3,13 +3,22 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Media;
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Catalog\Model\Product;
-
use Magento\Catalog\Model\Product\Media\AttributeManagement;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+
+use PHPUnit\Framework\TestCase;
-class AttributeManagementTest extends \PHPUnit\Framework\TestCase
+class AttributeManagementTest extends TestCase
{
/**
* @var AttributeManagement
@@ -22,24 +31,24 @@ class AttributeManagementTest extends \PHPUnit\Framework\TestCase
private $storeId;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $factoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $storeManagerMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->factoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
$this->storeId = 1;
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
+ $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $storeMock = $this->createMock(Store::class);
$storeMock->expects($this->any())
->method('getId')
->will($this->returnValue($this->storeId));
@@ -57,9 +66,9 @@ public function testGetList()
{
$attributeSetName = 'Default Attribute Set';
$expectedResult = [
- $this->createMock(\Magento\Catalog\Api\Data\ProductAttributeInterface::class),
+ $this->createMock(ProductAttributeInterface::class),
];
- $collectionMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class);
+ $collectionMock = $this->createMock(Collection::class);
$collectionMock->expects($this->once())
->method('setAttributeSetFilterBySetName')
->with($attributeSetName, Product::ENTITY);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/RepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/RepositoryTest.php
index fd7283903869d..ac67ba52d7728 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/RepositoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/RepositoryTest.php
@@ -3,17 +3,28 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Option;
-use \Magento\Catalog\Model\Product\Option\Repository;
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
-use \Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Option\Converter;
+use Magento\Catalog\Model\Product\Option\Repository;
+use Magento\Catalog\Model\Product\OptionFactory;
+use Magento\Catalog\Model\ProductRepository;
+use Magento\Catalog\Model\ResourceModel\Product\Option;
+use Magento\Catalog\Model\ResourceModel\Product\Option\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory;
+use Magento\Framework\EntityManager\EntityMetadata;
+use Magento\Framework\EntityManager\MetadataPool;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class RepositoryTest extends \PHPUnit\Framework\TestCase
+class RepositoryTest extends TestCase
{
/**
* @var Repository
@@ -21,46 +32,46 @@ class RepositoryTest extends \PHPUnit\Framework\TestCase
protected $optionRepository;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productRepositoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $optionResourceMock;
/**
- * @var ProductCustomOptionInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductCustomOptionInterface|MockObject
*/
protected $optionMock;
/**
- * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
protected $optionCollectionFactory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->productRepositoryMock = $this->createMock(\Magento\Catalog\Model\ProductRepository::class);
- $this->optionResourceMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Option::class);
- $this->converterMock = $this->createMock(\Magento\Catalog\Model\Product\Option\Converter::class);
+ $this->productRepositoryMock = $this->createMock(ProductRepository::class);
+ $this->optionResourceMock = $this->createMock(Option::class);
+ $converterMock = $this->createMock(Converter::class);
$this->optionMock = $this->createMock(\Magento\Catalog\Model\Product\Option::class);
- $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $optionFactory = $this->createPartialMock(\Magento\Catalog\Model\Product\OptionFactory::class, ['create']);
+ $this->productMock = $this->createMock(Product::class);
+ $optionFactory = $this->createPartialMock(OptionFactory::class, ['create']);
$this->optionCollectionFactory = $this->getMockBuilder(CollectionFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $metadataPool = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class)
+ $metadataPool = $this->getMockBuilder(MetadataPool::class)
->disableOriginalConstructor()
->getMock();
- $metadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadata::class)
+ $metadata = $this->getMockBuilder(EntityMetadata::class)
->disableOriginalConstructor()
->getMock();
$metadataPool->expects($this->any())->method('getMetadata')->willReturn($metadata);
@@ -68,7 +79,7 @@ protected function setUp()
$this->optionRepository = new Repository(
$this->productRepositoryMock,
$this->optionResourceMock,
- $this->converterMock,
+ $converterMock,
$this->optionCollectionFactory,
$optionFactory,
$metadataPool
@@ -94,11 +105,9 @@ public function testDelete()
$this->assertTrue($this->optionRepository->delete($this->optionMock));
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- */
public function testGetNonExistingOption()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
$optionId = 1;
$productSku = 'simple_product';
$this->productRepositoryMock
@@ -130,11 +139,9 @@ public function testGet()
$this->assertEquals($this->optionMock, $this->optionRepository->get($productSku, $optionId));
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- */
public function testDeleteByIdentifierNonExistingOption()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
$optionId = 1;
$productSku = 'simple_product';
$this->productRepositoryMock
@@ -171,11 +178,9 @@ public function testDeleteByIdentifier()
$this->assertTrue($this->optionRepository->deleteByIdentifier($productSku, $optionId));
}
- /**
- * @expectedException \Magento\Framework\Exception\CouldNotSaveException
- */
public function testDeleteByIdentifierWhenCannotRemoveOption()
{
+ $this->expectException('Magento\Framework\Exception\CouldNotSaveException');
$optionId = 1;
$productSku = 'simple_product';
$this->productRepositoryMock
@@ -198,21 +203,17 @@ public function testDeleteByIdentifierWhenCannotRemoveOption()
$this->assertTrue($this->optionRepository->deleteByIdentifier($productSku, $optionId));
}
- /**
- * @expectedException \Magento\Framework\Exception\CouldNotSaveException
- * @expectedExceptionMessage The ProductSku is empty. Set the ProductSku and try again.
- */
public function testSaveCouldNotSaveException()
{
+ $this->expectException('Magento\Framework\Exception\CouldNotSaveException');
+ $this->expectExceptionMessage('The ProductSku is empty. Set the ProductSku and try again.');
$this->optionMock->expects($this->once())->method('getProductSku')->willReturn(null);
$this->optionRepository->save($this->optionMock);
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- */
public function testSaveNoSuchEntityException()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
$productSku = 'simple_product';
$optionId = 1;
$productOptionId = 2;
@@ -256,7 +257,7 @@ public function testSave()
['option_type_id' => 4],
['option_type_id' => 5]
]);
- $optionCollection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Option\Collection::class)
+ $optionCollection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
$optionCollection->expects($this->once())->method('getProductOptions')->willReturn([$this->optionMock]);
@@ -285,7 +286,7 @@ public function testSaveWhenOptionTypeWasChanged()
['option_type_id' => 4],
['option_type_id' => 5]
]);
- $optionCollection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Option\Collection::class)
+ $optionCollection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
$optionCollection->expects($this->once())->method('getProductOptions')->willReturn([$this->optionMock]);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/SaveHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/SaveHandlerTest.php
index 6fe0594be08f2..8bcb203d5a43d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/SaveHandlerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/SaveHandlerTest.php
@@ -3,37 +3,40 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Option;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Option;
-use \Magento\Catalog\Model\Product\Option\Repository;
-use \Magento\Catalog\Model\Product\Option\SaveHandler;
+use Magento\Catalog\Model\Product\Option\Repository;
+use Magento\Catalog\Model\Product\Option\SaveHandler;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SaveHandlerTest extends \PHPUnit\Framework\TestCase
+class SaveHandlerTest extends TestCase
{
/**
- * @var SaveHandler|\PHPUnit_Framework_MockObject_MockObject
+ * @var SaveHandler|MockObject
*/
protected $model;
/**
- * @var Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
protected $entity;
/**
- * @var Option|\PHPUnit_Framework_MockObject_MockObject
+ * @var Option|MockObject
*/
protected $optionMock;
/**
- * @var Repository|\PHPUnit_Framework_MockObject_MockObject
+ * @var Repository|MockObject
*/
protected $optionRepository;
- public function setUp()
+ public function setUp(): void
{
$this->entity = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FactoryTest.php
index 8d498ad91d1a0..def5e66c18032 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FactoryTest.php
@@ -3,34 +3,43 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Option\Type;
-class FactoryTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product\Option\Type\DefaultType;
+use Magento\Catalog\Model\Product\Option\Type\Factory;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class FactoryTest extends TestCase
{
/**
- * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
protected $_objectManagerMock;
/**
- * @var \Magento\Catalog\Model\Product\Option\Type\Factory
+ * @var Factory
*/
protected $_factory;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
+ $this->_objectManagerMock = $this->createMock(ObjectManagerInterface::class);
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
$this->_factory = $objectManagerHelper->getObject(
- \Magento\Catalog\Model\Product\Option\Type\Factory::class,
+ Factory::class,
['objectManager' => $this->_objectManagerMock]
);
}
public function testCreate()
{
- $className = \Magento\Catalog\Model\Product\Option\Type\DefaultType::class;
+ $className = DefaultType::class;
$filterMock = $this->createMock($className);
$this->_objectManagerMock->expects(
@@ -49,7 +58,7 @@ public function testCreate()
public function testCreateWithArguments()
{
- $className = \Magento\Catalog\Model\Product\Option\Type\DefaultType::class;
+ $className = DefaultType::class;
$arguments = ['foo', 'bar'];
$filterMock = $this->createMock($className);
@@ -67,12 +76,12 @@ public function testCreateWithArguments()
$this->assertEquals($filterMock, $this->_factory->create($className, $arguments));
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage WrongClass doesn't extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
- */
public function testWrongTypeException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage(
+ 'WrongClass doesn\'t extends \Magento\Catalog\Model\Product\Option\Type\DefaultType'
+ );
$className = 'WrongClass';
$filterMock = $this->getMockBuilder($className)->disableOriginalConstructor()->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php
index a001ea20f16e0..bd61eb839a71e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php
@@ -3,64 +3,74 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Option\Type;
use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface;
+use Magento\Catalog\Model\Product\Option\Type\File;
+use Magento\Catalog\Model\Product\Option\UrlBuilder;
use Magento\Framework\App\Filesystem\DirectoryList;
+use Magento\Framework\Escaper;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\Filesystem\DriverPool;
+use Magento\Framework\Serialize\Serializer\Json;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\MediaStorage\Helper\File\Storage\Database;
+use Magento\Quote\Model\Quote\Item\Option;
+use Magento\Quote\Model\Quote\Item\OptionFactory;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class FileTest.
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class FileTest extends \PHPUnit\Framework\TestCase
+class FileTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManager;
/**
- * @var WriteInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriteInterface|MockObject
*/
protected $mediaDirectory;
/**
- * @var \Magento\MediaStorage\Helper\File\Storage\Database|\PHPUnit_Framework_MockObject_MockObject
+ * @var Database|MockObject
*/
protected $coreFileStorageDatabase;
/**
- * @var Filesystem|\PHPUnit_Framework_MockObject_MockObject
+ * @var Filesystem|MockObject
*/
private $filesystemMock;
/**
- * @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject
+ * @var Json|MockObject
*/
private $serializer;
/**
- * @var \Magento\Catalog\Model\Product\Option\UrlBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlBuilder|MockObject
*/
private $urlBuilder;
/**
- * @var \Magento\Framework\Escaper|\PHPUnit_Framework_MockObject_MockObject
+ * @var Escaper|MockObject
*/
private $escaper;
/**
- * @var \Magento\Quote\Model\Quote\Item\OptionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var OptionFactory|MockObject
*/
private $itemOptionFactoryMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
$this->filesystemMock = $this->getMockBuilder(Filesystem::class)
->disableOriginalConstructor()
@@ -74,26 +84,26 @@ protected function setUp()
->with(DirectoryList::MEDIA, DriverPool::FILE)
->willReturn($this->mediaDirectory);
- $this->serializer = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)
+ $this->serializer = $this->getMockBuilder(Json::class)
->disableOriginalConstructor()
->setMethods(['serialize', 'unserialize'])
->getMock();
- $this->urlBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\UrlBuilder::class)
+ $this->urlBuilder = $this->getMockBuilder(UrlBuilder::class)
->disableOriginalConstructor()
->getMock();
- $this->escaper = $this->getMockBuilder(\Magento\Framework\Escaper::class)
+ $this->escaper = $this->getMockBuilder(Escaper::class)
->disableOriginalConstructor()
->getMock();
- $this->itemOptionFactoryMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\OptionFactory::class)
+ $this->itemOptionFactoryMock = $this->getMockBuilder(OptionFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
$this->coreFileStorageDatabase = $this->createPartialMock(
- \Magento\MediaStorage\Helper\File\Storage\Database::class,
+ Database::class,
['copyFile', 'checkDbUsage']
);
@@ -119,12 +129,12 @@ function ($value) {
}
/**
- * @return \Magento\Catalog\Model\Product\Option\Type\File
+ * @return File
*/
protected function getFileObject()
{
return $this->objectManager->getObject(
- \Magento\Catalog\Model\Product\Option\Type\File::class,
+ File::class,
[
'filesystem' => $this->filesystemMock,
'coreFileStorageDatabase' => $this->coreFileStorageDatabase,
@@ -213,7 +223,7 @@ function ($value) {
$fileObject->setData('configuration_item_option', $optionMock);
$this->assertInstanceOf(
- \Magento\Catalog\Model\Product\Option\Type\File::class,
+ File::class,
$fileObject->copyQuoteToOrder()
);
}
@@ -269,7 +279,7 @@ function ($value) {
$fileObject->setData('configuration_item_option', $optionMock);
$this->assertInstanceOf(
- \Magento\Catalog\Model\Product\Option\Type\File::class,
+ File::class,
$fileObject->copyQuoteToOrder()
);
}
@@ -297,7 +307,7 @@ public function testGetFormattedOptionValue()
->with($resultValue)
->willReturn(json_encode($resultValue));
- $option = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class)
+ $option = $this->getMockBuilder(Option::class)
->setMethods(['setValue'])
->disableOriginalConstructor()
->getMock();
@@ -320,7 +330,7 @@ public function testGetFormattedOptionValueInvalid()
public function testGetEditableOptionValue()
{
$configurationItemOption = $this->getMockBuilder(
- \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class
+ OptionInterface::class
)->disableOriginalConstructor()
->setMethods(['getId', 'getValue'])
->getMock();
@@ -360,7 +370,7 @@ public function testParseOptionValue()
$userInput = 'Option [2]';
$fileObject = $this->getFileObject();
- $itemMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class)
+ $itemMock = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->setMethods(['load', 'getValue'])
->getMock();
@@ -387,7 +397,7 @@ public function testParseOptionValueNoId()
$userInput = 'Option [xx]';
$fileObject = $this->getFileObject();
- $itemMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class)
+ $itemMock = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->setMethods(['load', 'getValue'])
->getMock();
@@ -414,7 +424,7 @@ public function testParseOptionValueInvalid()
$userInput = 'Option [2]';
$fileObject = $this->getFileObject();
- $itemMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class)
+ $itemMock = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->setMethods(['load', 'getValue'])
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/UrlBuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/UrlBuilderTest.php
index a1885cea058cd..2a082b24f1e1f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/UrlBuilderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/UrlBuilderTest.php
@@ -3,14 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Option;
+use Magento\Catalog\Model\Product\Option\UrlBuilder;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\UrlInterface;
+use PHPUnit\Framework\TestCase;
-class UrlBuilderTest extends \PHPUnit\Framework\TestCase
+class UrlBuilderTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Option\UrlBuilder
+ * @var UrlBuilder
*/
private $model;
@@ -19,22 +24,22 @@ public function testGetUrl()
$this->assertEquals('testResult', $this->model->getUrl('router', []));
}
- protected function setUp()
+ protected function setUp(): void
{
$mockedFrontendUrlBuilder = $this->getMockedFrontendUrlBuilder();
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Product\Option\UrlBuilder::class,
+ UrlBuilder::class,
['frontendUrlBuilder' => $mockedFrontendUrlBuilder]
);
}
/**
- * @return \Magento\Framework\UrlInterface
+ * @return UrlInterface
*/
private function getMockedFrontendUrlBuilder()
{
- $mockBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
+ $mockBuilder = $this->getMockBuilder(UrlInterface::class)
->disableOriginalConstructor();
$mock = $mockBuilder->getMockForAbstractClass();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/DefaultValidatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/DefaultValidatorTest.php
index 7c2ec8abb768a..6c63ac61df55e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/DefaultValidatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/DefaultValidatorTest.php
@@ -3,35 +3,46 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Option\Validator;
-class DefaultValidatorTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Config\Source\Product\Options\Price;
+use Magento\Catalog\Model\Product\Option;
+use Magento\Catalog\Model\Product\Option\Validator\DefaultValidator;
+use Magento\Catalog\Model\ProductOptions\ConfigInterface;
+use Magento\Framework\DataObject;
+use Magento\Framework\Locale\FormatInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class DefaultValidatorTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Option\Validator\DefaultValidator
+ * @var DefaultValidator
*/
protected $validator;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $valueMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $localeFormatMock;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
- $configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
- $storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price($storeManagerMock);
- $this->localeFormatMock = $this->createMock(\Magento\Framework\Locale\FormatInterface::class);
+ $configMock = $this->createMock(ConfigInterface::class);
+ $storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $priceConfigMock = new Price($storeManagerMock);
+ $this->localeFormatMock = $this->createMock(FormatInterface::class);
$config = [
[
@@ -56,7 +67,7 @@ protected function setUp()
],
];
$configMock->expects($this->once())->method('getAll')->will($this->returnValue($config));
- $this->validator = new \Magento\Catalog\Model\Product\Option\Validator\DefaultValidator(
+ $this->validator = new DefaultValidator(
$configMock,
$priceConfigMock,
$this->localeFormatMock
@@ -71,10 +82,10 @@ public function isValidTitleDataProvider()
{
$mess = ['option required fields' => 'Missed values for option required fields'];
return [
- ['option_title', 'name 1.1', 'fixed', 10, new \Magento\Framework\DataObject(['store_id' => 1]), [], true],
- ['option_title', 'name 1.1', 'fixed', 10, new \Magento\Framework\DataObject(['store_id' => 0]), [], true],
- [null, 'name 1.1', 'fixed', 10, new \Magento\Framework\DataObject(['store_id' => 1]), [], true],
- [null, 'name 1.1', 'fixed', 10, new \Magento\Framework\DataObject(['store_id' => 0]), $mess, false],
+ ['option_title', 'name 1.1', 'fixed', 10, new DataObject(['store_id' => 1]), [], true],
+ ['option_title', 'name 1.1', 'fixed', 10, new DataObject(['store_id' => 0]), [], true],
+ [null, 'name 1.1', 'fixed', 10, new DataObject(['store_id' => 1]), [], true],
+ [null, 'name 1.1', 'fixed', 10, new DataObject(['store_id' => 0]), $mess, false],
];
}
@@ -90,7 +101,7 @@ public function isValidTitleDataProvider()
public function testIsValidTitle($title, $type, $priceType, $price, $product, $messages, $result)
{
$methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct'];
- $valueMock = $this->createPartialMock(\Magento\Catalog\Model\Product\Option::class, $methods);
+ $valueMock = $this->createPartialMock(Option::class, $methods);
$valueMock->expects($this->once())->method('getTitle')->will($this->returnValue($title));
$valueMock->expects($this->any())->method('getType')->will($this->returnValue($type));
$valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue($priceType));
@@ -111,8 +122,8 @@ public function testIsValidTitle($title, $type, $priceType, $price, $product, $m
public function isValidFailDataProvider()
{
return [
- [new \Magento\Framework\DataObject(['store_id' => 1])],
- [new \Magento\Framework\DataObject(['store_id' => 0])],
+ [new DataObject(['store_id' => 1])],
+ [new DataObject(['store_id' => 0])],
];
}
@@ -123,7 +134,7 @@ public function isValidFailDataProvider()
public function testIsValidFail($product)
{
$methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct'];
- $valueMock = $this->createPartialMock(\Magento\Catalog\Model\Product\Option::class, $methods);
+ $valueMock = $this->createPartialMock(Option::class, $methods);
$valueMock->expects($this->once())->method('getProduct')->will($this->returnValue($product));
$valueMock->expects($this->once())->method('getTitle');
$valueMock->expects($this->any())->method('getType');
@@ -145,10 +156,10 @@ public function testIsValidFail($product)
public function validationPriceDataProvider()
{
return [
- ['option_title', 'name 1.1', 'fixed', -12, new \Magento\Framework\DataObject(['store_id' => 1])],
- ['option_title', 'name 1.1', 'fixed', -12, new \Magento\Framework\DataObject(['store_id' => 0])],
- ['option_title', 'name 1.1', 'fixed', 12, new \Magento\Framework\DataObject(['store_id' => 1])],
- ['option_title', 'name 1.1', 'fixed', 12, new \Magento\Framework\DataObject(['store_id' => 0])]
+ ['option_title', 'name 1.1', 'fixed', -12, new DataObject(['store_id' => 1])],
+ ['option_title', 'name 1.1', 'fixed', -12, new DataObject(['store_id' => 0])],
+ ['option_title', 'name 1.1', 'fixed', 12, new DataObject(['store_id' => 1])],
+ ['option_title', 'name 1.1', 'fixed', 12, new DataObject(['store_id' => 0])]
];
}
@@ -163,7 +174,7 @@ public function validationPriceDataProvider()
public function testValidationPrice($title, $type, $priceType, $price, $product)
{
$methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct'];
- $valueMock = $this->createPartialMock(\Magento\Catalog\Model\Product\Option::class, $methods);
+ $valueMock = $this->createPartialMock(Option::class, $methods);
$valueMock->expects($this->once())->method('getTitle')->will($this->returnValue($title));
$valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue($type));
$valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue($priceType));
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/FileTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/FileTest.php
index e688da1c6aa16..e93fa2edc5062 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/FileTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/FileTest.php
@@ -3,35 +3,45 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Option\Validator;
-class FileTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Config\Source\Product\Options\Price;
+use Magento\Catalog\Model\Product\Option;
+use Magento\Catalog\Model\Product\Option\Validator\File;
+use Magento\Catalog\Model\ProductOptions\ConfigInterface;
+use Magento\Framework\Locale\FormatInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class FileTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Option\Validator\File
+ * @var File
*/
protected $validator;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $valueMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $localeFormatMock;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
- $configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
- $storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price($storeManagerMock);
- $this->localeFormatMock = $this->createMock(\Magento\Framework\Locale\FormatInterface::class);
+ $configMock = $this->createMock(ConfigInterface::class);
+ $storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $priceConfigMock = new Price($storeManagerMock);
+ $this->localeFormatMock = $this->createMock(FormatInterface::class);
$config = [
[
@@ -57,8 +67,8 @@ protected function setUp()
];
$configMock->expects($this->once())->method('getAll')->will($this->returnValue($config));
$methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', 'getImageSizeX', 'getImageSizeY','__wakeup'];
- $this->valueMock = $this->createPartialMock(\Magento\Catalog\Model\Product\Option::class, $methods);
- $this->validator = new \Magento\Catalog\Model\Product\Option\Validator\File(
+ $this->valueMock = $this->createPartialMock(Option::class, $methods);
+ $this->validator = new File(
$configMock,
$priceConfigMock,
$this->localeFormatMock
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/PoolTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/PoolTest.php
index 2bf04332bd73d..1b80043aebc73 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/PoolTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/PoolTest.php
@@ -3,33 +3,40 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Option\Validator;
-class PoolTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product\Option\Validator\DefaultValidator;
+use Magento\Catalog\Model\Product\Option\Validator\Pool;
+use Magento\Catalog\Model\Product\Option\Validator\Select;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class PoolTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Option\Validator\Pool
+ * @var Pool
*/
protected $pool;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $defaultValidatorMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $selectValidatorMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->defaultValidatorMock = $this->createMock(
- \Magento\Catalog\Model\Product\Option\Validator\DefaultValidator::class
+ DefaultValidator::class
);
- $this->selectValidatorMock = $this->createMock(\Magento\Catalog\Model\Product\Option\Validator\Select::class);
- $this->pool = new \Magento\Catalog\Model\Product\Option\Validator\Pool(
+ $this->selectValidatorMock = $this->createMock(Select::class);
+ $this->pool = new Pool(
['default' => $this->defaultValidatorMock, 'select' => $this->selectValidatorMock]
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php
index 7fad5592a2d21..4ebc5255330fb 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php
@@ -3,35 +3,45 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Option\Validator;
-class SelectTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Config\Source\Product\Options\Price;
+use Magento\Catalog\Model\Product\Option;
+use Magento\Catalog\Model\Product\Option\Validator\Select;
+use Magento\Catalog\Model\ProductOptions\ConfigInterface;
+use Magento\Framework\Locale\FormatInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class SelectTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Option\Validator\Select
+ * @var Select
*/
protected $validator;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $valueMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $localeFormatMock;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
- $configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
- $storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price($storeManagerMock);
- $this->localeFormatMock = $this->createMock(\Magento\Framework\Locale\FormatInterface::class);
+ $configMock = $this->createMock(ConfigInterface::class);
+ $storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $priceConfigMock = new Price($storeManagerMock);
+ $this->localeFormatMock = $this->createMock(FormatInterface::class);
$config = [
[
'label' => 'group label 1',
@@ -56,8 +66,8 @@ protected function setUp()
];
$configMock->expects($this->once())->method('getAll')->will($this->returnValue($config));
$methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getData'];
- $this->valueMock = $this->createPartialMock(\Magento\Catalog\Model\Product\Option::class, $methods, []);
- $this->validator = new \Magento\Catalog\Model\Product\Option\Validator\Select(
+ $this->valueMock = $this->createPartialMock(Option::class, $methods, []);
+ $this->validator = new Select(
$configMock,
$priceConfigMock,
$this->localeFormatMock
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/TextTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/TextTest.php
index a3e6189f74925..69c13d684b155 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/TextTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/TextTest.php
@@ -3,35 +3,45 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Option\Validator;
-class TextTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Config\Source\Product\Options\Price;
+use Magento\Catalog\Model\Product\Option;
+use Magento\Catalog\Model\Product\Option\Validator\Text;
+use Magento\Catalog\Model\ProductOptions\ConfigInterface;
+use Magento\Framework\Locale\FormatInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class TextTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Option\Validator\Text
+ * @var Text
*/
protected $validator;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $valueMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $localeFormatMock;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
- $configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
- $storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price($storeManagerMock);
- $this->localeFormatMock = $this->createMock(\Magento\Framework\Locale\FormatInterface::class);
+ $configMock = $this->createMock(ConfigInterface::class);
+ $storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $priceConfigMock = new Price($storeManagerMock);
+ $this->localeFormatMock = $this->createMock(FormatInterface::class);
$config = [
[
'label' => 'group label 1',
@@ -56,8 +66,8 @@ protected function setUp()
];
$configMock->expects($this->once())->method('getAll')->will($this->returnValue($config));
$methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getMaxCharacters'];
- $this->valueMock = $this->createPartialMock(\Magento\Catalog\Model\Product\Option::class, $methods);
- $this->validator = new \Magento\Catalog\Model\Product\Option\Validator\Text(
+ $this->valueMock = $this->createPartialMock(Option::class, $methods);
+ $this->validator = new Text(
$configMock,
$priceConfigMock,
$this->localeFormatMock
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php
index 212c8020750d2..06c352d7c67ed 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php
@@ -8,25 +8,31 @@
namespace Magento\Catalog\Test\Unit\Model\Product\Option;
use Magento\Catalog\Model\Product;
-
use Magento\Catalog\Model\Product\Option;
use Magento\Catalog\Model\Product\Option\Value;
+use Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory;
use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
+use Magento\Catalog\Pricing\Price\CustomOptionPriceCalculator;
+
+use Magento\Framework\Pricing\Price\PriceInterface;
+use Magento\Framework\Pricing\PriceInfoInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test for \Magento\Catalog\Model\Product\Option\Value class.
*/
-class ValueTest extends \PHPUnit\Framework\TestCase
+class ValueTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Option\Value
+ * @var Value
*/
private $model;
/**
- * @var \Magento\Catalog\Pricing\Price\CustomOptionPriceCalculator
+ * @var CustomOptionPriceCalculator
*/
private $customOptionPriceCalculatorMock;
@@ -35,13 +41,13 @@ class ValueTest extends \PHPUnit\Framework\TestCase
*/
private $CalculateCustomOptionCatalogRule;
- protected function setUp()
+ protected function setUp(): void
{
$mockedResource = $this->getMockedResource();
$mockedCollectionFactory = $this->getMockedValueCollectionFactory();
$this->customOptionPriceCalculatorMock = $this->createMock(
- \Magento\Catalog\Pricing\Price\CustomOptionPriceCalculator::class
+ CustomOptionPriceCalculator::class
);
$this->CalculateCustomOptionCatalogRule = $this->createMock(
@@ -50,7 +56,7 @@ protected function setUp()
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
- \Magento\Catalog\Model\Product\Option\Value::class,
+ Value::class,
[
'resource' => $mockedResource,
'valueCollectionFactory' => $mockedCollectionFactory,
@@ -67,12 +73,12 @@ public function testSaveProduct()
->setData('option_type_id', -1)
->setDataChanges(false)
->isDeleted(false);
- $this->assertInstanceOf(\Magento\Catalog\Model\Product\Option\Value::class, $this->model->saveValues());
+ $this->assertInstanceOf(Value::class, $this->model->saveValues());
$this->model->setData('is_delete', 1)
->setData('option_type_id', 1)
->setValues([100]);
- $this->assertInstanceOf(\Magento\Catalog\Model\Product\Option\Value::class, $this->model->saveValues());
+ $this->assertInstanceOf(Value::class, $this->model->saveValues());
}
public function testGetPrice()
@@ -92,7 +98,7 @@ public function testGetPrice()
public function testGetValuesCollection()
{
$this->assertInstanceOf(
- \Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection::class,
+ Collection::class,
$this->model->getValuesCollection($this->getMockedOption())
);
}
@@ -100,40 +106,40 @@ public function testGetValuesCollection()
public function testGetValuesByOption()
{
$this->assertInstanceOf(
- \Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection::class,
+ Collection::class,
$this->model->getValuesByOption([1], 1, 1)
);
}
public function testGetProduct()
{
- $this->assertInstanceOf(\Magento\Catalog\Model\Product::class, $this->model->getProduct());
+ $this->assertInstanceOf(Product::class, $this->model->getProduct());
}
public function testDuplicate()
{
- $this->assertInstanceOf(\Magento\Catalog\Model\Product\Option\Value::class, $this->model->duplicate(1, 1));
+ $this->assertInstanceOf(Value::class, $this->model->duplicate(1, 1));
}
public function testDeleteValues()
{
- $this->assertInstanceOf(\Magento\Catalog\Model\Product\Option\Value::class, $this->model->deleteValues(1));
+ $this->assertInstanceOf(Value::class, $this->model->deleteValues(1));
}
public function testDeleteValue()
{
- $this->assertInstanceOf(\Magento\Catalog\Model\Product\Option\Value::class, $this->model->deleteValue(1));
+ $this->assertInstanceOf(Value::class, $this->model->deleteValue(1));
}
/**
- * @return \Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory
+ * @return CollectionFactory
*/
private function getMockedValueCollectionFactory()
{
$mockedCollection = $this->getMockedValueCollection();
$mockBuilder =
- $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory::class)
+ $this->getMockBuilder(CollectionFactory::class)
->setMethods(['create'])
->disableOriginalConstructor();
$mock = $mockBuilder->getMock();
@@ -146,12 +152,12 @@ private function getMockedValueCollectionFactory()
}
/**
- * @return \Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection
+ * @return Collection
*/
private function getMockedValueCollection()
{
$mockBuilder = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection::class
+ Collection::class
)->setMethods(['addFieldToFilter', 'getValuesByOption', 'getValues'])->disableOriginalConstructor();
$mock = $mockBuilder->getMock();
@@ -177,7 +183,7 @@ private function getMockedOption()
{
$mockedProduct = $this->getMockedProduct();
- $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class)
+ $mockBuilder = $this->getMockBuilder(Option::class)
->disableOriginalConstructor();
$mock = $mockBuilder->getMock();
@@ -193,13 +199,13 @@ private function getMockedOption()
*/
private function getMockedProduct()
{
- $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $mockBuilder = $this->getMockBuilder(Product::class)
->setMethods(['getPriceInfo', '__wakeup'])
->disableOriginalConstructor();
$mock = $mockBuilder->getMock();
$priceInfoMock = $this->getMockForAbstractClass(
- \Magento\Framework\Pricing\PriceInfoInterface::class,
+ PriceInfoInterface::class,
[],
'',
false,
@@ -208,7 +214,7 @@ private function getMockedProduct()
['getPrice']
);
- $priceMock = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Price\PriceInterface::class);
+ $priceMock = $this->getMockForAbstractClass(PriceInterface::class);
$priceInfoMock->expects($this->any())->method('getPrice')->willReturn($priceMock);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php
index 1bd85c4053263..07dcca9974205 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php
@@ -3,28 +3,36 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product;
-use \Magento\Catalog\Model\Product\Option;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Option;
+use Magento\Catalog\Model\Product\Option\Value;
+use Magento\Framework\Pricing\Amount\AmountInterface;
+use Magento\Framework\Pricing\PriceInfoInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class OptionTest extends \PHPUnit\Framework\TestCase
+class OptionTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Option
+ * @var Option
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $this->productMock = $this->createMock(Product::class);
$objectManager = new ObjectManager($this);
- $this->model = $objectManager->getObject(\Magento\Catalog\Model\Product\Option::class);
+ $this->model = $objectManager->getObject(Option::class);
$this->model->setProduct($this->productMock);
}
@@ -47,7 +55,7 @@ public function testHasValues()
public function testGetRegularPrice()
{
$priceInfoMock = $this->getMockForAbstractClass(
- \Magento\Framework\Pricing\PriceInfoInterface::class,
+ PriceInfoInterface::class,
[],
'',
false,
@@ -56,14 +64,14 @@ public function testGetRegularPrice()
['getAmount', 'getPrice']
);
$priceInfoMock->expects($this->once())->method('getPrice')->willReturnSelf();
- $amountMock = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class);
+ $amountMock = $this->getMockForAbstractClass(AmountInterface::class);
$priceInfoMock->expects($this->once())->method('getAmount')->willReturn($amountMock);
$this->productMock->expects($this->once())->method('getPriceInfo')->willReturn($priceInfoMock);
$amountMock->expects($this->once())->method('getValue')->willReturn(50);
$this->model->setPrice(50);
- $this->model->setPriceType(\Magento\Catalog\Model\Product\Option\Value::TYPE_PERCENT);
+ $this->model->setPriceType(Value::TYPE_PERCENT);
$this->assertEquals(25, $this->model->getRegularPrice());
$this->model->setPriceType(null);
$this->assertEquals(50, $this->model->getRegularPrice());
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/BasePriceStorageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/BasePriceStorageTest.php
index 7f1044dfcc51e..46e3ec02f24e5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/BasePriceStorageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/BasePriceStorageTest.php
@@ -3,59 +3,73 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Price;
+use Magento\Catalog\Api\Data\BasePriceInterface;
+use Magento\Catalog\Api\Data\BasePriceInterfaceFactory;
+use Magento\Catalog\Api\Data\PriceUpdateResultInterface;
+use Magento\Catalog\Model\Product\Price\BasePriceStorage;
+use Magento\Catalog\Model\Product\Price\PricePersistence;
+use Magento\Catalog\Model\Product\Price\PricePersistenceFactory;
+use Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor;
+use Magento\Catalog\Model\Product\Price\Validation\Result;
+use Magento\Catalog\Model\ProductIdLocatorInterface;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Api\StoreRepositoryInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
- * Class BasePriceStorageTest.
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class BasePriceStorageTest extends \PHPUnit\Framework\TestCase
+class BasePriceStorageTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Price\PricePersistenceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var PricePersistenceFactory|MockObject
*/
private $pricePersistenceFactory;
/**
- * @var \Magento\Catalog\Model\Product\Price\PricePersistence|\PHPUnit_Framework_MockObject_MockObject
+ * @var PricePersistence|MockObject
*/
private $pricePersistence;
/**
- * @var \Magento\Catalog\Api\Data\BasePriceInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var BasePriceInterfaceFactory|MockObject
*/
private $basePriceInterfaceFactory;
/**
- * @var \Magento\Catalog\Api\Data\BasePriceInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var BasePriceInterface|MockObject
*/
private $basePriceInterface;
/**
- * @var \Magento\Catalog\Model\ProductIdLocatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductIdLocatorInterface|MockObject
*/
private $productIdLocator;
/**
- * @var \Magento\Store\Api\StoreRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreRepositoryInterface|MockObject
*/
private $storeRepository;
/**
- * @var \Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor
- * |\PHPUnit_Framework_MockObject_MockObject
+ * @var InvalidSkuProcessor|MockObject
*/
private $invalidSkuProcessor;
/**
- * @var \Magento\Catalog\Model\Product\Price\Validation\Result|\PHPUnit_Framework_MockObject_MockObject
+ * @var Result|MockObject
*/
private $validationResult;
/**
- * @var \Magento\Catalog\Model\Product\Price\BasePriceStorage
+ * @var BasePriceStorage
*/
private $model;
@@ -64,43 +78,43 @@ class BasePriceStorageTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->pricePersistenceFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\Product\Price\PricePersistenceFactory::class
+ PricePersistenceFactory::class
)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->pricePersistence = $this->getMockBuilder(\Magento\Catalog\Model\Product\Price\PricePersistence::class)
+ $this->pricePersistence = $this->getMockBuilder(PricePersistence::class)
->disableOriginalConstructor()
->getMock();
$this->basePriceInterfaceFactory = $this->getMockBuilder(
- \Magento\Catalog\Api\Data\BasePriceInterfaceFactory::class
+ BasePriceInterfaceFactory::class
)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->basePriceInterface = $this->getMockBuilder(\Magento\Catalog\Api\Data\BasePriceInterface::class)
+ $this->basePriceInterface = $this->getMockBuilder(BasePriceInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->productIdLocator = $this->getMockBuilder(\Magento\Catalog\Model\ProductIdLocatorInterface::class)
+ $this->productIdLocator = $this->getMockBuilder(ProductIdLocatorInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->storeRepository = $this->getMockBuilder(\Magento\Store\Api\StoreRepositoryInterface::class)
+ $this->storeRepository = $this->getMockBuilder(StoreRepositoryInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->invalidSkuProcessor = $this
- ->getMockBuilder(\Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor::class)
+ ->getMockBuilder(InvalidSkuProcessor::class)
->disableOriginalConstructor()
->getMock();
- $this->validationResult = $this->getMockBuilder(\Magento\Catalog\Model\Product\Price\Validation\Result::class)
+ $this->validationResult = $this->getMockBuilder(Result::class)
->disableOriginalConstructor()
->getMock();
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Price\BasePriceStorage::class,
+ BasePriceStorage::class,
[
'pricePersistenceFactory' => $this->pricePersistenceFactory,
'basePriceInterfaceFactory' => $this->basePriceInterfaceFactory,
@@ -179,13 +193,12 @@ public function testGet()
*/
public function testUpdate()
{
- $store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
+ $store = $this->getMockBuilder(StoreInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$sku = 'sku_1';
$idsBySku = [
- 'sku_1' =>
- [
+ 'sku_1' => [
1 => [
$this->basePriceInterface
]
@@ -229,7 +242,7 @@ public function testUpdate()
*/
public function testUpdateWithoutSkuAndWithNegativePrice()
{
- $exception = new \Magento\Framework\Exception\NoSuchEntityException();
+ $exception = new NoSuchEntityException();
$this->basePriceInterface->expects($this->atLeastOnce())->method('getSku')->willReturn(null);
$this->basePriceInterface->expects($this->atLeastOnce())->method('getPrice')->willReturn(-10);
$this->pricePersistenceFactory
@@ -241,7 +254,7 @@ public function testUpdateWithoutSkuAndWithNegativePrice()
->method('retrieveInvalidSkuList')
->with([null], ['simple', 'virtual', 'bundle', 'downloadable'], 1)
->willReturn([]);
- $priceUpdateResult = $this->getMockBuilder(\Magento\Catalog\Api\Data\PriceUpdateResultInterface::class)
+ $priceUpdateResult = $this->getMockBuilder(PriceUpdateResultInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->validationResult->expects($this->atLeastOnce())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/CostStorageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/CostStorageTest.php
index 410a11165018b..01ea02b4c8713 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/CostStorageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/CostStorageTest.php
@@ -3,58 +3,74 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Price;
+use Magento\Catalog\Api\Data\CostInterface;
+use Magento\Catalog\Api\Data\CostInterfaceFactory;
+use Magento\Catalog\Api\Data\PriceUpdateResultInterface;
+use Magento\Catalog\Model\Product\Price\CostStorage;
+use Magento\Catalog\Model\Product\Price\PricePersistence;
+use Magento\Catalog\Model\Product\Price\PricePersistenceFactory;
+use Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor;
+use Magento\Catalog\Model\Product\Price\Validation\Result;
+use Magento\Catalog\Model\Product\Type;
+use Magento\Catalog\Model\ProductIdLocatorInterface;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Api\StoreRepositoryInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
- * Class CostStorageTest.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CostStorageTest extends \PHPUnit\Framework\TestCase
+class CostStorageTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Price\PricePersistenceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var PricePersistenceFactory|MockObject
*/
private $pricePersistenceFactory;
/**
- * @var \Magento\Catalog\Model\Product\Price\PricePersistence|\PHPUnit_Framework_MockObject_MockObject
+ * @var PricePersistence|MockObject
*/
private $pricePersistence;
/**
- * @var \Magento\Catalog\Api\Data\CostInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CostInterfaceFactory|MockObject
*/
private $costInterfaceFactory;
/**
- * @var \Magento\Catalog\Api\Data\CostInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CostInterface|MockObject
*/
private $costInterface;
/**
- * @var \Magento\Catalog\Model\ProductIdLocatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductIdLocatorInterface|MockObject
*/
private $productIdLocator;
/**
- * @var \Magento\Store\Api\StoreRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreRepositoryInterface|MockObject
*/
private $storeRepository;
/**
- * @var \Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor
- * |\PHPUnit_Framework_MockObject_MockObject
+ * @var InvalidSkuProcessor|MockObject
*/
private $invalidSkuProcessor;
/**
- * @var \Magento\Catalog\Model\Product\Price\Validation\Result|\PHPUnit_Framework_MockObject_MockObject
+ * @var Result|MockObject
*/
private $validationResult;
/**
- * @var \Magento\Catalog\Model\Product\Price\CostStorage
+ * @var CostStorage
*/
private $model;
@@ -63,41 +79,41 @@ class CostStorageTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->pricePersistenceFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\Product\Price\PricePersistenceFactory::class
+ PricePersistenceFactory::class
)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->pricePersistence = $this->getMockBuilder(\Magento\Catalog\Model\Product\Price\PricePersistence::class)
+ $this->pricePersistence = $this->getMockBuilder(PricePersistence::class)
->disableOriginalConstructor()
->getMock();
- $this->costInterfaceFactory = $this->getMockBuilder(\Magento\Catalog\Api\Data\CostInterfaceFactory::class)
+ $this->costInterfaceFactory = $this->getMockBuilder(CostInterfaceFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->costInterface = $this->getMockBuilder(\Magento\Catalog\Api\Data\CostInterface::class)
+ $this->costInterface = $this->getMockBuilder(CostInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->productIdLocator = $this->getMockBuilder(\Magento\Catalog\Model\ProductIdLocatorInterface::class)
+ $this->productIdLocator = $this->getMockBuilder(ProductIdLocatorInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->storeRepository = $this->getMockBuilder(\Magento\Store\Api\StoreRepositoryInterface::class)
+ $this->storeRepository = $this->getMockBuilder(StoreRepositoryInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->validationResult = $this->getMockBuilder(\Magento\Catalog\Model\Product\Price\Validation\Result::class)
+ $this->validationResult = $this->getMockBuilder(Result::class)
->disableOriginalConstructor()
->getMock();
$this->invalidSkuProcessor = $this
- ->getMockBuilder(\Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor::class)
+ ->getMockBuilder(InvalidSkuProcessor::class)
->disableOriginalConstructor()
->getMock();
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Price\CostStorage::class,
+ CostStorage::class,
[
'pricePersistenceFactory' => $this->pricePersistenceFactory,
'costInterfaceFactory' => $this->costInterfaceFactory,
@@ -176,14 +192,13 @@ public function testGet()
*/
public function testUpdate()
{
- $store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
+ $store = $this->getMockBuilder(StoreInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$sku = 'sku_1';
$idsBySku = [
- 'sku_1' =>
- [
- 1 => \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL
+ 'sku_1' => [
+ 1 => Type::TYPE_VIRTUAL
]
];
$this->costInterface->expects($this->atLeastOnce())->method('getSku')->willReturn($sku);
@@ -231,7 +246,7 @@ public function testUpdate()
*/
public function testUpdateWithNegativeCostAndWithoutSku()
{
- $exception = new \Magento\Framework\Exception\NoSuchEntityException();
+ $exception = new NoSuchEntityException();
$this->costInterface->expects($this->atLeastOnce())->method('getSku')->willReturn(null);
$this->costInterface->expects($this->atLeastOnce())->method('getCost')->willReturn(-15);
$this->costInterface->expects($this->atLeastOnce())->method('getStoreId')->willReturn(10);
@@ -241,7 +256,7 @@ public function testUpdateWithNegativeCostAndWithoutSku()
->method('create')
->with(['attributeCode' => 'cost'])
->willReturn($this->pricePersistence);
- $priceUpdateResult = $this->getMockBuilder(\Magento\Catalog\Api\Data\PriceUpdateResultInterface::class)
+ $priceUpdateResult = $this->getMockBuilder(PriceUpdateResultInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->validationResult->expects($this->atLeastOnce())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/PricePersistenceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/PricePersistenceTest.php
index 98d897497f1fa..6494e0b033499 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/PricePersistenceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/PricePersistenceTest.php
@@ -3,46 +3,57 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Price;
-/**
- * Class PricePersistenceTest.
- */
-class PricePersistenceTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
+use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
+use Magento\Catalog\Model\Product\Price\PricePersistence;
+use Magento\Catalog\Model\Product\Type;
+use Magento\Catalog\Model\ProductIdLocatorInterface;
+use Magento\Catalog\Model\ResourceModel\Attribute;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class PricePersistenceTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Attribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var Attribute|MockObject
*/
private $attributeResource;
/**
- * @var \Magento\Catalog\Api\ProductAttributeRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductAttributeRepositoryInterface|MockObject
*/
private $attributeRepository;
/**
- * @var \Magento\Catalog\Api\Data\ProductAttributeInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductAttributeInterface|MockObject
*/
private $productAttribute;
/**
- * @var \Magento\Catalog\Model\ProductIdLocatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductIdLocatorInterface|MockObject
*/
private $productIdLocator;
/**
- * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
private $connection;
/**
- * @var \Magento\Framework\EntityManager\MetadataPool|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataPool|MockObject
*/
private $metadataPool;
/**
- * @var \Magento\Catalog\Model\Product\Price\PricePersistence
+ * @var PricePersistence
*/
private $model;
@@ -51,29 +62,29 @@ class PricePersistenceTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->attributeResource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Attribute::class)
+ $this->attributeResource = $this->getMockBuilder(Attribute::class)
->disableOriginalConstructor()->getMock();
$this->attributeRepository = $this->getMockBuilder(
- \Magento\Catalog\Api\ProductAttributeRepositoryInterface::class
+ ProductAttributeRepositoryInterface::class
)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->productIdLocator = $this->getMockBuilder(\Magento\Catalog\Model\ProductIdLocatorInterface::class)
+ $this->productIdLocator = $this->getMockBuilder(ProductIdLocatorInterface::class)
->disableOriginalConstructor()->getMockForAbstractClass();
- $this->metadataPool = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class)
+ $this->metadataPool = $this->getMockBuilder(MetadataPool::class)
->disableOriginalConstructor()
->setMethods(['getLinkField', 'getMetadata'])
->getMock();
- $this->connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
+ $this->connection = $this->getMockBuilder(AdapterInterface::class)
->disableOriginalConstructor()->getMockForAbstractClass();
- $this->productAttribute = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeInterface::class)
+ $this->productAttribute = $this->getMockBuilder(ProductAttributeInterface::class)
->disableOriginalConstructor()->getMockForAbstractClass();
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Price\PricePersistence::class,
+ PricePersistence::class,
[
'attributeResource' => $this->attributeResource,
'attributeRepository' => $this->attributeRepository,
@@ -94,13 +105,13 @@ public function testGet()
$skus = ['sku_1', 'sku_2'];
$idsBySku = [
'sku_1' => [
- 1 => \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
+ 1 => Type::TYPE_SIMPLE
],
'sku_2' => [
- 2 => \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL
+ 2 => Type::TYPE_VIRTUAL
]
];
- $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $select = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()->getMock();
$this->productIdLocator
->expects($this->once())
@@ -172,12 +183,11 @@ public function testUpdate()
/**
* Test update method throws exception.
- *
- * @expectedException \Magento\Framework\Exception\CouldNotSaveException
- * @expectedExceptionMessage Could not save Prices.
*/
public function testUpdateWithException()
{
+ $this->expectException('Magento\Framework\Exception\CouldNotSaveException');
+ $this->expectExceptionMessage('Could not save Prices.');
$attributeId = 5;
$prices = [
[
@@ -227,10 +237,10 @@ public function testDelete()
$skus = ['sku_1', 'sku_2'];
$idsBySku = [
'sku_1' => [
- 1 => \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
+ 1 => Type::TYPE_SIMPLE
],
'sku_2' => [
- 2 => \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL
+ 2 => Type::TYPE_VIRTUAL
]
];
$this->productIdLocator
@@ -265,20 +275,19 @@ public function testDelete()
/**
* Test delete method throws exception.
- *
- * @expectedException \Magento\Framework\Exception\CouldNotDeleteException
- * @expectedExceptionMessage Could not delete Prices
*/
public function testDeleteWithException()
{
+ $this->expectException('Magento\Framework\Exception\CouldNotDeleteException');
+ $this->expectExceptionMessage('Could not delete Prices');
$attributeId = 5;
$skus = ['sku_1', 'sku_2'];
$idsBySku = [
'sku_1' => [
- 1 => \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
+ 1 => Type::TYPE_SIMPLE
],
'sku_2' => [
- 2 => \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL
+ 2 => Type::TYPE_VIRTUAL
]
];
$this->productIdLocator
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/SpecialPriceStorageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/SpecialPriceStorageTest.php
index e2bd4e9c10b97..441c3d0a57ebf 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/SpecialPriceStorageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/SpecialPriceStorageTest.php
@@ -3,47 +3,59 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Price;
+use Magento\Catalog\Api\Data\SpecialPriceInterfaceFactory;
+use Magento\Catalog\Api\SpecialPriceInterface;
+use Magento\Catalog\Model\Product\Price\SpecialPriceStorage;
+use Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor;
+use Magento\Catalog\Model\Product\Price\Validation\Result;
+use Magento\Catalog\Model\ProductIdLocatorInterface;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Api\StoreRepositoryInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* Test for SpecialPriceStorage model.
*/
-class SpecialPriceStorageTest extends \PHPUnit\Framework\TestCase
+class SpecialPriceStorageTest extends TestCase
{
/**
- * @var \Magento\Catalog\Api\SpecialPriceInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var SpecialPriceInterface|MockObject
*/
private $specialPriceResource;
/**
- * @var \Magento\Catalog\Api\Data\SpecialPriceInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var SpecialPriceInterfaceFactory|MockObject
*/
private $specialPriceFactory;
/**
- * @var \Magento\Catalog\Model\ProductIdLocatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductIdLocatorInterface|MockObject
*/
private $productIdLocator;
/**
- * @var \Magento\Store\Api\StoreRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreRepositoryInterface|MockObject
*/
private $storeRepository;
/**
- * @var \Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor
- * |\PHPUnit_Framework_MockObject_MockObject
+ * @var InvalidSkuProcessor|MockObject
*/
private $invalidSkuProcessor;
/**
- * @var \Magento\Catalog\Model\Product\Price\Validation\Result|\PHPUnit_Framework_MockObject_MockObject
+ * @var Result|MockObject
*/
private $validationResult;
/**
- * @var \Magento\Catalog\Model\Product\Price\SpecialPriceStorage
+ * @var SpecialPriceStorage
*/
private $model;
@@ -52,26 +64,26 @@ class SpecialPriceStorageTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->specialPriceResource = $this->getMockBuilder(\Magento\Catalog\Api\SpecialPriceInterface::class)
+ $this->specialPriceResource = $this->getMockBuilder(SpecialPriceInterface::class)
->disableOriginalConstructor()->setMethods(['get', 'update', 'delete', 'getEntityLinkField'])->getMock();
- $this->productIdLocator = $this->getMockBuilder(\Magento\Catalog\Model\ProductIdLocatorInterface::class)
+ $this->productIdLocator = $this->getMockBuilder(ProductIdLocatorInterface::class)
->disableOriginalConstructor()->getMock();
- $this->storeRepository = $this->getMockBuilder(\Magento\Store\Api\StoreRepositoryInterface::class)
+ $this->storeRepository = $this->getMockBuilder(StoreRepositoryInterface::class)
->disableOriginalConstructor()->getMock();
$this->invalidSkuProcessor = $this
- ->getMockBuilder(\Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor::class)
+ ->getMockBuilder(InvalidSkuProcessor::class)
->disableOriginalConstructor()->getMock();
- $this->validationResult = $this->getMockBuilder(\Magento\Catalog\Model\Product\Price\Validation\Result::class)
+ $this->validationResult = $this->getMockBuilder(Result::class)
->disableOriginalConstructor()->getMock();
$this->specialPriceFactory = $this->getMockBuilder(
- \Magento\Catalog\Api\Data\SpecialPriceInterfaceFactory::class
+ SpecialPriceInterfaceFactory::class
)->disableOriginalConstructor()->setMethods(['create'])->getMock();
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Price\SpecialPriceStorage::class,
+ SpecialPriceStorage::class,
[
'specialPriceResource' => $this->specialPriceResource,
'specialPriceFactory' => $this->specialPriceFactory,
@@ -263,7 +275,7 @@ public function testUpdateWithException()
$price->expects($this->atLeastOnce())->method('getPriceTo')->willReturn('2016-12-21 01:02:03');
$this->invalidSkuProcessor->expects($this->once())->method('retrieveInvalidSkuList')->willReturn([]);
$this->storeRepository->expects($this->once())->method('getById')
- ->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException());
+ ->willThrowException(new NoSuchEntityException());
$this->validationResult->expects($this->once())
->method('addFailedItem')
->with(
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/TierPriceStorageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/TierPriceStorageTest.php
index 34f43b725da57..37c3f0f214c2d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/TierPriceStorageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/TierPriceStorageTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Price;
@@ -10,49 +11,50 @@
use Magento\Catalog\Model\Indexer\Product\Price\Processor as PriceIndexerProcessor;
use Magento\Catalog\Model\Product\Price\TierPriceFactory;
use Magento\Catalog\Model\Product\Price\TierPricePersistence;
+use Magento\Catalog\Model\Product\Price\TierPriceStorage;
use Magento\Catalog\Model\Product\Price\Validation\Result as PriceValidationResult;
use Magento\Catalog\Model\Product\Price\Validation\TierPriceValidator;
use Magento\Catalog\Model\ProductIdLocatorInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * TierPriceStorage test.
- */
-class TierPriceStorageTest extends \PHPUnit\Framework\TestCase
+class TierPriceStorageTest extends TestCase
{
/**
- * @var TierPricePersistence|\PHPUnit_Framework_MockObject_MockObject
+ * @var TierPricePersistence|MockObject
*/
private $tierPricePersistence;
/**
- * @var TierPriceValidator|\PHPUnit_Framework_MockObject_MockObject
+ * @var TierPriceValidator|MockObject
*/
private $tierPriceValidator;
/**
- * @var TierPriceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var TierPriceFactory|MockObject
*/
private $tierPriceFactory;
/**
- * @var PriceIndexerProcessor|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceIndexerProcessor|MockObject
*/
private $priceIndexProcessor;
/**
- * @var ProductIdLocatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductIdLocatorInterface|MockObject
*/
private $productIdLocator;
/**
- * @var \Magento\Catalog\Model\Product\Price\TierPriceStorage
+ * @var TierPriceStorage
*/
private $tierPriceStorage;
/**
* {@inheritdoc}
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->tierPricePersistence = $this->createMock(TierPricePersistence::class);
$this->tierPricePersistence->method('getEntityLinkField')
@@ -62,9 +64,9 @@ protected function setUp()
$this->priceIndexProcessor = $this->createMock(PriceIndexerProcessor::class);
$this->productIdLocator = $this->createMock(ProductIdLocatorInterface::class);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->tierPriceStorage = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Price\TierPriceStorage::class,
+ TierPriceStorage::class,
[
'tierPricePersistence' => $this->tierPricePersistence,
'tierPriceValidator' => $this->tierPriceValidator,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/InvalidSkuProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/InvalidSkuProcessorTest.php
index 740c0d29b8e2e..52c22e54e2279 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/InvalidSkuProcessorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/InvalidSkuProcessorTest.php
@@ -3,42 +3,52 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Price\Validation;
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor;
+use Magento\Catalog\Model\Product\Type;
+use Magento\Catalog\Model\ProductIdLocatorInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* Test for model Magento\Catalog\Product\Price\Validation\InvalidSkuProcessor.
*/
-class InvalidSkuProcessorTest extends \PHPUnit\Framework\TestCase
+class InvalidSkuProcessorTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor
+ * @var InvalidSkuProcessor
*/
private $invalidSkuProcessor;
/**
- * @var \Magento\Catalog\Model\ProductIdLocatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductIdLocatorInterface|MockObject
*/
private $productIdLocator;
/**
- * @var \Magento\Catalog\Api\ProductRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductRepositoryInterface|MockObject
*/
private $productRepository;
/**
* {@inheritdoc}
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->productIdLocator = $this->getMockBuilder(\Magento\Catalog\Model\ProductIdLocatorInterface::class)
+ $this->productIdLocator = $this->getMockBuilder(ProductIdLocatorInterface::class)
->disableOriginalConstructor()->getMockForAbstractClass();
- $this->productRepository = $this->getMockBuilder(\Magento\Catalog\Api\ProductRepositoryInterface::class)
+ $this->productRepository = $this->getMockBuilder(ProductRepositoryInterface::class)
->disableOriginalConstructor()->getMockForAbstractClass();
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->invalidSkuProcessor = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor::class,
+ InvalidSkuProcessor::class,
[
'productIdLocator' => $this->productIdLocator,
'productRepository' => $this->productRepository
@@ -58,7 +68,7 @@ private function prepareRetrieveInvalidSkuListMethod($productType, $productSku)
$idsBySku = [$productSku => [235235235 => $productType]];
$this->productIdLocator->expects($this->atLeastOnce())->method('retrieveProductIdsBySkus')
->willReturn($idsBySku);
- $product = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)
+ $product = $this->getMockBuilder(ProductInterface::class)
->setMethods(['getPriceType'])
->disableOriginalConstructor()->getMockForAbstractClass();
$productPriceType = 0;
@@ -74,7 +84,7 @@ private function prepareRetrieveInvalidSkuListMethod($productType, $productSku)
public function testRetrieveInvalidSkuList()
{
$productSku = 'LKJKJ2233636';
- $productType = \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE;
+ $productType = Type::TYPE_BUNDLE;
$methodParamSku = 'SDFSDF3242355';
$skus = [$methodParamSku];
$allowedProductTypes = [$productType];
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/ResultTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/ResultTest.php
index 7ed32d564ca19..823dc5a0c0409 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/ResultTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/ResultTest.php
@@ -8,11 +8,12 @@
namespace Magento\Catalog\Test\Unit\Model\Product\Price\Validation;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use Magento\Catalog\Model\Product\Price\Validation\Result;
-use PHPUnit\Framework\TestCase;
use Magento\Catalog\Api\Data\PriceUpdateResultInterface;
use Magento\Catalog\Api\Data\PriceUpdateResultInterfaceFactory;
+use Magento\Catalog\Model\Product\Price\Validation\Result;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
class ResultTest extends TestCase
{
@@ -22,19 +23,19 @@ class ResultTest extends TestCase
private $model;
/**
- * @var PriceUpdateResultInterfaceFactory|PHPUnit_Framework_MockObject_MockObject
+ * @var PriceUpdateResultInterfaceFactory|MockObject
*/
private $priceUpdateResultFactory;
/**
- * @var ObjectManagerHelper|PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerHelper|MockObject
*/
private $objectManager;
/**
* Setup environment for test
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->priceUpdateResultFactory = $this->getMockBuilder(PriceUpdateResultInterfaceFactory::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/TierPriceValidatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/TierPriceValidatorTest.php
index 960346c970573..6a9914db84ef7 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/TierPriceValidatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/TierPriceValidatorTest.php
@@ -3,88 +3,108 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Price\Validation;
+use Magento\Catalog\Api\Data\TierPriceInterface;
+use Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor;
+use Magento\Catalog\Model\Product\Price\Validation\Result;
+use Magento\Catalog\Model\Product\Price\Validation\TierPriceValidator;
+use Magento\Catalog\Model\Product\Type;
+use Magento\Catalog\Model\ProductIdLocatorInterface;
+use Magento\Customer\Api\Data\GroupInterface;
+use Magento\Customer\Api\Data\GroupSearchResultsInterface;
+use Magento\Customer\Api\GroupRepositoryInterface;
+use Magento\Framework\Api\AbstractSimpleObject;
+use Magento\Framework\Api\FilterBuilder;
+use Magento\Framework\Api\Search\SearchCriteriaInterface;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Api\Data\WebsiteInterface;
+use Magento\Store\Api\WebsiteRepositoryInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* Test for \Magento\Catalog\Model\Product\Price\Validation\TierPriceValidator.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class TierPriceValidatorTest extends \PHPUnit\Framework\TestCase
+class TierPriceValidatorTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Price\Validation\TierPriceValidator
+ * @var TierPriceValidator
*/
private $tierPriceValidator;
/**
- * @var \Magento\Catalog\Model\ProductIdLocatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductIdLocatorInterface|MockObject
*/
private $productIdLocator;
/**
- * @var \Magento\Framework\Api\SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var SearchCriteriaBuilder|MockObject
*/
private $searchCriteriaBuilder;
/**
- * @var \Magento\Framework\Api\FilterBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var FilterBuilder|MockObject
*/
private $filterBuilder;
/**
- * @var \Magento\Customer\Api\GroupRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupRepositoryInterface|MockObject
*/
private $customerGroupRepository;
/**
- * @var \Magento\Store\Api\WebsiteRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WebsiteRepositoryInterface|MockObject
*/
private $websiteRepository;
/**
- * @var \Magento\Catalog\Model\Product\Price\Validation\Result|\PHPUnit_Framework_MockObject_MockObject
+ * @var Result|MockObject
*/
private $validationResult;
/**
- * @var \Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor
- * |\PHPUnit_Framework_MockObject_MockObject
+ * @var InvalidSkuProcessor|MockObject
*/
private $invalidSkuProcessor;
/**
- * @var \Magento\Catalog\Api\Data\TierPriceInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var TierPriceInterface|MockObject
*/
private $tierPrice;
/**
* {@inheritdoc}
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->productIdLocator = $this->getMockBuilder(\Magento\Catalog\Model\ProductIdLocatorInterface::class)
+ $this->productIdLocator = $this->getMockBuilder(ProductIdLocatorInterface::class)
->disableOriginalConstructor()->getMockForAbstractClass();
- $this->searchCriteriaBuilder = $this->getMockBuilder(\Magento\Framework\Api\SearchCriteriaBuilder::class)
+ $this->searchCriteriaBuilder = $this->getMockBuilder(SearchCriteriaBuilder::class)
->disableOriginalConstructor()->getMock();
- $this->filterBuilder = $this->getMockBuilder(\Magento\Framework\Api\FilterBuilder::class)
+ $this->filterBuilder = $this->getMockBuilder(FilterBuilder::class)
->disableOriginalConstructor()->getMock();
- $this->customerGroupRepository = $this->getMockBuilder(\Magento\Customer\Api\GroupRepositoryInterface::class)
+ $this->customerGroupRepository = $this->getMockBuilder(GroupRepositoryInterface::class)
->disableOriginalConstructor()->getMockForAbstractClass();
- $this->websiteRepository = $this->getMockBuilder(\Magento\Store\Api\WebsiteRepositoryInterface::class)
+ $this->websiteRepository = $this->getMockBuilder(WebsiteRepositoryInterface::class)
->disableOriginalConstructor()->getMockForAbstractClass();
- $this->validationResult = $this->getMockBuilder(\Magento\Catalog\Model\Product\Price\Validation\Result::class)
+ $this->validationResult = $this->getMockBuilder(Result::class)
->disableOriginalConstructor()->getMock();
$this->invalidSkuProcessor = $this
- ->getMockBuilder(\Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor::class)
+ ->getMockBuilder(InvalidSkuProcessor::class)
->disableOriginalConstructor()->getMock();
- $this->tierPrice = $this->getMockBuilder(\Magento\Catalog\Api\Data\TierPriceInterface::class)
+ $this->tierPrice = $this->getMockBuilder(TierPriceInterface::class)
->disableOriginalConstructor()->getMockForAbstractClass();
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
$this->tierPriceValidator = $objectManagerHelper->getObject(
- \Magento\Catalog\Model\Product\Price\Validation\TierPriceValidator::class,
+ TierPriceValidator::class,
[
'productIdLocator' => $this->productIdLocator,
'searchCriteriaBuilder' => $this->searchCriteriaBuilder,
@@ -106,9 +126,9 @@ protected function setUp()
private function prepareCustomerGroupRepositoryMock(array $returned)
{
$searchCriteria = $this
- ->getMockBuilder(\Magento\Framework\Api\Search\SearchCriteriaInterface::class)
+ ->getMockBuilder(SearchCriteriaInterface::class)
->disableOriginalConstructor()->getMock();
- $filter = $this->getMockBuilder(\Magento\Framework\Api\AbstractSimpleObject::class)
+ $filter = $this->getMockBuilder(AbstractSimpleObject::class)
->disableOriginalConstructor()->getMockForAbstractClass();
$this->filterBuilder->expects($this->atLeastOnce())->method('setField')->willReturnSelf();
$this->filterBuilder->expects($this->atLeastOnce())->method('setValue')->willReturnSelf();
@@ -116,7 +136,7 @@ private function prepareCustomerGroupRepositoryMock(array $returned)
$this->searchCriteriaBuilder->expects($this->atLeastOnce())->method('addFilters')->willReturnSelf();
$this->searchCriteriaBuilder->expects($this->atLeastOnce())->method('create')->willReturn($searchCriteria);
$customerGroupSearchResults = $this
- ->getMockBuilder(\Magento\Customer\Api\Data\GroupSearchResultsInterface::class)
+ ->getMockBuilder(GroupSearchResultsInterface::class)
->disableOriginalConstructor()->getMock();
$customerGroupSearchResults->expects($this->once())->method('getItems')
->willReturn($returned['customerGroupSearchResults_getItems']);
@@ -150,7 +170,7 @@ private function prepareRetrieveValidationResultMethod($sku, array $returned)
$this->invalidSkuProcessor->expects($this->atLeastOnce())->method('retrieveInvalidSkuList')
->willReturn($skuDiff);
$productId = 3346346;
- $productType = \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE;
+ $productType = Type::TYPE_BUNDLE;
$idsBySku = [
$sku => [$productId => $productType]
];
@@ -187,7 +207,7 @@ public function testRetrieveValidationResult(array $returned)
$prices = [$this->tierPrice];
$existingPrices = [$this->tierPrice];
$this->prepareRetrieveValidationResultMethod($sku, $returned);
- $website = $this->getMockBuilder(\Magento\Store\Api\Data\WebsiteInterface::class)
+ $website = $this->getMockBuilder(WebsiteInterface::class)
->disableOriginalConstructor()->getMockForAbstractClass();
$this->websiteRepository->expects($this->atLeastOnce())->method('getById')->willReturn($website);
$this->prepareCustomerGroupRepositoryMock($returned);
@@ -206,7 +226,7 @@ public function testRetrieveValidationResult(array $returned)
public function retrieveValidationResultDataProvider()
{
$customerGroupName = 'test_Group';
- $customerGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)
+ $customerGroup = $this->getMockBuilder(GroupInterface::class)
->setMethods(['getCode', 'getId'])
->disableOriginalConstructor()->getMockForAbstractClass();
$customerGroup->expects($this->atLeastOnce())->method('getCode')->willReturn($customerGroupName);
@@ -217,14 +237,14 @@ public function retrieveValidationResultDataProvider()
[
[
'tierPrice_getCustomerGroup' => $customerGroupName,
- 'tierPrice_getPriceType' => \Magento\Catalog\Api\Data\TierPriceInterface::PRICE_TYPE_DISCOUNT,
+ 'tierPrice_getPriceType' => TierPriceInterface::PRICE_TYPE_DISCOUNT,
'customerGroupSearchResults_getItems' => [$customerGroup]
]
],
[
[
'tierPrice_getCustomerGroup' => $customerGroupName,
- 'tierPrice_getPriceType' => \Magento\Catalog\Api\Data\TierPriceInterface::PRICE_TYPE_FIXED,
+ 'tierPrice_getPriceType' => TierPriceInterface::PRICE_TYPE_FIXED,
'customerGroupSearchResults_getItems' => []
]
]
@@ -243,12 +263,12 @@ public function testRetrieveValidationResultWithException()
$prices = [$this->tierPrice];
$existingPrices = [$this->tierPrice];
$returned = [
- 'tierPrice_getPriceType' => \Magento\Catalog\Api\Data\TierPriceInterface::PRICE_TYPE_DISCOUNT,
+ 'tierPrice_getPriceType' => TierPriceInterface::PRICE_TYPE_DISCOUNT,
'customerGroupSearchResults_getItems' => [],
'tierPrice_getCustomerGroup' => $customerGroupName,
];
$this->prepareRetrieveValidationResultMethod($sku, $returned);
- $exception = new \Magento\Framework\Exception\NoSuchEntityException();
+ $exception = new NoSuchEntityException();
$this->websiteRepository->expects($this->atLeastOnce())->method('getById')->willThrowException($exception);
$this->prepareCustomerGroupRepositoryMock($returned);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifier/CompositeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifier/CompositeTest.php
index 9ea1ca9387c13..0bba531265aeb 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifier/CompositeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifier/CompositeTest.php
@@ -3,40 +3,49 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\PriceModifier;
-class CompositeTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\PriceModifier\Composite;
+use Magento\Catalog\Model\Product\PriceModifierInterface;
+use Magento\Framework\ObjectManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class CompositeTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\PriceModifier\Composite
+ * @var Composite
*/
protected $compositeModel;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $objectManagerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $priceModifierMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
- $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $this->priceModifierMock = $this->createMock(\Magento\Catalog\Model\Product\PriceModifierInterface::class);
+ $this->objectManagerMock = $this->createMock(ObjectManagerInterface::class);
+ $this->productMock = $this->createMock(Product::class);
+ $this->priceModifierMock = $this->createMock(PriceModifierInterface::class);
}
public function testModifyPriceIfModifierExists()
{
- $this->compositeModel = new \Magento\Catalog\Model\Product\PriceModifier\Composite(
+ $this->compositeModel = new Composite(
$this->objectManagerMock,
['some_class_name']
);
@@ -64,7 +73,7 @@ public function testModifyPriceIfModifierExists()
public function testModifyPriceIfModifierNotExists()
{
- $this->compositeModel = new \Magento\Catalog\Model\Product\PriceModifier\Composite(
+ $this->compositeModel = new Composite(
$this->objectManagerMock,
[]
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifierTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifierTest.php
index 6029a2b820086..1e8992e8338d2 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifierTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifierTest.php
@@ -3,23 +3,30 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product;
-class PriceModifierTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\PriceModifier;
+use Magento\Catalog\Model\ProductRepository;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class PriceModifierTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\PriceModifier
+ * @var PriceModifier
*/
protected $priceModifier;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productRepositoryMock;
@@ -28,12 +35,12 @@ class PriceModifierTest extends \PHPUnit\Framework\TestCase
*/
protected $prices = [];
- protected function setUp()
+ protected function setUp(): void
{
$this->productMock =
- $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getData', 'setData', '__wakeup']);
- $this->productRepositoryMock = $this->createMock(\Magento\Catalog\Model\ProductRepository::class);
- $this->priceModifier = new \Magento\Catalog\Model\Product\PriceModifier(
+ $this->createPartialMock(Product::class, ['getData', 'setData', '__wakeup']);
+ $this->productRepositoryMock = $this->createMock(ProductRepository::class);
+ $this->priceModifier = new PriceModifier(
$this->productRepositoryMock
);
$this->prices = [
@@ -52,12 +59,12 @@ protected function setUp()
];
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage Product hasn't group price with such data: customerGroupId = '1', website = 1, qty = 3
- */
public function testRemoveWhenTierPricesNotExists()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage(
+ 'Product hasn\'t group price with such data: customerGroupId = \'1\', website = 1, qty = 3'
+ );
$this->productMock
->expects($this->once())
->method('getData')
@@ -68,12 +75,12 @@ public function testRemoveWhenTierPricesNotExists()
$this->priceModifier->removeTierPrice($this->productMock, 1, 3, 1);
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage Product hasn't group price with such data: customerGroupId = '10', website = 1, qty = 5
- */
public function testRemoveTierPriceForNonExistingCustomerGroup()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage(
+ 'Product hasn\'t group price with such data: customerGroupId = \'10\', website = 1, qty = 5'
+ );
$this->productMock
->expects($this->once())
->method('getData')
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Pricing/Renderer/SalableResolverTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Pricing/Renderer/SalableResolverTest.php
index 760b4780ff1c6..3d685ea1205f4 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Pricing/Renderer/SalableResolverTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Pricing/Renderer/SalableResolverTest.php
@@ -3,31 +3,38 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Pricing\Renderer;
-class SalableResolverTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class SalableResolverTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver
+ * @var SalableResolver
*/
protected $object;
/**
- * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
protected $product;
- protected function setUp()
+ protected function setUp(): void
{
$this->product = $this->createPartialMock(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
['__wakeup', 'getCanShowPrice']
);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->object = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver::class
+ SalableResolver::class
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductFrontendAction/SynchronizerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductFrontendAction/SynchronizerTest.php
index 8b70899cd26d3..7726bdf9424c5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductFrontendAction/SynchronizerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductFrontendAction/SynchronizerTest.php
@@ -3,70 +3,82 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\ProductFrontendAction;
use Magento\Catalog\Api\Data\ProductFrontendActionInterface;
+use Magento\Catalog\Model\FrontendStorageConfigurationInterface;
+use Magento\Catalog\Model\FrontendStorageConfigurationPool;
+use Magento\Catalog\Model\Product\ProductFrontendAction\Synchronizer;
+use Magento\Catalog\Model\ProductFrontendActionFactory;
use Magento\Catalog\Model\ResourceModel\ProductFrontendAction\Collection;
+use Magento\Catalog\Model\ResourceModel\ProductFrontendAction\CollectionFactory;
+use Magento\Customer\Model\Session;
+use Magento\Customer\Model\Visitor;
+use Magento\Framework\EntityManager\EntityManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class SynchronizerTest extends \PHPUnit\Framework\TestCase
+class SynchronizerTest extends TestCase
{
- /** @var \Magento\Catalog\Model\Product\ProductFrontendAction\Synchronizer */
+ /** @var Synchronizer */
protected $model;
/** @var ObjectManagerHelper */
protected $objectManagerHelper;
- /** @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Session|MockObject */
protected $sessionMock;
- /** @var \Magento\Customer\Model\Visitor|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Visitor|MockObject */
protected $visitorMock;
- /** @var \Magento\Catalog\Model\ProductFrontendActionFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ProductFrontendActionFactory|MockObject */
protected $productFrontendActionFactoryMock;
- /** @var \Magento\Framework\EntityManager\EntityManager|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var EntityManager|MockObject */
protected $entityManagerMock;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
protected $collectionFactoryMock;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
protected $frontendStorageConfigurationPoolMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->sessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class)
+ $this->sessionMock = $this->getMockBuilder(Session::class)
->disableOriginalConstructor()
->getMock();
- $this->visitorMock = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class)
+ $this->visitorMock = $this->getMockBuilder(Visitor::class)
->disableOriginalConstructor()
->getMock();
$this->productFrontendActionFactoryMock = $this
- ->getMockBuilder(\Magento\Catalog\Model\ProductFrontendActionFactory::class)
+ ->getMockBuilder(ProductFrontendActionFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->entityManagerMock = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityManager::class)
+ $this->entityManagerMock = $this->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();
$this->collectionFactoryMock = $this
- ->getMockBuilder(\Magento\Catalog\Model\ResourceModel\ProductFrontendAction\CollectionFactory::class)
+ ->getMockBuilder(CollectionFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$this->frontendStorageConfigurationPoolMock = $this
- ->getMockBuilder(\Magento\Catalog\Model\FrontendStorageConfigurationPool::class)
+ ->getMockBuilder(FrontendStorageConfigurationPool::class)
->disableOriginalConstructor()
->getMock();
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Model\Product\ProductFrontendAction\Synchronizer::class,
+ Synchronizer::class,
[
'session' => $this->sessionMock,
'visitor' => $this->visitorMock,
@@ -95,7 +107,7 @@ public function testFilterProductActions()
'product_id' => 3,
]
];
- $frontendConfiguration = $this->createMock(\Magento\Catalog\Model\FrontendStorageConfigurationInterface::class);
+ $frontendConfiguration = $this->createMock(FrontendStorageConfigurationInterface::class);
$frontendConfiguration->expects($this->once())
->method('get')
->willReturn([
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductList/ToolbarTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductList/ToolbarTest.php
index 3789ba4ee126d..407ed766c1053 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductList/ToolbarTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductList/ToolbarTest.php
@@ -3,14 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\ProductList;
-use \Magento\Catalog\Model\Product\ProductList\Toolbar;
-
+use Magento\Catalog\Model\Product\ProductList\Toolbar;
+use Magento\Framework\App\Request\Http;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+
+use PHPUnit\Framework\TestCase;
-class ToolbarTest extends \PHPUnit\Framework\TestCase
+class ToolbarTest extends TestCase
{
/**
* @var Toolbar
@@ -18,20 +22,20 @@ class ToolbarTest extends \PHPUnit\Framework\TestCase
protected $toolbarModel;
/**
- * @var \Magento\Framework\App\Request\Http |\PHPUnit_Framework_MockObject_MockObject
+ * @var Http|MockObject
*/
protected $requestMock;
/**
* Set up
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
+ $this->requestMock = $this->getMockBuilder(Http::class)
->disableOriginalConstructor()
->getMock();
$this->toolbarModel = (new ObjectManager($this))->getObject(
- \Magento\Catalog\Model\Product\ProductList\Toolbar::class,
+ Toolbar::class,
[
'request' => $this->requestMock,
]
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ReservedAttributeListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ReservedAttributeListTest.php
index 5080e64f46e27..6ff1b2e89ef72 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ReservedAttributeListTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ReservedAttributeListTest.php
@@ -3,21 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product;
+use Magento\Catalog\Model\Entity\Attribute;
+use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\ReservedAttributeList;
+use PHPUnit\Framework\TestCase;
-class ReservedAttributeListTest extends \PHPUnit\Framework\TestCase
+class ReservedAttributeListTest extends TestCase
{
/**
* @var ReservedAttributeList
*/
protected $model;
- protected function setUp()
+ protected function setUp(): void
{
$this->model = new ReservedAttributeList(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
['some_value'],
['some_attribute']
);
@@ -30,7 +35,7 @@ protected function setUp()
public function testIsReservedAttribute($isUserDefined, $attributeCode, $expected)
{
$attribute = $this->createPartialMock(
- \Magento\Catalog\Model\Entity\Attribute::class,
+ Attribute::class,
['getIsUserDefined', 'getAttributeCode', '__sleep', '__wakeup']
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php
index ae479a9b34d48..3ef798e837efd 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php
@@ -3,19 +3,34 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product;
+use Magento\Catalog\Api\Data\ProductTierPriceInterface;
+use Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\PriceModifier;
use Magento\Catalog\Model\Product\TierPriceManagement;
-
+use Magento\Catalog\Model\ProductRepository;
+use Magento\Customer\Api\GroupManagementInterface;
+use Magento\Customer\Api\GroupRepositoryInterface;
+use Magento\Customer\Model\Data\Group;
use Magento\Customer\Model\GroupManagement;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Exception\TemporaryState\CouldNotSaveException;
+use Magento\Store\Model\ScopeInterface;
+use Magento\Store\Model\StoreManagerInterface;
+
+use Magento\Store\Model\Website;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class TierPriceManagementTest extends \PHPUnit\Framework\TestCase
+class TierPriceManagementTest extends TestCase
{
/**
* @var TierPriceManagement
@@ -23,73 +38,73 @@ class TierPriceManagementTest extends \PHPUnit\Framework\TestCase
protected $service;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $repositoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $priceFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $storeManagerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $priceModifierMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $websiteMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $configMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $groupManagementMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $groupRepositoryMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->repositoryMock = $this->createMock(\Magento\Catalog\Model\ProductRepository::class);
+ $this->repositoryMock = $this->createMock(ProductRepository::class);
$this->priceFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory::class,
+ ProductTierPriceInterfaceFactory::class,
['create']
);
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
$this->websiteMock =
- $this->createPartialMock(\Magento\Store\Model\Website::class, ['getId', '__wakeup']);
+ $this->createPartialMock(Website::class, ['getId', '__wakeup']);
$this->productMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
['getData', 'getIdBySku', 'load', '__wakeup', 'save', 'validate', 'setData']
);
- $this->configMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $this->configMock = $this->createMock(ScopeConfigInterface::class);
$this->priceModifierMock =
- $this->createMock(\Magento\Catalog\Model\Product\PriceModifier::class);
+ $this->createMock(PriceModifier::class);
$this->repositoryMock->expects($this->any())->method('get')->with('product_sku')
->will($this->returnValue($this->productMock));
$this->groupManagementMock =
- $this->createMock(\Magento\Customer\Api\GroupManagementInterface::class);
+ $this->createMock(GroupManagementInterface::class);
$this->groupRepositoryMock =
- $this->createMock(\Magento\Customer\Api\GroupRepositoryInterface::class);
+ $this->createMock(GroupRepositoryInterface::class);
$this->service = new TierPriceManagement(
$this->repositoryMock,
@@ -111,7 +126,7 @@ protected function setUp()
*/
public function testGetList($configValue, $customerGroupId, $groupData, $expected)
{
- $group = $this->createMock(\Magento\Customer\Model\Data\Group::class);
+ $group = $this->createMock(Group::class);
$group->expects($this->any())->method('getId')->willReturn(GroupManagement::CUST_GROUP_ALL);
$this->groupManagementMock->expects($this->any())->method('getAllCustomersGroup')
->will($this->returnValue($group));
@@ -125,10 +140,10 @@ public function testGetList($configValue, $customerGroupId, $groupData, $expecte
$this->configMock
->expects($this->once())
->method('getValue')
- ->with('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE)
+ ->with('catalog/price/scope', ScopeInterface::SCOPE_WEBSITE)
->will($this->returnValue($configValue));
if ($expected) {
- $priceMock = $this->createMock(\Magento\Catalog\Api\Data\ProductTierPriceInterface::class);
+ $priceMock = $this->createMock(ProductTierPriceInterface::class);
$priceMock->expects($this->once())
->method('setValue')
->with($expected['value'])
@@ -186,19 +201,17 @@ public function testSuccessDeleteTierPrice()
$this->configMock
->expects($this->once())
->method('getValue')
- ->with('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE)
+ ->with('catalog/price/scope', ScopeInterface::SCOPE_WEBSITE)
->will($this->returnValue(0));
$this->priceModifierMock->expects($this->once())->method('removeTierPrice')->with($this->productMock, 4, 5, 0);
$this->assertEquals(true, $this->service->remove('product_sku', 4, 5, 0));
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage No such entity.
- */
public function testDeleteTierPriceFromNonExistingProduct()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage('No such entity.');
$this->repositoryMock->expects($this->once())->method('get')
->will($this->throwException(new NoSuchEntityException()));
$this->priceModifierMock->expects($this->never())->method('removeTierPrice');
@@ -218,7 +231,7 @@ public function testSuccessDeleteTierPriceFromWebsiteLevel()
$this->configMock
->expects($this->once())
->method('getValue')
- ->with('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE)
+ ->with('catalog/price/scope', ScopeInterface::SCOPE_WEBSITE)
->will($this->returnValue(1));
$this->priceModifierMock->expects($this->once())->method('removeTierPrice')->with($this->productMock, 4, 5, 1);
@@ -227,7 +240,7 @@ public function testSuccessDeleteTierPriceFromWebsiteLevel()
public function testSetNewPriceWithGlobalPriceScopeAll()
{
- $websiteMock = $this->getMockBuilder(\Magento\Store\Model\Website::class)
+ $websiteMock = $this->getMockBuilder(Website::class)
->setMethods(['getId', '__wakeup'])
->disableOriginalConstructor()
->getMock();
@@ -247,7 +260,7 @@ public function testSetNewPriceWithGlobalPriceScopeAll()
$this->configMock
->expects($this->once())
->method('getValue')
- ->with('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE)
+ ->with('catalog/price/scope', ScopeInterface::SCOPE_WEBSITE)
->will($this->returnValue(1));
$this->productMock->expects($this->once())->method('setData')->with(
@@ -264,7 +277,7 @@ public function testSetNewPriceWithGlobalPriceScopeAll()
]
);
$this->repositoryMock->expects($this->once())->method('save')->with($this->productMock);
- $group = $this->createMock(\Magento\Customer\Model\Data\Group::class);
+ $group = $this->createMock(Group::class);
$group->expects($this->once())->method('getId')->willReturn(GroupManagement::CUST_GROUP_ALL);
$this->groupManagementMock->expects($this->once())->method('getAllCustomersGroup')
->will($this->returnValue($group));
@@ -273,7 +286,7 @@ public function testSetNewPriceWithGlobalPriceScopeAll()
public function testSetNewPriceWithGlobalPriceScope()
{
- $group = $this->createMock(\Magento\Customer\Model\Data\Group::class);
+ $group = $this->createMock(Group::class);
$group->expects($this->once())->method('getId')->will($this->returnValue(1));
$this->groupRepositoryMock->expects($this->once())->method('getById')->will($this->returnValue($group));
$this->productMock
@@ -288,7 +301,7 @@ public function testSetNewPriceWithGlobalPriceScope()
$this->configMock
->expects($this->once())
->method('getValue')
- ->with('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE)
+ ->with('catalog/price/scope', ScopeInterface::SCOPE_WEBSITE)
->will($this->returnValue(0));
$this->productMock->expects($this->once())->method('setData')->with(
@@ -316,7 +329,7 @@ public function testSetUpdatedPriceWithGlobalPriceScope()
$this->configMock
->expects($this->once())
->method('getValue')
- ->with('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE)
+ ->with('catalog/price/scope', ScopeInterface::SCOPE_WEBSITE)
->will($this->returnValue(0));
$this->productMock->expects($this->once())->method('setData')->with(
@@ -329,13 +342,13 @@ public function testSetUpdatedPriceWithGlobalPriceScope()
$this->service->add('product_sku', 1, 100, 3);
}
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Values in the attr1, attr2 attributes are invalid. Verify the values and try again.
- */
public function testSetThrowsExceptionIfDoesntValidate()
{
- $group = $this->createMock(\Magento\Customer\Model\Data\Group::class);
+ $this->expectException('Magento\Framework\Exception\InputException');
+ $this->expectExceptionMessage(
+ 'Values in the attr1, attr2 attributes are invalid. Verify the values and try again.'
+ );
+ $group = $this->createMock(Group::class);
$group->expects($this->once())->method('getId')->will($this->returnValue(1));
$this->productMock
->expects($this->once())
@@ -353,12 +366,10 @@ public function testSetThrowsExceptionIfDoesntValidate()
$this->service->add('product_sku', 1, 100, 2);
}
- /**
- * @expectedException \Magento\Framework\Exception\CouldNotSaveException
- */
public function testSetThrowsExceptionIfCantSave()
{
- $group = $this->createMock(\Magento\Customer\Model\Data\Group::class);
+ $this->expectException('Magento\Framework\Exception\CouldNotSaveException');
+ $group = $this->createMock(Group::class);
$group->expects($this->once())->method('getId')->will($this->returnValue(1));
$this->productMock
->expects($this->once())
@@ -371,12 +382,10 @@ public function testSetThrowsExceptionIfCantSave()
$this->service->add('product_sku', 1, 100, 2);
}
- /**
- * @expectedException \Magento\Framework\Exception\TemporaryState\CouldNotSaveException
- */
public function testAddRethrowsTemporaryStateExceptionIfRecoverableErrorOccurred()
{
- $group = $this->createMock(\Magento\Customer\Model\Data\Group::class);
+ $this->expectException('Magento\Framework\Exception\TemporaryState\CouldNotSaveException');
+ $group = $this->createMock(Group::class);
$group->expects($this->once())
->method('getId')
->willReturn(1);
@@ -398,11 +407,11 @@ public function testAddRethrowsTemporaryStateExceptionIfRecoverableErrorOccurred
/**
* @param string|int $price
* @param string|float $qty
- * @expectedException \Magento\Framework\Exception\InputException
* @dataProvider addDataProvider
*/
public function testAddWithInvalidData($price, $qty)
{
+ $this->expectException('Magento\Framework\Exception\InputException');
$this->service->add('product_sku', 1, $price, $qty);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/AbstractTypeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/AbstractTypeTest.php
index b34375256a959..c5eb1b7cca69e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/AbstractTypeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/AbstractTypeTest.php
@@ -3,12 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Type;
+use Magento\Catalog\Model\Entity\Attribute;
+use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Attribute\Source\Status;
+use Magento\Catalog\Model\Product\Type\Simple;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class AbstractTypeTest extends \PHPUnit\Framework\TestCase
+class AbstractTypeTest extends TestCase
{
/**
* @var ObjectManager
@@ -16,31 +23,31 @@ class AbstractTypeTest extends \PHPUnit\Framework\TestCase
private $objectManagerHelper;
/**
- * @var \Magento\Catalog\Model\Product\Type\Simple|\PHPUnit_Framework_MockObject_MockObject
+ * @var Simple|MockObject
*/
private $model;
/**
- * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
private $product;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Model\ResourceModel\Product|MockObject
*/
private $productResource;
/**
- * @var \Magento\Catalog\Model\Entity\Attribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var Attribute|MockObject
*/
private $attribute;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper = new ObjectManager($this);
- $this->model = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product\Type\Simple::class);
+ $this->model = $this->objectManagerHelper->getObject(Simple::class);
- $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $this->product = $this->getMockBuilder(Product::class)
->setMethods(['getHasOptions', '__wakeup', '__sleep', 'getResource', 'getStatus'])
->disableOriginalConstructor()
->getMock();
@@ -51,7 +58,7 @@ protected function setUp()
$this->product->expects($this->any())->method('getResource')->will($this->returnValue($this->productResource));
- $this->attribute = $this->getMockBuilder(\Magento\Catalog\Model\Entity\Attribute::class)
+ $this->attribute = $this->getMockBuilder(Attribute::class)
->setMethods(['getGroupSortPath', 'getSortPath', '__wakeup'])
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php
index cdbef1bec3872..dc11b7ea9da09 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php
@@ -3,20 +3,30 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Type;
use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory;
use Magento\Catalog\Api\Data\ProductTierPriceExtensionInterface;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\TierPrice;
+use Magento\Catalog\Model\Product\Type\Price;
+use Magento\Customer\Api\GroupManagementInterface;
+use Magento\Customer\Model\Data\Group;
use Magento\Customer\Model\GroupManagement;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Store\Model\Website;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Price Test
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class PriceTest extends \PHPUnit\Framework\TestCase
+class PriceTest extends TestCase
{
const KEY_TIER_PRICE = 'tier_price';
const PRICE_SCOPE_GLOBAL = 0;
@@ -33,45 +43,45 @@ class PriceTest extends \PHPUnit\Framework\TestCase
protected $objectManagerHelper;
/**
- * @var \Magento\Catalog\Model\Product
+ * @var Product
*/
protected $product;
/**
- * @var \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductTierPriceInterfaceFactory|MockObject
*/
protected $tpFactory;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $scopeConfigMock;
/**
- * @var \Magento\Customer\Api\GroupManagementInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupManagementInterface|MockObject
*/
protected $groupManagementMock;
/**
- * @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject
+ * @var Website|MockObject
*/
protected $websiteMock;
private $tierPriceExtensionFactoryMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
- $this->product = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product::class);
+ $this->product = $this->objectManagerHelper->getObject(Product::class);
$this->tpFactory = $this->createPartialMock(
- \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory::class,
+ ProductTierPriceInterfaceFactory::class,
['create']
);
- $this->websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, ['getId']);
+ $this->websiteMock = $this->createPartialMock(Website::class, ['getId']);
$storeMangerMock = $this->getMockForAbstractClass(
- \Magento\Store\Model\StoreManagerInterface::class,
+ StoreManagerInterface::class,
[],
'',
false,
@@ -84,7 +94,7 @@ protected function setUp()
->will($this->returnValue($this->websiteMock));
$this->scopeConfigMock = $this->getMockForAbstractClass(
- \Magento\Framework\App\Config\ScopeConfigInterface::class,
+ ScopeConfigInterface::class,
[],
'',
false,
@@ -93,10 +103,10 @@ protected function setUp()
['getValue']
);
- $group = $this->createMock(\Magento\Customer\Model\Data\Group::class);
+ $group = $this->createMock(Group::class);
$group->expects($this->any())->method('getId')->willReturn(GroupManagement::CUST_GROUP_ALL);
$this->groupManagementMock =
- $this->createMock(\Magento\Customer\Api\GroupManagementInterface::class);
+ $this->createMock(GroupManagementInterface::class);
$this->groupManagementMock->expects($this->any())->method('getAllCustomersGroup')
->will($this->returnValue($group));
$this->tierPriceExtensionFactoryMock = $this->getMockBuilder(ProductTierPriceExtensionFactory::class)
@@ -104,7 +114,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
$this->model = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Model\Product\Type\Price::class,
+ Price::class,
[
'tierPriceFactory' => $this->tpFactory,
'config' => $this->scopeConfigMock,
@@ -168,7 +178,7 @@ public function testTierPrices($priceScope, $expectedWebsiteId)
->will(
$this->returnCallback(
function () {
- return $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product\TierPrice::class);
+ return $this->objectManagerHelper->getObject(TierPrice::class);
}
)
);
@@ -179,12 +189,12 @@ function () {
->getMock();
$tierPriceExtensionMock->expects($this->any())->method('getWebsiteId')->willReturn($expectedWebsiteId);
$tierPriceExtensionMock->expects($this->any())->method('getPercentageValue')->willReturn(null);
- $tp1 = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product\TierPrice::class);
+ $tp1 = $this->objectManagerHelper->getObject(TierPrice::class);
$tp1->setValue(10);
$tp1->setCustomerGroupId(1);
$tp1->setQty(11);
$tp1->setExtensionAttributes($tierPriceExtensionMock);
- $tp2 = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\Product\TierPrice::class);
+ $tp2 = $this->objectManagerHelper->getObject(TierPrice::class);
$tp2->setValue(20);
$tp2->setCustomerGroupId(2);
$tp2->setQty(22);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/SimpleTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/SimpleTest.php
index 826db1e6d4e69..f457d158d73f5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/SimpleTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/SimpleTest.php
@@ -3,28 +3,40 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Type;
-class SimpleTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product\Type\Simple;
+use Magento\Catalog\Model\ProductFactory;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\Filesystem;
+use Magento\Framework\Registry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\MediaStorage\Helper\File\Storage\Database;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
+
+class SimpleTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Type\Simple
+ * @var Simple
*/
protected $_model;
- protected function setUp()
+ protected function setUp(): void
{
- $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->getMockBuilder(\Magento\Framework\Filesystem::class)
+ $objectHelper = new ObjectManager($this);
+ $eventManager = $this->createMock(ManagerInterface::class);
+ $fileStorageDbMock = $this->createMock(Database::class);
+ $filesystem = $this->getMockBuilder(Filesystem::class)
->disableOriginalConstructor()
->getMock();
- $coreRegistry = $this->createMock(\Magento\Framework\Registry::class);
- $logger = $this->createMock(\Psr\Log\LoggerInterface::class);
- $productFactoryMock = $this->createMock(\Magento\Catalog\Model\ProductFactory::class);
+ $coreRegistry = $this->createMock(Registry::class);
+ $logger = $this->createMock(LoggerInterface::class);
+ $productFactoryMock = $this->createMock(ProductFactory::class);
$this->_model = $objectHelper->getObject(
- \Magento\Catalog\Model\Product\Type\Simple::class,
+ Simple::class,
[
'productFactory' => $productFactoryMock,
'eventManager' => $eventManager,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/VirtualTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/VirtualTest.php
index 8bcbed061c954..bf9dedfd13246 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/VirtualTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/VirtualTest.php
@@ -3,28 +3,40 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product\Type;
-class VirtualTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product\Type\Virtual;
+use Magento\Catalog\Model\ProductFactory;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\Filesystem;
+use Magento\Framework\Registry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\MediaStorage\Helper\File\Storage\Database;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
+
+class VirtualTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Type\Virtual
+ * @var Virtual
*/
protected $_model;
- protected function setUp()
+ protected function setUp(): void
{
- $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $eventManager = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
- $coreRegistryMock = $this->createMock(\Magento\Framework\Registry::class);
- $fileStorageDbMock = $this->createMock(\Magento\MediaStorage\Helper\File\Storage\Database::class);
- $filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class)
+ $objectHelper = new ObjectManager($this);
+ $eventManager = $this->createMock(ManagerInterface::class);
+ $coreRegistryMock = $this->createMock(Registry::class);
+ $fileStorageDbMock = $this->createMock(Database::class);
+ $filesystem = $this->getMockBuilder(Filesystem::class)
->disableOriginalConstructor()
->getMock();
- $logger = $this->createMock(\Psr\Log\LoggerInterface::class);
- $productFactoryMock = $this->createMock(\Magento\Catalog\Model\ProductFactory::class);
+ $logger = $this->createMock(LoggerInterface::class);
+ $productFactoryMock = $this->createMock(ProductFactory::class);
$this->_model = $objectHelper->getObject(
- \Magento\Catalog\Model\Product\Type\Virtual::class,
+ Virtual::class,
[
'eventManager' => $eventManager,
'fileStorageDb' => $fileStorageDbMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTest.php
index 8b8ea95baf3b0..3cebbcba24589 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTest.php
@@ -3,17 +3,29 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Type;
+use Magento\Catalog\Model\Product\Type\Pool;
+use Magento\Catalog\Model\Product\Type\Price;
+use Magento\Catalog\Model\Product\Type\Simple;
+use Magento\Catalog\Model\Product\Type\Virtual;
+use Magento\Catalog\Model\ProductTypes\ConfigInterface;
+use Magento\Framework\Pricing\PriceInfo\Factory;
+use Magento\Framework\Pricing\PriceInfoInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
/**
- * ProductType Test
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class TypeTest extends \PHPUnit\Framework\TestCase
+class TypeTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $_objectHelper;
@@ -35,7 +47,7 @@ class TypeTest extends \PHPUnit\Framework\TestCase
];
/**
- * @var \Magento\Catalog\Model\Product\Type
+ * @var Type
*/
protected $_model;
@@ -114,7 +126,7 @@ public function testGetTypesByPriority()
public function testGetPriceInfo()
{
$mockedProduct = $this->getMockedProduct();
- $expectedResult = \Magento\Framework\Pricing\PriceInfoInterface::class;
+ $expectedResult = PriceInfoInterface::class;
$this->assertInstanceOf($expectedResult, $this->_model->getPriceInfo($mockedProduct));
}
@@ -130,11 +142,11 @@ public function testFactory()
->will($this->returnValue('type_id_3'));
$this->assertInstanceOf(
- \Magento\Catalog\Model\Product\Type\Simple::class,
+ Simple::class,
$this->_model->factory($mockedProduct)
);
$this->assertInstanceOf(
- \Magento\Catalog\Model\Product\Type\Virtual::class,
+ Virtual::class,
$this->_model->factory($mockedProduct)
);
}
@@ -142,21 +154,21 @@ public function testFactory()
public function testPriceFactory()
{
$this->assertInstanceOf(
- \Magento\Catalog\Model\Product\Type\Price::class,
+ Price::class,
$this->_model->priceFactory('type_id_1')
);
}
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->_objectHelper = new ObjectManager($this);
$mockedPriceInfoFactory = $this->getMockedPriceInfoFactory();
$mockedProductTypePool = $this->getMockedProductTypePool();
$mockedConfig = $this->getMockedConfig();
$mockedTypePriceFactory = $this->getMockedTypePriceFactory();
$this->_model = $this->_objectHelper->getObject(
- \Magento\Catalog\Model\Product\Type::class,
+ Type::class,
[
'config' => $mockedConfig,
'priceInfoFactory' => $mockedPriceInfoFactory,
@@ -183,7 +195,7 @@ protected function getOptionArray()
*/
private function getMockedProduct()
{
- $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $mockBuilder = $this->getMockBuilder(Product::class)
->disableOriginalConstructor();
$mock = $mockBuilder->getMock();
@@ -191,13 +203,13 @@ private function getMockedProduct()
}
/**
- * @return \Magento\Framework\Pricing\PriceInfo\Factory
+ * @return Factory
*/
private function getMockedPriceInfoFactory()
{
$mockedPriceInfoInterface = $this->getMockedPriceInfoInterface();
- $mockBuilder = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Factory::class)
+ $mockBuilder = $this->getMockBuilder(Factory::class)
->disableOriginalConstructor()
->setMethods(['create']);
$mock = $mockBuilder->getMock();
@@ -214,7 +226,7 @@ private function getMockedPriceInfoFactory()
*/
private function getMockedPriceInfoInterface()
{
- $mockBuilder = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfoInterface::class)
+ $mockBuilder = $this->getMockBuilder(PriceInfoInterface::class)
->disableOriginalConstructor();
$mock = $mockBuilder->getMockForAbstractClass();
@@ -222,11 +234,11 @@ private function getMockedPriceInfoInterface()
}
/**
- * @return \Magento\Catalog\Model\Product\Type\Pool
+ * @return Pool
*/
private function getMockedProductTypePool()
{
- $mockBuild = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Pool::class)
+ $mockBuild = $this->getMockBuilder(Pool::class)
->disableOriginalConstructor()
->setMethods(['get']);
$mock = $mockBuild->getMock();
@@ -237,7 +249,7 @@ private function getMockedProductTypePool()
$this->returnValueMap(
[
['some_model', [], $this->getMockedProductTypeVirtual()],
- [\Magento\Catalog\Model\Product\Type\Simple::class, [], $this->getMockedProductTypeSimple()],
+ [Simple::class, [], $this->getMockedProductTypeSimple()],
]
)
);
@@ -246,11 +258,11 @@ private function getMockedProductTypePool()
}
/**
- * @return \Magento\Catalog\Model\Product\Type\Virtual
+ * @return Virtual
*/
private function getMockedProductTypeVirtual()
{
- $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Virtual::class)
+ $mockBuilder = $this->getMockBuilder(Virtual::class)
->disableOriginalConstructor()
->setMethods(['setConfig']);
$mock = $mockBuilder->getMock();
@@ -262,11 +274,11 @@ private function getMockedProductTypeVirtual()
}
/**
- * @return \Magento\Catalog\Model\Product\Type\Simple
+ * @return Simple
*/
private function getMockedProductTypeSimple()
{
- $mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Simple::class)
+ $mockBuilder = $this->getMockBuilder(Simple::class)
->disableOriginalConstructor()
->setMethods(['setConfig']);
$mock = $mockBuilder->getMock();
@@ -278,11 +290,11 @@ private function getMockedProductTypeSimple()
}
/**
- * @return \Magento\Catalog\Model\ProductTypes\ConfigInterface
+ * @return ConfigInterface
*/
private function getMockedConfig()
{
- $mockBuild = $this->getMockBuilder(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class)
+ $mockBuild = $this->getMockBuilder(ConfigInterface::class)
->disableOriginalConstructor()
->setMethods(['getAll']);
$mock = $mockBuild->getMockForAbstractClass();
@@ -310,7 +322,7 @@ private function getMockedTypePriceFactory()
$this->returnValueMap(
[
['some_model', [], $this->getMockedProductTypePrice()],
- [\Magento\Catalog\Model\Product\Type\Price::class, [], $this->getMockedProductTypePrice()],
+ [Price::class, [], $this->getMockedProductTypePrice()],
]
)
);
@@ -319,11 +331,11 @@ private function getMockedTypePriceFactory()
}
/**
- * @return \Magento\Catalog\Model\Product\Type\Price
+ * @return Price
*/
private function getMockedProductTypePrice()
{
- $mockBuild = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Price::class)
+ $mockBuild = $this->getMockBuilder(Price::class)
->disableOriginalConstructor();
$mock = $mockBuild->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTransitionManagerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTransitionManagerTest.php
index d6547d8ebe4ea..844f1b234c693 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTransitionManagerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTransitionManagerTest.php
@@ -3,40 +3,50 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product;
-class TypeTransitionManagerTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Edit\WeightResolver;
+use Magento\Catalog\Model\Product\Type;
+use Magento\Catalog\Model\Product\TypeTransitionManager;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class TypeTransitionManagerTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\TypeTransitionManager
+ * @var TypeTransitionManager
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $weightResolver;
- protected function setUp()
+ protected function setUp(): void
{
$this->productMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
['getTypeId', 'setTypeId', 'setTypeInstance']
);
- $this->weightResolver = $this->createMock(\Magento\Catalog\Model\Product\Edit\WeightResolver::class);
- $this->model = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))
+ $this->weightResolver = $this->createMock(WeightResolver::class);
+ $this->model = (new ObjectManager($this))
->getObject(
- \Magento\Catalog\Model\Product\TypeTransitionManager::class,
+ TypeTransitionManager::class,
[
'weightResolver' => $this->weightResolver,
'compatibleTypes' => [
- 'simple' => \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE,
- 'virtual' => \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL,
+ 'simple' => Type::TYPE_SIMPLE,
+ 'virtual' => Type::TYPE_VIRTUAL,
]
]
);
@@ -75,23 +85,23 @@ public function processProductDataProvider()
return [
[
true,
- \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL,
- \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE,
+ Type::TYPE_VIRTUAL,
+ Type::TYPE_SIMPLE,
],
[
true,
- \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE,
- \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE,
+ Type::TYPE_SIMPLE,
+ Type::TYPE_SIMPLE,
],
[
false,
- \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE,
- \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL,
+ Type::TYPE_SIMPLE,
+ Type::TYPE_VIRTUAL,
],
[
false,
- \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL,
- \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL,
+ Type::TYPE_VIRTUAL,
+ Type::TYPE_VIRTUAL,
]
];
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php
index c7b6402cd3877..70bf1b88cbc44 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php
@@ -3,11 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Catalog\Test\Unit\Model\Product;
+declare(strict_types=1);
-use \Magento\Catalog\Model\Product\Url;
+namespace Magento\Catalog\Test\Unit\Model\Product;
-class UrlTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Helper\Category;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Url;
+use Magento\Catalog\Model\Product\Url as ProductUrl;
+use Magento\Framework\Filter\FilterManager;
+use Magento\Framework\Session\SidResolverInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\UrlFactory;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\UrlRewrite\Model\UrlFinderInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class UrlTest extends TestCase
{
/**
* @var Url
@@ -15,40 +29,40 @@ class UrlTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var \Magento\Framework\Filter\FilterManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var FilterManager|MockObject
*/
protected $filter;
/**
- * @var \Magento\UrlRewrite\Model\UrlFinderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlFinderInterface|MockObject
*/
protected $urlFinder;
/**
- * @var \Magento\Catalog\Helper\Category|\PHPUnit_Framework_MockObject_MockObject
+ * @var Category|MockObject
*/
protected $catalogCategory;
/**
- * @var \Magento\Framework\Url|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\Url|MockObject
*/
protected $url;
/**
- * @var \Magento\Framework\Session\SidResolverInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var SidResolverInterface|MockObject
*/
protected $sidResolver;
- protected function setUp()
+ protected function setUp(): void
{
$this->filter = $this->getMockBuilder(
- \Magento\Framework\Filter\FilterManager::class
+ FilterManager::class
)->disableOriginalConstructor()->setMethods(
['translitUrl']
)->getMock();
$this->urlFinder = $this->getMockBuilder(
- \Magento\UrlRewrite\Model\UrlFinderInterface::class
+ UrlFinderInterface::class
)->disableOriginalConstructor()->getMock();
$this->url = $this->getMockBuilder(
@@ -57,22 +71,22 @@ protected function setUp()
['setScope', 'getUrl']
)->getMock();
- $this->sidResolver = $this->createMock(\Magento\Framework\Session\SidResolverInterface::class);
+ $this->sidResolver = $this->createMock(SidResolverInterface::class);
- $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getId', '__wakeup']);
+ $store = $this->createPartialMock(Store::class, ['getId', '__wakeup']);
$store->expects($this->any())->method('getId')->will($this->returnValue(1));
- $storeManager = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class);
+ $storeManager = $this->getMockForAbstractClass(StoreManagerInterface::class);
$storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
- $urlFactory = $this->getMockBuilder(\Magento\Framework\UrlFactory::class)
+ $urlFactory = $this->getMockBuilder(UrlFactory::class)
->disableOriginalConstructor()
->getMock();
$urlFactory->method('create')
->willReturn($this->url);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Url::class,
+ ProductUrl::class,
[
'filter' => $this->filter,
'catalogCategory' => $this->catalogCategory,
@@ -130,7 +144,7 @@ public function testGetUrl(
$productUrlKey
) {
$product = $this->getMockBuilder(
- \Magento\Catalog\Model\Product::class
+ Product::class
)->disableOriginalConstructor()->setMethods(
['getStoreId', 'getEntityId', 'getId', 'getUrlKey', 'setRequestPath', 'hasUrlDataObject', 'getRequestPath',
'getCategoryId', 'getDoNotUseCategoryId', '__wakeup', ]
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ValidatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ValidatorTest.php
index e7032d8b3711e..6c66935b4c833 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ValidatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ValidatorTest.php
@@ -3,16 +3,24 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product;
-class ValidatorTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Validator;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\DataObject;
+use PHPUnit\Framework\TestCase;
+
+class ValidatorTest extends TestCase
{
public function testValidator()
{
- $validator = new \Magento\Catalog\Model\Product\Validator();
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class);
- $responseMock = $this->createMock(\Magento\Framework\DataObject::class);
+ $validator = new Validator();
+ $productMock = $this->createMock(Product::class);
+ $requestMock = $this->createMock(RequestInterface::class);
+ $responseMock = $this->createMock(DataObject::class);
$productMock->expects($this->once())->method('validate')->will($this->returnValue(true));
$this->assertEquals(true, $validator->validate($productMock, $requestMock, $responseMock));
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/VisibilityTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/VisibilityTest.php
index ee7e9e8a1096d..5ecf65815bd02 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/VisibilityTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/VisibilityTest.php
@@ -3,27 +3,32 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Product;
+use Magento\Catalog\Model\Product\Visibility;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class VisibilityTest extends \PHPUnit\Framework\TestCase
+class VisibilityTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Product\Visibility
+ * @var Visibility
*/
protected $_model;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
- $this->_model = $objectManager->getObject(\Magento\Catalog\Model\Product\Visibility::class);
+ $this->_model = $objectManager->getObject(Visibility::class);
}
public function testGetFlatColumns()
{
$abstractAttributeMock = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
+ AbstractAttribute::class,
['getAttributeCode', '__wakeup']
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Webapi/ProductOutputProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Webapi/ProductOutputProcessorTest.php
index fa419d23626ae..2645453c4ae03 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Webapi/ProductOutputProcessorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Webapi/ProductOutputProcessorTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Webapi;
@@ -10,8 +11,9 @@
use Magento\Catalog\Model\Product\Webapi\ProductOutputProcessor;
use Magento\Framework\Webapi\Request;
use Magento\Framework\Webapi\Rest\Request\DeserializerInterface;
+use PHPUnit\Framework\TestCase;
-class ProductOutputProcessorTest extends \PHPUnit\Framework\TestCase
+class ProductOutputProcessorTest extends TestCase
{
/**
* @var Request
@@ -28,7 +30,7 @@ class ProductOutputProcessorTest extends \PHPUnit\Framework\TestCase
*/
private $productOutputProcessor;
- protected function setUp()
+ protected function setUp(): void
{
$this->requestMock = $this->createPartialMock(
Request::class,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/ReadHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/ReadHandlerTest.php
index b2ee8180cd8b5..40742b69be910 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/ReadHandlerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/ReadHandlerTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Website;
@@ -10,9 +11,11 @@
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Website\ReadHandler;
use Magento\Catalog\Model\ResourceModel\Product as ResourceModel;
+use Magento\Catalog\Model\ResourceModel\Product\Website\Link;
use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ReadHandlerTest extends \PHPUnit\Framework\TestCase
+class ReadHandlerTest extends TestCase
{
/** @var ResourceModel\Website\Link|MockObject */
private $websiteLinkMock;
@@ -23,9 +26,9 @@ class ReadHandlerTest extends \PHPUnit\Framework\TestCase
/** @var ReadHandler */
private $readHandler;
- public function setUp()
+ public function setUp(): void
{
- $this->websiteLinkMock = $this->getMockBuilder(ResourceModel\Website\Link::class)
+ $this->websiteLinkMock = $this->getMockBuilder(Link::class)
->disableOriginalConstructor()
->getMock();
$this->extensionAttributesMock = $this->getMockBuilder(ProductExtensionInterface::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/SaveHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/SaveHandlerTest.php
index 392f01a62b3ee..e1f97d9ef4722 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/SaveHandlerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/SaveHandlerTest.php
@@ -3,21 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\Product\Website;
-use Magento\Catalog\Api\Data\ProductExtensionInterface;
use Magento\Catalog\Api\Data\ProductInterface;
-use Magento\Catalog\Model\ResourceModel\Product\Website\Link;
use Magento\Catalog\Model\Product\Website\SaveHandler;
-use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Product as ResourceModel;
+use Magento\Catalog\Model\ResourceModel\Product\Website\Link;
use Magento\Framework\Api\ExtensionAttributesInterface;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\StoreManagerInterface;
use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SaveHandlerTest extends \PHPUnit\Framework\TestCase
+class SaveHandlerTest extends TestCase
{
/** @var ResourceModel\Website\Link|MockObject */
private $productWebsiteLink;
@@ -31,7 +31,7 @@ class SaveHandlerTest extends \PHPUnit\Framework\TestCase
/** @var ProductInterface|MockObject */
private $product;
- public function setUp()
+ public function setUp(): void
{
$this->productWebsiteLink = $this->getMockBuilder(Link::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductAttributeGroupRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductAttributeGroupRepositoryTest.php
index 5c3e9a429317c..04774126d35ba 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductAttributeGroupRepositoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductAttributeGroupRepositoryTest.php
@@ -3,46 +3,57 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model;
-class ProductAttributeGroupRepositoryTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product\Attribute\GroupFactory;
+use Magento\Catalog\Model\ProductAttributeGroupRepository;
+use Magento\Eav\Api\AttributeGroupRepositoryInterface;
+use Magento\Eav\Api\Data\AttributeGroupInterface;
+use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group;
+use Magento\Framework\Api\SearchCriteriaInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ProductAttributeGroupRepositoryTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ProductAttributeGroupRepository
+ * @var ProductAttributeGroupRepository
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $groupRepositoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $groupFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $groupResourceMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->groupRepositoryMock = $this->createMock(\Magento\Eav\Api\AttributeGroupRepositoryInterface::class);
+ $this->groupRepositoryMock = $this->createMock(AttributeGroupRepositoryInterface::class);
$this->groupFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Attribute\GroupFactory::class,
+ GroupFactory::class,
['create']
);
$this->groupResourceMock = $this->createPartialMock(
- \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group::class,
+ Group::class,
['load', '__wakeup']
);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\ProductAttributeGroupRepository::class,
+ ProductAttributeGroupRepository::class,
[
'groupRepository' => $this->groupRepositoryMock,
'groupResource' => $this->groupResourceMock,
@@ -53,8 +64,8 @@ protected function setUp()
public function testSave()
{
- $groupMock = $this->createMock(\Magento\Eav\Api\Data\AttributeGroupInterface::class);
- $expectedResult = $this->createMock(\Magento\Eav\Api\Data\AttributeGroupInterface::class);
+ $groupMock = $this->createMock(AttributeGroupInterface::class);
+ $expectedResult = $this->createMock(AttributeGroupInterface::class);
$this->groupRepositoryMock->expects($this->once())->method('save')->with($groupMock)
->willReturn($expectedResult);
$this->assertEquals($expectedResult, $this->model->save($groupMock));
@@ -62,8 +73,8 @@ public function testSave()
public function testGetList()
{
- $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteriaInterface::class);
- $expectedResult = $this->createMock(\Magento\Eav\Api\Data\AttributeGroupInterface::class);
+ $searchCriteriaMock = $this->createMock(SearchCriteriaInterface::class);
+ $expectedResult = $this->createMock(AttributeGroupInterface::class);
$this->groupRepositoryMock->expects($this->once())->method('getList')->with($searchCriteriaMock)
->willReturn($expectedResult);
$this->assertEquals($expectedResult, $this->model->getList($searchCriteriaMock));
@@ -79,11 +90,9 @@ public function testGet()
$this->assertEquals($groupMock, $this->model->get($groupId));
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- */
public function testGetThrowsExceptionIfGroupDoesNotExist()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
$groupId = 42;
$groupMock = $this->createMock(\Magento\Catalog\Model\Product\Attribute\Group::class);
$this->groupFactoryMock->expects($this->once())->method('create')->willReturn($groupMock);
@@ -120,12 +129,10 @@ public function testDelete()
$this->assertTrue($this->model->delete($groupMock));
}
- /**
- * @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage The attribute group can't be deleted because it contains system attributes.
- */
public function testDeleteThrowsExceptionIfGroupHasSystemAttributes()
{
+ $this->expectException('Magento\Framework\Exception\StateException');
+ $this->expectExceptionMessage('The attribute group can\'t be deleted because it contains system attributes.');
$groupMock = $this->createPartialMock(
\Magento\Catalog\Model\Product\Attribute\Group::class,
['hasSystemAttributes']
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductIdLocatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductIdLocatorTest.php
index b9cb82274c808..25337e20376dd 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductIdLocatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductIdLocatorTest.php
@@ -3,26 +3,37 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model;
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Model\ProductIdLocator;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use Magento\Framework\EntityManager\EntityMetadataInterface;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* Unit test for ProductIdLocator class.
*/
-class ProductIdLocatorTest extends \PHPUnit\Framework\TestCase
+class ProductIdLocatorTest extends TestCase
{
/**
- * @var \Magento\Framework\EntityManager\MetadataPool|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataPool|MockObject
*/
private $metadataPool;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
private $collectionFactory;
/**
- * @var \Magento\Catalog\Model\ProductIdLocator
+ * @var ProductIdLocator
*/
private $model;
@@ -31,19 +42,19 @@ class ProductIdLocatorTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->metadataPool = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class)
+ $this->metadataPool = $this->getMockBuilder(MetadataPool::class)
->setMethods(['getMetadata'])
->disableOriginalConstructor()->getMock();
$this->collectionFactory = $this
- ->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class)
+ ->getMockBuilder(CollectionFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()->getMock();
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\ProductIdLocator::class,
+ ProductIdLocator::class,
[
'metadataPool' => $this->metadataPool,
'collectionFactory' => $this->collectionFactory,
@@ -57,7 +68,7 @@ protected function setUp()
public function testRetrieveProductIdsBySkus()
{
$skus = ['sku_1', 'sku_2'];
- $collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class)
+ $collection = $this->getMockBuilder(Collection::class)
->setMethods(
[
'getItems',
@@ -69,15 +80,15 @@ public function testRetrieveProductIdsBySkus()
]
)
->disableOriginalConstructor()->getMock();
- $product = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)
+ $product = $this->getMockBuilder(ProductInterface::class)
->setMethods(['getSku', 'getData', 'getTypeId'])
->disableOriginalConstructor()->getMockForAbstractClass();
- $metaDataInterface = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadataInterface::class)
+ $metaDataInterface = $this->getMockBuilder(EntityMetadataInterface::class)
->setMethods(['getLinkField'])
->disableOriginalConstructor()->getMockForAbstractClass();
$this->collectionFactory->expects($this->once())->method('create')->willReturn($collection);
$collection->expects($this->once())->method('addFieldToFilter')
- ->with(\Magento\Catalog\Api\Data\ProductInterface::SKU, ['in' => $skus])->willReturnSelf();
+ ->with(ProductInterface::SKU, ['in' => $skus])->willReturnSelf();
$collection->expects($this->atLeastOnce())->method('getItems')->willReturn([$product]);
$collection->expects($this->atLeastOnce())->method('setPageSize')->willReturnSelf();
$collection->expects($this->atLeastOnce())->method('getLastPageNumber')->willReturn(1);
@@ -86,7 +97,7 @@ public function testRetrieveProductIdsBySkus()
$this->metadataPool
->expects($this->once())
->method('getMetadata')
- ->with(\Magento\Catalog\Api\Data\ProductInterface::class)
+ ->with(ProductInterface::class)
->willReturn($metaDataInterface);
$metaDataInterface->expects($this->once())->method('getLinkField')->willReturn('entity_id');
$product->expects($this->once())->method('getSku')->willReturn('sku_1');
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php
index 69bd7dc059022..bbf29620a4f05 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php
@@ -3,17 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ProductLink;
-use Magento\Framework\Exception\NoSuchEntityException;
-use Magento\Framework\Exception\InputException;
-use Magento\Framework\Exception\CouldNotSaveException;
-use Magento\Catalog\Model\ProductLink\Management;
-use Magento\Catalog\Model\ProductRepository;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\LinkTypeProvider;
use Magento\Catalog\Model\ProductLink\Link;
+use Magento\Catalog\Model\ProductLink\Management;
+use Magento\Catalog\Model\ProductRepository;
+use Magento\Framework\Exception\CouldNotSaveException;
+use Magento\Framework\Exception\InputException;
+use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
@@ -23,7 +24,6 @@
*/
class ManagementTest extends TestCase
{
-
const STUB_PRODUCT_SKU_1 = 'Simple Product 1';
const STUB_PRODUCT_SKU_2 = 'Simple Product 2';
const STUB_PRODUCT_TYPE = 'simple';
@@ -380,7 +380,6 @@ private function getInputRelatedLinkMock(
string $productSku2,
string $typeId
) {
-
$inputRelatedLinkMock = $this->objectManager->getObject(Link::class);
$inputRelatedLinkMock->setProductSku($productSku1);
$inputRelatedLinkMock->setLinkType($linkType);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php
index 88815f562b5fe..6c60412a4d2d3 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php
@@ -3,89 +3,105 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ProductLink;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks;
+use Magento\Catalog\Model\Product\LinkTypeProvider;
+use Magento\Catalog\Model\ProductLink\CollectionProvider;
+use Magento\Catalog\Model\ProductLink\Management;
+use Magento\Catalog\Model\ProductLink\Repository;
+use Magento\Catalog\Model\ProductRepository;
+use Magento\Catalog\Model\ResourceModel\Product\Link;
+use Magento\Framework\EntityManager\EntityMetadata;
+use Magento\Framework\EntityManager\Hydrator;
+use Magento\Framework\EntityManager\HydratorPool;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class RepositoryTest extends \PHPUnit\Framework\TestCase
+class RepositoryTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $metadataPoolMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $hydratorPoolMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $hydratorMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $metadataMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $linkTypeProvider;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $linkResourceMock;
/**
- * @var \Magento\Catalog\Model\ProductLink\Repository
+ * @var Repository
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
-
protected $productRepositoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $entityCollectionProviderMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $linkInitializerMock;
/**
* Test method
*/
- protected function setUp()
+ protected function setUp(): void
{
- $linkManagementMock = $this->createMock(\Magento\Catalog\Model\ProductLink\Management::class);
- $this->productRepositoryMock = $this->createMock(\Magento\Catalog\Model\ProductRepository::class);
+ $linkManagementMock = $this->createMock(Management::class);
+ $this->productRepositoryMock = $this->createMock(ProductRepository::class);
$this->entityCollectionProviderMock = $this->createMock(
- \Magento\Catalog\Model\ProductLink\CollectionProvider::class
+ CollectionProvider::class
);
$this->linkInitializerMock = $this->createMock(
- \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks::class
+ ProductLinks::class
);
- $this->metadataPoolMock = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class);
- $this->hydratorPoolMock = $this->createMock(\Magento\Framework\EntityManager\HydratorPool::class);
- $this->hydratorMock = $this->createPartialMock(\Magento\Framework\EntityManager\Hydrator::class, ['extract']);
- $this->metadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class);
- $this->linkTypeProvider = $this->createMock(\Magento\Catalog\Model\Product\LinkTypeProvider::class);
- $this->linkResourceMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Link::class);
+ $this->metadataPoolMock = $this->createMock(MetadataPool::class);
+ $this->hydratorPoolMock = $this->createMock(HydratorPool::class);
+ $this->hydratorMock = $this->createPartialMock(Hydrator::class, ['extract']);
+ $this->metadataMock = $this->createMock(EntityMetadata::class);
+ $this->linkTypeProvider = $this->createMock(LinkTypeProvider::class);
+ $this->linkResourceMock = $this->createMock(Link::class);
$this->hydratorPoolMock->expects($this->any())->method('getHydrator')->willReturn($this->hydratorMock);
$this->metadataPoolMock->expects($this->any())->method('getMetadata')->willReturn($this->metadataMock);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\ProductLink\Repository::class,
+ Repository::class,
[
'productRepository' => $this->productRepositoryMock,
'entityCollectionProvider' => $this->entityCollectionProviderMock,
@@ -105,9 +121,9 @@ protected function setUp()
public function testSave()
{
$entityMock = $this->createMock(\Magento\Catalog\Model\ProductLink\Link::class);
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $productMock = $this->createMock(Product::class);
- $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $linkedProductMock = $this->createMock(Product::class);
$parentId = 42;
$linkedProductId = 37;
$typeId = 4;
@@ -135,15 +151,13 @@ public function testSave()
$this->assertTrue($this->model->save($entityMock));
}
- /**
- * @expectedException \Magento\Framework\Exception\CouldNotSaveException
- * @expectedExceptionMessage The linked products data is invalid. Verify the data and try again.
- */
public function testSaveWithException()
{
+ $this->expectException('Magento\Framework\Exception\CouldNotSaveException');
+ $this->expectExceptionMessage('The linked products data is invalid. Verify the data and try again.');
$entityMock = $this->createMock(\Magento\Catalog\Model\ProductLink\Link::class);
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $productMock = $this->createMock(Product::class);
+ $linkedProductMock = $this->createMock(Product::class);
$parentId = 42;
$linkedProductId = 37;
$typeId = 4;
@@ -176,8 +190,8 @@ public function testSaveWithException()
public function testDelete()
{
$entityMock = $this->createMock(\Magento\Catalog\Model\ProductLink\Link::class);
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $productMock = $this->createMock(Product::class);
+ $linkedProductMock = $this->createMock(Product::class);
$parentId = 42;
$linkedProductId = 37;
$typeId = 4;
@@ -206,15 +220,13 @@ public function testDelete()
$this->assertTrue($this->model->delete($entityMock));
}
- /**
- * @expectedException \Magento\Framework\Exception\CouldNotSaveException
- * @expectedExceptionMessage The linked products data is invalid. Verify the data and try again.
- */
public function testDeleteWithInvalidDataException()
{
+ $this->expectException('Magento\Framework\Exception\CouldNotSaveException');
+ $this->expectExceptionMessage('The linked products data is invalid. Verify the data and try again.');
$entityMock = $this->createMock(\Magento\Catalog\Model\ProductLink\Link::class);
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $productMock = $this->createMock(Product::class);
+ $linkedProductMock = $this->createMock(Product::class);
$parentId = 42;
$linkedProductId = 37;
$typeId = 4;
@@ -244,15 +256,15 @@ public function testDeleteWithInvalidDataException()
$this->model->delete($entityMock);
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage Product with SKU 'linkedProduct' is not linked to product with SKU 'product'
- */
public function testDeleteWithNoSuchEntityException()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage(
+ 'Product with SKU \'linkedProduct\' is not linked to product with SKU \'product\''
+ );
$entityMock = $this->createMock(\Magento\Catalog\Model\ProductLink\Link::class);
- $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $productMock = $this->createMock(Product::class);
+ $linkedProductMock = $this->createMock(Product::class);
$this->productRepositoryMock->expects($this->exactly(2))->method('get')->will($this->returnValueMap(
[
['product', false, null, false, $productMock],
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductManagementTest.php
index 0cf350572dbaf..97592c14c1cfb 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductManagementTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductManagementTest.php
@@ -3,27 +3,35 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model;
-class ProductManagementTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\ProductManagement;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ProductManagementTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ProductManagement
+ * @var ProductManagement
*/
protected $model;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
protected $productsFactoryMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->productsFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
- $this->model = new \Magento\Catalog\Model\ProductManagement(
+ $this->model = new ProductManagement(
$this->productsFactoryMock
);
}
@@ -31,7 +39,7 @@ protected function setUp()
public function testGetEnabledCount()
{
$statusEnabled = 1;
- $productsMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
+ $productsMock = $this->createMock(Collection::class);
$this->productsFactoryMock
->expects($this->once())
@@ -56,7 +64,7 @@ public function testGetEnabledCount()
public function testGetDisabledCount()
{
$statusDisabled = 2;
- $productsMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
+ $productsMock = $this->createMock(Collection::class);
$this->productsFactoryMock
->expects($this->once())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductOptionProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductOptionProcessorTest.php
index 01065e530cf2f..14ad02b438ecf 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductOptionProcessorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductOptionProcessorTest.php
@@ -3,19 +3,27 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model;
use Magento\Catalog\Api\Data\CustomOptionInterface;
+use Magento\Catalog\Api\Data\ProductOptionExtensionInterface;
+use Magento\Catalog\Api\Data\ProductOptionInterface;
+use Magento\Catalog\Model\CustomOptions\CustomOption;
use Magento\Catalog\Model\CustomOptions\CustomOptionFactory;
+use Magento\Catalog\Model\Product\Option\UrlBuilder;
use Magento\Catalog\Model\ProductOptionProcessor;
use Magento\Framework\DataObject;
use Magento\Framework\DataObject\Factory as DataObjectFactory;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ProductOptionProcessorTest extends \PHPUnit\Framework\TestCase
+class ProductOptionProcessorTest extends TestCase
{
/**
* @var ProductOptionProcessor
@@ -23,28 +31,28 @@ class ProductOptionProcessorTest extends \PHPUnit\Framework\TestCase
protected $processor;
/**
- * @var DataObject | \PHPUnit_Framework_MockObject_MockObject
+ * @var DataObject|MockObject
*/
protected $dataObject;
/**
- * @var DataObjectFactory | \PHPUnit_Framework_MockObject_MockObject
+ * @var DataObjectFactory|MockObject
*/
protected $dataObjectFactory;
/**
- * @var CustomOptionFactory | \PHPUnit_Framework_MockObject_MockObject
+ * @var CustomOptionFactory|MockObject
*/
protected $customOptionFactory;
/**
- * @var CustomOptionInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var CustomOptionInterface|MockObject
*/
protected $customOption;
- protected function setUp()
+ protected function setUp(): void
{
- $this->dataObject = $this->getMockBuilder(\Magento\Framework\DataObject::class)
+ $this->dataObject = $this->getMockBuilder(DataObject::class)
->setMethods([
'getOptions', 'addData',
])
@@ -60,7 +68,7 @@ protected function setUp()
->willReturn($this->dataObject);
$this->customOption = $this->getMockBuilder(
- \Magento\Catalog\Api\Data\CustomOptionInterface::class
+ CustomOptionInterface::class
)
->setMethods([
'getDownloadableLinks',
@@ -68,7 +76,7 @@ protected function setUp()
->getMockForAbstractClass();
$this->customOptionFactory = $this->getMockBuilder(
- \Magento\Catalog\Model\CustomOptions\CustomOptionFactory::class
+ CustomOptionFactory::class
)
->setMethods(['create'])
->disableOriginalConstructor()
@@ -82,7 +90,7 @@ protected function setUp()
$this->customOptionFactory
);
- $urlBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\UrlBuilder::class)
+ $urlBuilder = $this->getMockBuilder(UrlBuilder::class)
->disableOriginalConstructor()
->setMethods(['getUrl'])
->getMock();
@@ -103,11 +111,11 @@ public function testConvertToBuyRequest(
$options,
$requestData
) {
- $productOptionMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductOptionInterface::class)
+ $productOptionMock = $this->getMockBuilder(ProductOptionInterface::class)
->getMockForAbstractClass();
$productOptionExtensionMock = $this->getMockBuilder(
- \Magento\Catalog\Api\Data\ProductOptionExtensionInterface::class
+ ProductOptionExtensionInterface::class
)
->setMethods([
'getCustomOptions',
@@ -137,8 +145,8 @@ public function dataProviderConvertToBuyRequest()
{
$objectManager = new ObjectManager($this);
- /** @var \Magento\Catalog\Model\CustomOptions\CustomOption $option */
- $option = $objectManager->getObject(\Magento\Catalog\Model\CustomOptions\CustomOption::class);
+ /** @var CustomOption $option */
+ $option = $objectManager->getObject(CustomOption::class);
$option->setOptionId(1);
$option->setOptionValue(1);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/XsdTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/XsdTest.php
index ff636545b48fb..09cc59962b505 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/XsdTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/XsdTest.php
@@ -3,9 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ProductOptions\Config;
-class XsdTest extends \PHPUnit\Framework\TestCase
+use Magento\Framework\Config\Dom\UrnResolver;
+use Magento\Framework\TestFramework\Unit\Utility\XsdValidator;
+use PHPUnit\Framework\TestCase;
+
+class XsdTest extends TestCase
{
/**
* Path to xsd file
@@ -14,18 +20,18 @@ class XsdTest extends \PHPUnit\Framework\TestCase
protected $_xsdSchemaPath;
/**
- * @var \Magento\Framework\TestFramework\Unit\Utility\XsdValidator
+ * @var XsdValidator
*/
protected $_xsdValidator;
- protected function setUp()
+ protected function setUp(): void
{
if (!function_exists('libxml_set_external_entity_loader')) {
$this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
}
- $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver();
+ $urnResolver = new UrnResolver();
$this->_xsdSchemaPath = $urnResolver->getRealPath('urn:magento:module:Magento_Catalog:etc/');
- $this->_xsdValidator = new \Magento\Framework\TestFramework\Unit\Utility\XsdValidator();
+ $this->_xsdValidator = new XsdValidator();
}
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/_files/invalidProductOptionsMergedXmlArray.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/_files/invalidProductOptionsMergedXmlArray.php
index 8fb2408cbb69c..d458ad0026485 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/_files/invalidProductOptionsMergedXmlArray.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/_files/invalidProductOptionsMergedXmlArray.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
return [
'options_node_is_required' => [
'',
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/_files/invalidProductOptionsXmlArray.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/_files/invalidProductOptionsXmlArray.php
index cfb54c3aefd0f..85edc42e1389e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/_files/invalidProductOptionsXmlArray.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/_files/invalidProductOptionsXmlArray.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
return [
'options_node_is_required' => [
'',
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRender/FormattedPriceInfoBuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRender/FormattedPriceInfoBuilderTest.php
index 65fe12130de68..7a1b9f0875835 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRender/FormattedPriceInfoBuilderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRender/FormattedPriceInfoBuilderTest.php
@@ -3,24 +3,27 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ProductRender;
-use Magento\Framework\Pricing\PriceCurrencyInterface;
-use Magento\Catalog\Api\Data\ProductRender\PriceInfoInterface;
use Magento\Catalog\Api\Data\ProductRender\FormattedPriceInfoInterface;
use Magento\Catalog\Api\Data\ProductRender\FormattedPriceInfoInterfaceFactory;
+use Magento\Catalog\Api\Data\ProductRender\PriceInfoInterface;
use Magento\Catalog\Model\ProductRender\FormattedPriceInfoBuilder;
+use Magento\Framework\Pricing\PriceCurrencyInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class FormattedPriceInfoBuilderTest extends \PHPUnit\Framework\TestCase
+class FormattedPriceInfoBuilderTest extends TestCase
{
/**
- * @var PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject;
+ * @var PriceCurrencyInterface|MockObject ;
*/
private $priceCurrencyMock;
/**
- * @var FormattedPriceInfoInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject;
+ * @var FormattedPriceInfoInterfaceFactory|MockObject ;
*/
private $formattedPriceInfoFactoryMock;
@@ -29,7 +32,7 @@ class FormattedPriceInfoBuilderTest extends \PHPUnit\Framework\TestCase
*/
private $formattedPriceInfoBuilderMock;
- public function setUp()
+ public function setUp(): void
{
$this->priceCurrencyMock = $this->getMockBuilder(PriceCurrencyInterface::class)
->getMockForAbstractClass();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRender/PriceInfoTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRender/PriceInfoTest.php
index 6901e09c50cab..6c5867b205cbb 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRender/PriceInfoTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRender/PriceInfoTest.php
@@ -3,52 +3,59 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ProductRender;
use Magento\Catalog\Model\ProductRender\PriceInfo;
-
-class PriceInfoTest extends \PHPUnit\Framework\TestCase
+use Magento\Framework\Api\AttributeValueFactory;
+use Magento\Framework\Api\ExtensionAttributesFactory;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Registry;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class PriceInfoTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ProductRender\PriceInfo
+ * @var PriceInfo
*/
private $priceInfo;
/**
- * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $contextMock;
/**
- * @var \Magento\Framework\Api\ExtensionAttributesFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var ExtensionAttributesFactory|MockObject
*/
private $extensionFactoryMock;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
private $registryMock;
/**
- * @var \Magento\Framework\Api\AttributeValueFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeValueFactory|MockObject
*/
private $attributeValueFactoryMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->contextMock = $this->getMockBuilder(\Magento\Framework\Model\Context::class)
+ $this->contextMock = $this->getMockBuilder(Context::class)
->disableOriginalConstructor()
->getMock();
- $this->extensionFactoryMock = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttributesFactory::class)
+ $this->extensionFactoryMock = $this->getMockBuilder(ExtensionAttributesFactory::class)
->disableOriginalConstructor()
->getMock();
- $this->registryMock = $this->getMockBuilder(\Magento\Framework\Registry::class)
+ $this->registryMock = $this->getMockBuilder(Registry::class)
->disableOriginalConstructor()
->getMock();
- $this->attributeValueFactoryMock = $this->getMockBuilder(\Magento\Framework\Api\AttributeValueFactory::class)
+ $this->attributeValueFactoryMock = $this->getMockBuilder(AttributeValueFactory::class)
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRenderListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRenderListTest.php
index fe2756a3126bb..a5ff50a906592 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRenderListTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRenderListTest.php
@@ -3,74 +3,85 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\Data\ProductRenderInterface;
+use Magento\Catalog\Model\Config;
use Magento\Catalog\Model\Product\Visibility;
+use Magento\Catalog\Model\ProductRenderFactory;
+use Magento\Catalog\Model\ProductRenderList;
+use Magento\Catalog\Model\ProductRenderSearchResultsFactory;
use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use Magento\Catalog\Ui\DataProvider\Product\ProductRenderCollectorComposite;
use Magento\Framework\Api\Search\SearchCriteria;
use Magento\Framework\Api\Search\SearchResultInterface;
+use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Framework\Data\CollectionModifier;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ProductRenderListTest extends \PHPUnit\Framework\TestCase
+class ProductRenderListTest extends TestCase
{
/** @var \Magento\Catalog\Model\ProductRenderRepository */
private $model;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
private $collectionFactoryMock;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
private $collectionProcessorMock;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
private $productRenderCollectorCompositeMock;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
private $productRenderSearchResultsFactoryMock;
- /** @var \Magento\Catalog\Model\ProductRenderFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ProductRenderFactory|MockObject */
private $productRenderFactoryMock;
- /** @var \Magento\Catalog\Model\Config|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Config|MockObject */
private $configMock;
- /** @var Visibility|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Visibility|MockObject */
private $productVisibility;
- /** @var CollectionModifier|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var CollectionModifier|MockObject */
private $collectionModifier;
- public function setUp()
+ public function setUp(): void
{
$this->collectionFactoryMock = $this
- ->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class)
+ ->getMockBuilder(CollectionFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
$this->collectionProcessorMock = $this
- ->getMockBuilder(\Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface::class)
+ ->getMockBuilder(CollectionProcessorInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->productRenderCollectorCompositeMock = $this
- ->getMockBuilder(\Magento\Catalog\Ui\DataProvider\Product\ProductRenderCollectorComposite::class)
+ ->getMockBuilder(ProductRenderCollectorComposite::class)
->disableOriginalConstructor()
->getMock();
$this->productRenderSearchResultsFactoryMock = $this
- ->getMockBuilder(\Magento\Catalog\Model\ProductRenderSearchResultsFactory::class)
+ ->getMockBuilder(ProductRenderSearchResultsFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
$this->productRenderFactoryMock = $this
- ->getMockBuilder(\Magento\Catalog\Model\ProductRenderFactory::class)
+ ->getMockBuilder(ProductRenderFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
- $this->configMock = $this->getMockBuilder(\Magento\Catalog\Model\Config::class)
+ $this->configMock = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
$this->configMock->expects($this->once())
@@ -83,7 +94,7 @@ public function setUp()
->disableOriginalConstructor()
->getMock();
- $this->model = new \Magento\Catalog\Model\ProductRenderList(
+ $this->model = new ProductRenderList(
$this->collectionFactoryMock,
$this->collectionProcessorMock,
$this->productRenderCollectorCompositeMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php
index 1f3faf659e390..fc3b62664b4cc 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php
@@ -22,6 +22,7 @@
use Magento\Catalog\Model\ProductFactory;
use Magento\Catalog\Model\ProductLink\Link;
use Magento\Catalog\Model\ProductRepository;
+use Magento\Catalog\Model\ProductRepository\MediaGalleryProcessor;
use Magento\Catalog\Model\ResourceModel\Product\Collection;
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
use Magento\Framework\Api\Data\ImageContentInterface;
@@ -36,6 +37,7 @@
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\DB\Adapter\ConnectionException;
+use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Filesystem;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
@@ -190,7 +192,7 @@ class ProductRepositoryTest extends TestCase
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->productFactory = $this->createPartialMock(
ProductFactory::class,
@@ -310,7 +312,7 @@ function ($value) {
);
$mediaProcessor = $this->objectManager->getObject(
- ProductRepository\MediaGalleryProcessor::class,
+ MediaGalleryProcessor::class,
[
'processor' => $this->processor,
'contentFactory' => $this->contentFactory,
@@ -343,12 +345,12 @@ function ($value) {
$this->objectManager->setBackwardCompatibleProperty($this->model, 'mediaProcessor', $mediaProcessor);
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage The product that was requested doesn't exist. Verify the product and try again.
- */
public function testGetAbsentProduct()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage(
+ 'The product that was requested doesn\'t exist. Verify the product and try again.'
+ );
$this->productFactory->expects($this->once())->method('create')
->will($this->returnValue($this->product));
$this->resourceModel->expects($this->once())->method('getIdBySku')->with('test_sku')
@@ -409,12 +411,12 @@ public function testGetWithSetStoreId()
$this->assertSame($this->product, $this->model->get($sku, false, $storeId));
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage The product that was requested doesn't exist. Verify the product and try again.
- */
public function testGetByIdAbsentProduct()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
+ $this->expectExceptionMessage(
+ 'The product that was requested doesn\'t exist. Verify the product and try again.'
+ );
$this->productFactory->expects($this->once())->method('create')
->will($this->returnValue($this->product));
$this->product->expects($this->once())->method('load')->with('product_id');
@@ -464,7 +466,7 @@ public function testGetByIdForCacheKeyGenerate($identifier, $editMode, $storeId)
/**
* Test the forceReload parameter
*
- * @throws \Magento\Framework\Exception\NoSuchEntityException
+ * @throws NoSuchEntityException
*/
public function testGetByIdForcedReload()
{
@@ -546,7 +548,7 @@ private function getProductMocksForReducedCache($productsCount)
/**
* Test forceReload parameter
*
- * @throws \Magento\Framework\Exception\NoSuchEntityException
+ * @throws NoSuchEntityException
*/
public function testGetForcedReload()
{
@@ -637,12 +639,10 @@ public function testSaveNew()
$this->assertEquals($this->product, $this->model->save($this->product));
}
- /**
- * @expectedException \Magento\Framework\Exception\CouldNotSaveException
- * @expectedExceptionMessage The product was unable to be saved. Please try again.
- */
public function testSaveUnableToSaveException()
{
+ $this->expectException('Magento\Framework\Exception\CouldNotSaveException');
+ $this->expectExceptionMessage('The product was unable to be saved. Please try again.');
$this->storeManager->expects($this->any())->method('getWebsites')->willReturn([1 => 'default']);
$this->resourceModel->expects($this->exactly(1))
->method('getIdBySku')->willReturn(null);
@@ -663,12 +663,10 @@ public function testSaveUnableToSaveException()
$this->model->save($this->product);
}
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Invalid value of "" provided for the field.
- */
public function testSaveException()
{
+ $this->expectException('Magento\Framework\Exception\InputException');
+ $this->expectExceptionMessage('Invalid value of "" provided for the field.');
$this->storeManager->expects($this->any())->method('getWebsites')->willReturn([1 => 'default']);
$this->resourceModel->expects($this->exactly(1))->method('getIdBySku')->will($this->returnValue(null));
$this->productFactory->expects($this->exactly(2))
@@ -689,12 +687,10 @@ public function testSaveException()
$this->model->save($this->product);
}
- /**
- * @expectedException \Magento\Framework\Exception\CouldNotSaveException
- * @expectedExceptionMessage Invalid product data: error1,error2
- */
public function testSaveInvalidProductException()
{
+ $this->expectException('Magento\Framework\Exception\CouldNotSaveException');
+ $this->expectExceptionMessage('Invalid product data: error1,error2');
$this->storeManager->expects($this->any())->method('getWebsites')->willReturn([1 => 'default']);
$this->resourceModel->expects($this->exactly(1))->method('getIdBySku')->will($this->returnValue(null));
$this->productFactory->expects($this->exactly(2))
@@ -713,12 +709,10 @@ public function testSaveInvalidProductException()
$this->model->save($this->product);
}
- /**
- * @expectedException \Magento\Framework\Exception\TemporaryState\CouldNotSaveException
- * @expectedExceptionMessage Database connection error
- */
public function testSaveThrowsTemporaryStateExceptionIfDatabaseConnectionErrorOccurred()
{
+ $this->expectException('Magento\Framework\Exception\TemporaryState\CouldNotSaveException');
+ $this->expectExceptionMessage('Database connection error');
$this->storeManager->expects($this->any())->method('getWebsites')->willReturn([1 => 'default']);
$this->productFactory->expects($this->any())
->method('create')
@@ -751,12 +745,10 @@ public function testDelete()
$this->assertTrue($this->model->delete($this->product));
}
- /**
- * @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage The "product-42" product couldn't be removed.
- */
public function testDeleteException()
{
+ $this->expectException('Magento\Framework\Exception\StateException');
+ $this->expectExceptionMessage('The "product-42" product couldn\'t be removed.');
$this->product->expects($this->exactly(2))->method('getSku')->willReturn('product-42');
$this->product->expects($this->exactly(2))->method('getId')->willReturn(42);
$this->resourceModel->expects($this->once())->method('delete')->with($this->product)
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php
index ce234e17c41aa..c7bf34ee2d6fc 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php
@@ -3,30 +3,80 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model;
+use Magento\Backend\App\Area\FrontNameResolver;
+use Magento\Catalog\Api\CategoryRepositoryInterface;
+use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
+use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory;
use Magento\Catalog\Api\Data\ProductExtensionInterface;
+use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
+use Magento\Catalog\Api\ProductLinkRepositoryInterface;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\FilterProductCustomAttribute;
+use Magento\Catalog\Model\Indexer\Product\Flat\Processor;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool;
+use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
use Magento\Catalog\Model\Product\Attribute\Source\Status;
+use Magento\Catalog\Model\Product\Image\Cache;
+use Magento\Catalog\Model\Product\Image\CacheFactory;
+use Magento\Catalog\Model\Product\Option;
+use Magento\Catalog\Model\Product\OptionFactory;
+use Magento\Catalog\Model\Product\Type;
+use Magento\Catalog\Model\Product\Type\AbstractType;
+use Magento\Catalog\Model\Product\Type\Price;
+use Magento\Catalog\Model\Product\Type\Simple;
+use Magento\Catalog\Model\Product\Type\Virtual;
+use Magento\Catalog\Model\ProductLink\Link;
+use Magento\Catalog\Model\ResourceModel\Product as ProductResourceMOdel;
+use Magento\CatalogInventory\Api\Data\StockItemInterface;
+use Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
+use Magento\Framework\Api\AbstractSimpleObject;
+use Magento\Framework\Api\AttributeValue;
+use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\Api\Data\ImageContentInterface;
+use Magento\Framework\Api\DataObjectHelper;
use Magento\Framework\Api\ExtensibleDataInterface;
use Magento\Framework\Api\ExtensionAttributesFactory;
+use Magento\Framework\Api\ExtensionAttributesInterface;
+use Magento\Framework\App\CacheInterface;
+use Magento\Framework\App\State;
+use Magento\Framework\Data\Collection;
+use Magento\Framework\Data\CollectionFactory;
+use Magento\Framework\DataObject;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\Filesystem;
+use Magento\Framework\Filesystem\Directory\ReadInterface;
+use Magento\Framework\Indexer\IndexerInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
+use Magento\Framework\Model\ActionValidator\RemoveAction;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
+use Magento\Framework\Module\Manager;
+use Magento\Framework\Pricing\PriceInfo\Base;
+use Magento\Framework\Registry;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;
+use Magento\Store\Model\Website;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Product Test
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
- *
*/
-class ProductTest extends \PHPUnit\Framework\TestCase
+class ProductTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productLinkRepositoryMock;
@@ -41,228 +91,228 @@ class ProductTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject
+ * @var Manager|MockObject
*/
protected $moduleManager;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $stockItemFactoryMock;
/**
- * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerInterface|MockObject
*/
protected $categoryIndexerMock;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor|\PHPUnit_Framework_MockObject_MockObject
+ * @var Processor|MockObject
*/
protected $productFlatProcessor;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor|MockObject
*/
protected $productPriceProcessor;
/**
- * @var Product\Type|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product\Type|MockObject
*/
protected $productTypeInstanceMock;
/**
- * @var Product\Option|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product\Option|MockObject
*/
protected $optionInstanceMock;
/**
- * @var \Magento\Framework\Pricing\PriceInfo\Base|\PHPUnit_Framework_MockObject_MockObject
+ * @var Base|MockObject
*/
protected $_priceInfoMock;
/**
- * @var \Magento\Catalog\Model\FilterProductCustomAttribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var FilterProductCustomAttribute|MockObject
*/
private $filterCustomAttribute;
/**
- * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
+ * @var Store|MockObject
*/
private $store;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductResourceMOdel|MockObject
*/
private $resource;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
private $registry;
/**
- * @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject
+ * @var Category|MockObject
*/
private $category;
/**
- * @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject
+ * @var Website|MockObject
*/
private $website;
/**
- * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var IndexerRegistry|MockObject
*/
protected $indexerRegistryMock;
/**
- * @var \Magento\Catalog\Api\CategoryRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryRepositoryInterface|MockObject
*/
private $categoryRepository;
/**
- * @var \Magento\Catalog\Helper\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Helper\Product|MockObject
*/
private $_catalogProduct;
/**
- * @var \Magento\Catalog\Model\Product\Image\Cache|\PHPUnit_Framework_MockObject_MockObject
+ * @var Cache|MockObject
*/
protected $imageCache;
/**
- * @var \Magento\Catalog\Model\Product\Image\CacheFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CacheFactory|MockObject
*/
protected $imageCacheFactory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $mediaGalleryEntryFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $dataObjectHelperMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $metadataServiceMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $attributeValueFactory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $mediaGalleryEntryConverterPoolMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $converterMock;
/**
- * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
protected $eventManagerMock;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
protected $mediaConfig;
/**
- * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject
+ * @var State|MockObject
*/
private $appStateMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $extensionAttributes;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $extensionAttributesFactory;
/**
- * @var \Magento\Framework\Filesystem
+ * @var Filesystem
*/
private $filesystemMock;
/**
- * @var \Magento\Framework\Data\CollectionFactory
+ * @var CollectionFactory
*/
private $collectionFactoryMock;
/**
- * @var ProductExtensionInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductExtensionInterface|MockObject
*/
private $productExtAttributes;
/**
- * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $eavConfig;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManager;
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->categoryIndexerMock = $this->getMockForAbstractClass(\Magento\Framework\Indexer\IndexerInterface::class);
+ $this->categoryIndexerMock = $this->getMockForAbstractClass(IndexerInterface::class);
$this->moduleManager = $this->createPartialMock(
- \Magento\Framework\Module\Manager::class,
+ Manager::class,
['isEnabled']
);
- $this->extensionAttributes = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttributesInterface::class)
+ $this->extensionAttributes = $this->getMockBuilder(ExtensionAttributesInterface::class)
->setMethods(['getWebsiteIds', 'setWebsiteIds'])
->disableOriginalConstructor()
->getMock();
$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
+ 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
);
$this->appStateMock = $this->createPartialMock(
- \Magento\Framework\App\State::class,
+ State::class,
['getAreaCode', 'isAreaCodeEmulated']
);
$this->appStateMock->expects($this->any())
->method('getAreaCode')
- ->will($this->returnValue(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE));
+ ->will($this->returnValue(FrontNameResolver::AREA_CODE));
- $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
+ $this->eventManagerMock = $this->createMock(ManagerInterface::class);
$actionValidatorMock = $this->createMock(
- \Magento\Framework\Model\ActionValidator\RemoveAction::class
+ 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'],
[],
'',
@@ -279,37 +329,37 @@ 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();
$optionFactory = $this->createPartialMock(
- \Magento\Catalog\Model\Product\OptionFactory::class,
+ OptionFactory::class,
['create']
);
$optionFactory->expects($this->any())->method('create')->willReturn($this->optionInstanceMock);
- $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();
- $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ $this->storeManager = $this->getMockBuilder(StoreManagerInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->storeManager->expects($this->any())
@@ -319,64 +369,64 @@ 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->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->mediaGalleryEntryConverterPoolMock =
$this->createPartialMock(
- \Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool::class,
+ EntryConverterPool::class,
['getConverterByMediaType']
);
$this->converterMock =
$this->createMock(
- \Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter::class
+ ImageEntryConverter::class
);
$this->mediaGalleryEntryConverterPoolMock->expects($this->any())->method('getConverterByMediaType')
->willReturn($this->converterMock);
$this->productLinkRepositoryMock = $this->getMockBuilder(
- \Magento\Catalog\Api\ProductLinkRepositoryInterface::class
+ ProductLinkRepositoryInterface::class
)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->extensionAttributesFactory = $this->getMockBuilder(ExtensionAttributesFactory::class)
->disableOriginalConstructor()
->getMock();
- $this->filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class)
+ $this->filesystemMock = $this->getMockBuilder(Filesystem::class)
->disableOriginalConstructor()
->getMock();
- $this->collectionFactoryMock = $this->getMockBuilder(\Magento\Framework\Data\CollectionFactory::class)
+ $this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$this->mediaConfig = $this->createMock(\Magento\Catalog\Model\Product\Media\Config::class);
- $this->eavConfig = $this->createMock(\Magento\Eav\Model\Config::class);
+ $this->eavConfig = $this->createMock(Config::class);
$this->productExtAttributes = $this->getMockBuilder(ProductExtensionInterface::class)
->setMethods(['getStockItem'])
@@ -387,7 +437,7 @@ protected function setUp()
->willReturn($this->productExtAttributes);
$this->filterCustomAttribute = $this->createTestProxy(
- \Magento\Catalog\Model\FilterProductCustomAttribute::class
+ FilterProductCustomAttribute::class
);
$this->objectManagerHelper = new ObjectManagerHelper($this);
@@ -427,14 +477,14 @@ protected function setUp()
public function testGetAttributes()
{
- $productType = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\AbstractType::class)
+ $productType = $this->getMockBuilder(AbstractType::class)
->setMethods(['getSetAttributes'])
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->productTypeInstanceMock->expects($this->any())->method('factory')->will(
$this->returnValue($productType)
);
- $attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $attribute = $this->getMockBuilder(AbstractAttribute::class)
->setMethods(['__wakeup', 'isInGroup'])
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -512,11 +562,11 @@ public function testGetStoreId()
public function testGetCategoryCollection()
{
- $collection = $this->getMockBuilder(\Magento\Framework\Data\Collection::class)
+ $collection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
$this->resource->expects($this->once())->method('getCategoryCollection')->will($this->returnValue($collection));
- $this->assertInstanceOf(\Magento\Framework\Data\Collection::class, $this->model->getCategoryCollection());
+ $this->assertInstanceOf(Collection::class, $this->model->getCategoryCollection());
}
/**
@@ -533,7 +583,7 @@ public function testGetCategoryCollectionCollectionNull($initCategoryCollection,
]
);
- $abstractDbMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class)
+ $abstractDbMock = $this->getMockBuilder(AbstractDb::class)
->disableOriginalConstructor()
->setMethods(
[
@@ -542,7 +592,7 @@ public function testGetCategoryCollectionCollectionNull($initCategoryCollection,
)
->getMockForAbstractClass();
$getCategoryCollectionMock = $this->createMock(
- \Magento\Framework\Data\Collection::class
+ Collection::class
);
$product
->expects($this->once())
@@ -593,7 +643,7 @@ public function getCategoryCollectionCollectionNullDataProvider()
public function testSetCategoryCollection()
{
- $collection = $this->getMockBuilder(\Magento\Framework\Data\Collection::class)
+ $collection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
$this->resource->expects($this->once())->method('getCategoryCollection')->will($this->returnValue($collection));
@@ -606,7 +656,7 @@ public function testGetCategory()
$this->category->expects($this->any())->method('getId')->will($this->returnValue(10));
$this->registry->expects($this->any())->method('registry')->will($this->returnValue($this->category));
$this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($this->category));
- $this->assertInstanceOf(\Magento\Catalog\Model\Category::class, $this->model->getCategory());
+ $this->assertInstanceOf(Category::class, $this->model->getCategory());
}
public function testGetCategoryId()
@@ -746,9 +796,9 @@ public function testGetIdentities($expected, $origData, $data, $isDeleted = fals
*/
public function getIdentitiesProvider()
{
- $extensionAttributesMock = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttributesInterface::class)
+ $extensionAttributesMock = $this->getMockBuilder(ExtensionAttributesInterface::class)
->disableOriginalConstructor()->setMethods(['getStockItem'])->getMock();
- $stockItemMock = $this->getMockBuilder(\Magento\CatalogInventory\Api\Data\StockItemInterface::class)
+ $stockItemMock = $this->getMockBuilder(StockItemInterface::class)
->disableOriginalConstructor()->getMock();
$extensionAttributesMock->expects($this->any())->method('getStockItem')->willReturn($stockItemMock);
$stockItemMock->expects($this->any())->method('getIsInStock')->willReturn(true);
@@ -859,7 +909,7 @@ private function getNewProductProviderData()
}
/**
- * @param \PHPUnit_Framework_MockObject_MockObject $extensionAttributesMock
+ * @param MockObject $extensionAttributesMock
* @return array
*/
private function getStatusStockProviderData($extensionAttributesMock)
@@ -936,7 +986,7 @@ public function testGetQty()
*/
public function testSave()
{
- $collection = $this->createMock(\Magento\Framework\Data\Collection::class);
+ $collection = $this->createMock(Collection::class);
$collection->method('count')->willReturn(1);
$collection->method('getIterator')->willReturn(new \ArrayObject([]));
$this->collectionFactoryMock->method('create')->willReturn($collection);
@@ -965,7 +1015,7 @@ public function testSaveIfAreaEmulated()
*/
public function testSaveAndDuplicate()
{
- $collection = $this->createMock(\Magento\Framework\Data\Collection::class);
+ $collection = $this->createMock(Collection::class);
$collection->method('count')->willReturn(1);
$collection->method('getIterator')->willReturn(new \ArrayObject([]));
$this->collectionFactoryMock->method('create')->willReturn($collection);
@@ -978,7 +1028,7 @@ public function testSaveAndDuplicate()
public function testGetIsSalableSimple()
{
$typeInstanceMock =
- $this->createPartialMock(\Magento\Catalog\Model\Product\Type\Simple::class, ['isSalable']);
+ $this->createPartialMock(Simple::class, ['isSalable']);
$typeInstanceMock
->expects($this->atLeastOnce())
->method('isSalable')
@@ -991,7 +1041,7 @@ public function testGetIsSalableSimple()
public function testGetIsSalableHasDataIsSaleable()
{
- $typeInstanceMock = $this->createMock(\Magento\Catalog\Model\Product\Type\Simple::class);
+ $typeInstanceMock = $this->createMock(Simple::class);
$this->model->setTypeInstance($typeInstanceMock);
$this->model->setData('is_saleable', true);
@@ -1002,12 +1052,10 @@ public function testGetIsSalableHasDataIsSaleable()
/**
* Configure environment for `testSave` and `testSaveAndDuplicate` methods
- *
- * @return array
*/
protected function configureSaveTest()
{
- $productTypeMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Simple::class)
+ $productTypeMock = $this->getMockBuilder(Simple::class)
->disableOriginalConstructor()->setMethods(['beforeSave', 'save'])->getMock();
$productTypeMock->expects($this->once())->method('beforeSave')->will($this->returnSelf());
$productTypeMock->expects($this->once())->method('save')->will($this->returnSelf());
@@ -1031,7 +1079,7 @@ public function testFromArray()
];
$stockItemMock = $this->getMockForAbstractClass(
- \Magento\Framework\Api\AbstractSimpleObject::class,
+ AbstractSimpleObject::class,
[],
'',
false,
@@ -1046,7 +1094,7 @@ public function testFromArray()
->will($this->returnValue(true));
$this->dataObjectHelperMock->expects($this->once())
->method('populateWithArray')
- ->with($stockItemMock, $data['stock_item'], \Magento\CatalogInventory\Api\Data\StockItemInterface::class)
+ ->with($stockItemMock, $data['stock_item'], StockItemInterface::class)
->will($this->returnSelf());
$this->stockItemFactoryMock->expects($this->once())
->method('create')
@@ -1069,7 +1117,7 @@ protected function prepareCategoryIndexer()
*/
public function testGetProductLinks()
{
- $outputRelatedLink = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\ProductLink\Link::class);
+ $outputRelatedLink = $this->objectManagerHelper->getObject(Link::class);
$outputRelatedLink->setSku("Simple Product 1");
$outputRelatedLink->setLinkType("related");
$outputRelatedLink->setLinkedProductSku("Simple Product 2");
@@ -1077,7 +1125,7 @@ public function testGetProductLinks()
$outputRelatedLink->setPosition(0);
$expectedOutput = [$outputRelatedLink];
$this->productLinkRepositoryMock->expects($this->once())->method('getList')->willReturn($expectedOutput);
- $typeInstance = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\AbstractType::class)
+ $typeInstance = $this->getMockBuilder(AbstractType::class)
->setMethods(['getSku'])
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -1092,7 +1140,7 @@ public function testGetProductLinks()
*/
public function testSetProductLinks()
{
- $link = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\ProductLink\Link::class);
+ $link = $this->objectManagerHelper->getObject(Link::class);
$link->setSku("Simple Product 1");
$link->setLinkType("upsell");
$link->setLinkedProductSku("Simple Product 2");
@@ -1108,7 +1156,7 @@ public function testSetProductLinks()
*/
protected function setupMediaAttributes()
{
- $productType = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\AbstractType::class)
+ $productType = $this->getMockBuilder(AbstractType::class)
->setMethods(['getSetAttributes'])
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -1116,12 +1164,12 @@ protected function setupMediaAttributes()
$this->returnValue($productType)
);
- $frontendMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend::class)
+ $frontendMock = $this->getMockBuilder(AbstractFrontend::class)
->disableOriginalConstructor()
->setMethods(['getInputType'])
->getMockForAbstractClass();
$frontendMock->expects($this->any())->method('getInputType')->willReturn('media_image');
- $attributeImage = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $attributeImage = $this->getMockBuilder(AbstractAttribute::class)
->setMethods(['__wakeup', 'getFrontend', 'getAttributeCode'])
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -1129,7 +1177,7 @@ protected function setupMediaAttributes()
->method('getFrontend')
->willReturn($frontendMock);
$attributeImage->expects($this->any())->method('getAttributeCode')->willReturn('image');
- $attributeSmallImage = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $attributeSmallImage = $this->getMockBuilder(AbstractAttribute::class)
->setMethods(['__wakeup', 'getFrontend', 'getAttributeCode'])
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -1198,11 +1246,11 @@ public function testGetMediaGalleryEntries()
$entry1 =
$this->createMock(
- \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
+ ProductAttributeMediaGalleryEntryInterface::class
);
$entry2 =
$this->createMock(
- \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
+ ProductAttributeMediaGalleryEntryInterface::class
);
$this->converterMock->expects($this->exactly(2))->method('convertTo')->willReturnOnConsecutiveCalls(
@@ -1236,7 +1284,7 @@ public function testSetMediaGalleryEntries()
],
];
- $entryMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class)
+ $entryMock = $this->getMockBuilder(ProductAttributeMediaGalleryEntryInterface::class)
->setMethods(
[
'getId',
@@ -1295,7 +1343,7 @@ public function testGetMediaGalleryImagesMerging()
],
]
];
- $expectedImageDataObject = new \Magento\Framework\DataObject(
+ $expectedImageDataObject = new DataObject(
[
'value_id' => 1,
'file' => 'imageFile.jpg',
@@ -1305,7 +1353,7 @@ public function testGetMediaGalleryImagesMerging()
'path' => '/var/www/html/pub/imageFile.jpg',
]
);
- $expectedSmallImageDataObject = new \Magento\Framework\DataObject(
+ $expectedSmallImageDataObject = new DataObject(
[
'value_id' => 2,
'file' => 'smallImageFile.jpg',
@@ -1316,7 +1364,7 @@ public function testGetMediaGalleryImagesMerging()
]
);
- $directoryMock = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class);
+ $directoryMock = $this->createMock(ReadInterface::class);
$directoryMock->method('getAbsolutePath')->willReturnOnConsecutiveCalls(
'/var/www/html/pub/imageFile.jpg',
'/var/www/html/pub/smallImageFile.jpg'
@@ -1327,7 +1375,7 @@ public function testGetMediaGalleryImagesMerging()
);
$this->filesystemMock->method('getDirectoryRead')->willReturn($directoryMock);
$this->model->setData('media_gallery', $mediaEntries);
- $imagesCollectionMock = $this->createMock(\Magento\Framework\Data\Collection::class);
+ $imagesCollectionMock = $this->createMock(Collection::class);
$imagesCollectionMock->method('count')->willReturn(0);
$imagesCollectionMock->method('getItemById')->willReturnMap(
[
@@ -1363,8 +1411,8 @@ public function testGetCustomAttributes()
//Set the color attribute;
$this->model->setData($customAttributeCode, $initialCustomAttributeValue);
- $attributeValue = new \Magento\Framework\Api\AttributeValue();
- $attributeValue2 = new \Magento\Framework\Api\AttributeValue();
+ $attributeValue = new AttributeValue();
+ $attributeValue2 = new AttributeValue();
$this->attributeValueFactory->expects($this->exactly(2))->method('create')
->willReturnOnConsecutiveCalls($attributeValue, $attributeValue2);
$this->assertEquals(1, count($this->model->getCustomAttributes()));
@@ -1399,12 +1447,12 @@ public function priceDataProvider()
public function testGetOptions()
{
$option1Id = 2;
- $optionMock1 = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class)
+ $optionMock1 = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->setMethods(['getId', 'setProduct'])
->getMock();
$option2Id = 3;
- $optionMock2 = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class)
+ $optionMock2 = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->setMethods(['getId', 'setProduct'])
->getMock();
@@ -1453,7 +1501,7 @@ public function testGetFinalPrice()
$qty = 1;
$this->model->setQty($qty);
$productTypePriceMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Type\Price::class,
+ Price::class,
['getFinalPrice']
);
@@ -1478,7 +1526,7 @@ public function testGetFinalPricePreset()
$this->model->setQty($qty);
$this->model->setFinalPrice($finalPrice);
$productTypePriceMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Type\Price::class,
+ Price::class,
['getFinalPrice']
);
$productTypePriceMock->expects($this->any())
@@ -1496,7 +1544,7 @@ public function testGetFinalPricePreset()
public function testGetTypeId()
{
- $productType = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Virtual::class)
+ $productType = $this->getMockBuilder(Virtual::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -1512,7 +1560,7 @@ public function testGetTypeId()
public function testGetOptionById()
{
$optionId = 100;
- $optionMock = $this->createMock(\Magento\Catalog\Model\Product\Option::class);
+ $optionMock = $this->createMock(Option::class);
$this->model->setOptions([$optionMock]);
$optionMock->expects($this->once())->method('getId')->willReturn($optionId);
$this->assertEquals($optionMock, $this->model->getOptionById($optionId));
@@ -1521,7 +1569,7 @@ public function testGetOptionById()
public function testGetOptionByIdWithWrongOptionId()
{
$optionId = 100;
- $optionMock = $this->createMock(\Magento\Catalog\Model\Product\Option::class);
+ $optionMock = $this->createMock(Option::class);
$this->model->setOptions([$optionMock]);
$optionMock->expects($this->once())->method('getId')->willReturn(200);
$this->assertNull($this->model->getOptionById($optionId));
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypeListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypeListTest.php
index 8e4b97598a6a6..d0f33b74837df 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypeListTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypeListTest.php
@@ -3,11 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model;
+use Magento\Catalog\Api\Data\ProductTypeInterface;
+use Magento\Catalog\Api\Data\ProductTypeInterfaceFactory;
use Magento\Catalog\Model\ProductTypeList;
+use Magento\Catalog\Model\ProductTypes\ConfigInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ProductTypeListTest extends \PHPUnit\Framework\TestCase
+class ProductTypeListTest extends TestCase
{
/**
* @var ProductTypeList
@@ -15,20 +22,20 @@ class ProductTypeListTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $typeConfigMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $factoryMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->typeConfigMock = $this->createMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class);
+ $this->typeConfigMock = $this->createMock(ConfigInterface::class);
$this->factoryMock = $this->createPartialMock(
- \Magento\Catalog\Api\Data\ProductTypeInterfaceFactory::class,
+ ProductTypeInterfaceFactory::class,
['create']
);
$this->model = new ProductTypeList(
@@ -46,7 +53,7 @@ public function testGetProductTypes()
$productTypeData = [
'simple' => $simpleProductType,
];
- $productTypeMock = $this->createMock(\Magento\Catalog\Api\Data\ProductTypeInterface::class);
+ $productTypeMock = $this->createMock(ProductTypeInterface::class);
$this->typeConfigMock->expects($this->any())->method('getAll')->will($this->returnValue($productTypeData));
$this->factoryMock->expects($this->once())->method('create')->willReturn($productTypeMock);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/ConverterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/ConverterTest.php
index a52b982408eef..95504ed9f4ada 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/ConverterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/ConverterTest.php
@@ -3,12 +3,17 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ProductTypes\Config;
-class ConverterTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\ProductTypes\Config\Converter;
+use PHPUnit\Framework\TestCase;
+
+class ConverterTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ProductTypes\Config\Converter
+ * @var Converter
*/
protected $_model;
@@ -17,9 +22,9 @@ class ConverterTest extends \PHPUnit\Framework\TestCase
*/
protected $_filePath;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_model = new \Magento\Catalog\Model\ProductTypes\Config\Converter();
+ $this->_model = new Converter();
$this->_filePath = realpath(__DIR__) . '/_files/';
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/SchemaLocatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/SchemaLocatorTest.php
index f972e1772b4f4..d80b5428b7d07 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/SchemaLocatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/SchemaLocatorTest.php
@@ -3,23 +3,30 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ProductTypes\Config;
-class SchemaLocatorTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\ProductTypes\Config\SchemaLocator;
+use Magento\Framework\Module\Dir\Reader;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class SchemaLocatorTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ProductTypes\Config\SchemaLocator
+ * @var SchemaLocator
*/
protected $_model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_moduleReaderMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_moduleReaderMock = $this->createMock(\Magento\Framework\Module\Dir\Reader::class);
+ $this->_moduleReaderMock = $this->createMock(Reader::class);
$this->_moduleReaderMock->expects(
$this->once()
)->method(
@@ -30,7 +37,7 @@ protected function setUp()
)->will(
$this->returnValue('schema_dir')
);
- $this->_model = new \Magento\Catalog\Model\ProductTypes\Config\SchemaLocator($this->_moduleReaderMock);
+ $this->_model = new SchemaLocator($this->_moduleReaderMock);
}
public function testGetSchema()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/XsdMergedTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/XsdMergedTest.php
index 9e83224f69b2f..d901a97f65018 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/XsdMergedTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/XsdMergedTest.php
@@ -3,9 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ProductTypes\Config;
-class XsdMergedTest extends \PHPUnit\Framework\TestCase
+use Magento\Framework\Config\Dom\UrnResolver;
+use Magento\Framework\TestFramework\Unit\Utility\XsdValidator;
+use PHPUnit\Framework\TestCase;
+
+class XsdMergedTest extends TestCase
{
/**
* Path to xsd schema file
@@ -14,20 +20,20 @@ class XsdMergedTest extends \PHPUnit\Framework\TestCase
protected $_xsdSchema;
/**
- * @var \Magento\Framework\TestFramework\Unit\Utility\XsdValidator
+ * @var XsdValidator
*/
protected $_xsdValidator;
- protected function setUp()
+ protected function setUp(): void
{
if (!function_exists('libxml_set_external_entity_loader')) {
$this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
}
- $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver();
+ $urnResolver = new UrnResolver();
$this->_xsdSchema = $urnResolver->getRealPath(
'urn:magento:module:Magento_Catalog:etc/product_types_merged.xsd'
);
- $this->_xsdValidator = new \Magento\Framework\TestFramework\Unit\Utility\XsdValidator();
+ $this->_xsdValidator = new XsdValidator();
}
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/XsdTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/XsdTest.php
index 704be29984c7a..606e5898b785f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/XsdTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/XsdTest.php
@@ -3,9 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ProductTypes\Config;
-class XsdTest extends \PHPUnit\Framework\TestCase
+use Magento\Framework\Config\Dom\UrnResolver;
+use Magento\Framework\TestFramework\Unit\Utility\XsdValidator;
+use PHPUnit\Framework\TestCase;
+
+class XsdTest extends TestCase
{
/**
* Path to xsd schema file
@@ -14,18 +20,18 @@ class XsdTest extends \PHPUnit\Framework\TestCase
protected $_xsdSchema;
/**
- * @var \Magento\Framework\TestFramework\Unit\Utility\XsdValidator
+ * @var XsdValidator
*/
protected $_xsdValidator;
- protected function setUp()
+ protected function setUp(): void
{
if (!function_exists('libxml_set_external_entity_loader')) {
$this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
}
- $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver();
+ $urnResolver = new UrnResolver();
$this->_xsdSchema = $urnResolver->getRealPath('urn:magento:module:Magento_Catalog:etc/product_types.xsd');
- $this->_xsdValidator = new \Magento\Framework\TestFramework\Unit\Utility\XsdValidator();
+ $this->_xsdValidator = new XsdValidator();
}
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php
index 1fb7a4954db2e..c4965b37717a5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
return [
'type_without_required_name' => [
'',
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php
index 868252da8190c..8175b31680741 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
return [
'types_with_same_name_attribute_value' => [
'',
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/product_types.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/product_types.php
index a797a10a9762f..8c90c06ce53d8 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/product_types.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/product_types.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
return [
'types' => [
'type_one' => [
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php
index fb289c7beaac6..26a6eaea88588 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php
@@ -3,41 +3,51 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ProductTypes;
-class ConfigTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\ProductTypes\Config;
+use Magento\Catalog\Model\ProductTypes\Config\Reader;
+use Magento\Framework\Config\CacheInterface;
+use Magento\Framework\Serialize\SerializerInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class ConfigTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManager;
/**
- * @var \Magento\Catalog\Model\ProductTypes\Config\Reader|\PHPUnit_Framework_MockObject_MockObject
+ * @var Reader|MockObject
*/
private $readerMock;
/**
- * @var \Magento\Framework\Config\CacheInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CacheInterface|MockObject
*/
private $cacheMock;
/**
- * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var SerializerInterface|MockObject
*/
private $serializerMock;
/**
- * @var \Magento\Catalog\Model\ProductTypes\Config
+ * @var Config
*/
private $config;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->readerMock = $this->createMock(\Magento\Catalog\Model\ProductTypes\Config\Reader::class);
- $this->cacheMock = $this->createMock(\Magento\Framework\Config\CacheInterface::class);
- $this->serializerMock = $this->createMock(\Magento\Framework\Serialize\SerializerInterface::class);
+ $this->objectManager = new ObjectManager($this);
+ $this->readerMock = $this->createMock(Reader::class);
+ $this->cacheMock = $this->createMock(CacheInterface::class);
+ $this->serializerMock = $this->createMock(SerializerInterface::class);
}
/**
@@ -57,7 +67,7 @@ public function testGetType($value, $expected)
->willReturn($value);
$this->config = $this->objectManager->getObject(
- \Magento\Catalog\Model\ProductTypes\Config::class,
+ Config::class,
[
'reader' => $this->readerMock,
'cache' => $this->cacheMock,
@@ -90,7 +100,7 @@ public function testGetAll()
->willReturn(['types' => $expected]);
$this->config = $this->objectManager->getObject(
- \Magento\Catalog\Model\ProductTypes\Config::class,
+ Config::class,
[
'reader' => $this->readerMock,
'cache' => $this->cacheMock,
@@ -111,7 +121,7 @@ public function testIsProductSet()
->willReturn([]);
$this->config = $this->objectManager->getObject(
- \Magento\Catalog\Model\ProductTypes\Config::class,
+ Config::class,
[
'reader' => $this->readerMock,
'cache' => $this->cacheMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AbstractTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AbstractTest.php
index 3dcea33d5e00e..f19824b6e0fdf 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AbstractTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AbstractTest.php
@@ -3,15 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
/**
* Test class for \Magento\Catalog\Model\Entity\Attribute\Set
*/
namespace Magento\Catalog\Test\Unit\Model\ResourceModel;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ResourceModel\AbstractResource;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Framework\DataObject;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class AbstractTest extends \PHPUnit\Framework\TestCase
+class AbstractTest extends TestCase
{
/**
* Get attribute list
@@ -24,7 +30,7 @@ protected function _getAttributes()
$codes = ['entity_type_id', 'attribute_set_id', 'created_at', 'updated_at', 'parent_id', 'increment_id'];
foreach ($codes as $code) {
$mock = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
+ AbstractAttribute::class,
['isInSet', 'getApplyTo', 'getBackend', '__wakeup']
);
@@ -46,13 +52,13 @@ public function testWalkAttributes()
$set = 10;
$storeId = 100;
- $object = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['__wakeup']);
+ $object = $this->createPartialMock(Product::class, ['__wakeup']);
$object->setData('test_attr', 'test_attr');
$object->setData('attribute_set_id', $set);
$object->setData('store_id', $storeId);
- $entityType = new \Magento\Framework\DataObject();
+ $entityType = new DataObject();
$entityType->setEntityTypeCode('test');
$entityType->setEntityTypeId(0);
$entityType->setEntityTable('table');
@@ -60,7 +66,7 @@ public function testWalkAttributes()
$attributes = $this->_getAttributes();
$attribute = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
+ AbstractAttribute::class,
['isInSet', 'getBackend', '__wakeup']
);
$attribute->setAttributeId($code);
@@ -78,11 +84,11 @@ public function testWalkAttributes()
$attributes[$code] = $attribute;
- /** @var $model \Magento\Catalog\Model\ResourceModel\AbstractResource */
+ /** @var AbstractResource $model */
$arguments = $objectManager->getConstructArguments(
- \Magento\Catalog\Model\ResourceModel\AbstractResource::class
+ AbstractResource::class
);
- $model = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\AbstractResource::class)
+ $model = $this->getMockBuilder(AbstractResource::class)
->setMethods(['getAttributesByCode'])
->setConstructorArgs($arguments)
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Attribute/ConditionBuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Attribute/ConditionBuilderTest.php
index d687495756ccc..ae7c1b48fda95 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Attribute/ConditionBuilderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Attribute/ConditionBuilderTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
/**
* Test class for \Magento\Catalog\Model\ResourceModel\Attribute\AttributeConditionsBuilder
@@ -10,25 +11,24 @@
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Attribute;
use Magento\Catalog\Model\Entity\Attribute;
-use Magento\Framework\DB\Adapter\Pdo\Mysql;
-use Magento\Store\Model\Website;
use Magento\Catalog\Model\ResourceModel\Attribute\ConditionBuilder;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute as CatalogEavAttribute;
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Framework\DB\Adapter\Pdo\Mysql;
use Magento\Framework\EntityManager\EntityMetadata;
use Magento\Framework\EntityManager\EntityMetadataInterface;
-use Magento\Store\Api\Data\StoreInterface;
use Magento\Framework\Model\Entity\ScopeInterface;
+use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManager;
-use Magento\Catalog\Model\ResourceModel\Eav\Attribute as CatalogEavAttribute;
+use Magento\Store\Model\Website;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class AttributeConditionsBuilderTest
- * @package Magento\Catalog\Test\Unit\Model\ResourceModel\Attribute
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ConditionBuilderTest extends \PHPUnit\Framework\TestCase
+class ConditionBuilderTest extends TestCase
{
/**
* @param AbstractAttribute $attribute
@@ -546,7 +546,7 @@ public function buildNewAttributeWebsiteScopeSuccessDataProvider()
}
/**
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
private function getValidAttributeMock()
{
@@ -572,7 +572,7 @@ private function getValidAttributeMock()
}
/**
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
private function getValidStoreMock()
{
@@ -608,7 +608,7 @@ private function getValidStoreMock()
}
/**
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
private function getValidScopeMock()
{
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AttributeTest.php
index 0501d995aaf53..6f942eacf1ac0 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AttributeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AttributeTest.php
@@ -9,73 +9,77 @@
namespace Magento\Catalog\Test\Unit\Model\ResourceModel;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Model\Attribute\LockValidatorInterface;
use Magento\Catalog\Model\ResourceModel\Attribute;
+use Magento\Eav\Model\Config;
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
use Magento\Eav\Model\ResourceModel\Entity\Type;
use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface as Adapter;
use Magento\Framework\EntityManager\EntityMetadataInterface;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\Context;
-use Magento\Framework\DB\Adapter\AdapterInterface as Adapter;
use Magento\ResourceConnections\DB\Select;
use Magento\Store\Model\StoreManagerInterface;
-use Magento\Catalog\Model\Attribute\LockValidatorInterface;
-use Magento\Framework\Model\AbstractModel;
-use Magento\Framework\EntityManager\MetadataPool;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class AttributeTest extends \PHPUnit\Framework\TestCase
+class AttributeTest extends TestCase
{
/**
- * @var Select|\PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
private $selectMock;
/**
- * @var Adapter|\PHPUnit_Framework_MockObject_MockObject
+ * @var Adapter|MockObject
*/
private $connectionMock;
/**
- * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceMock;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManagerMock;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $contextMock;
/**
- * @var \Magento\Eav\Model\ResourceModel\Entity\Type|\PHPUnit_Framework_MockObject_MockObject
+ * @var Type|MockObject
*/
private $eavEntityTypeMock;
/**
- * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $eavConfigMock;
/**
- * @var LockValidatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LockValidatorInterface|MockObject
*/
private $lockValidatorMock;
/**
- * @var EntityMetadataInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var EntityMetadataInterface|MockObject
*/
private $entityMetaDataInterfaceMock;
/**
* @inheritDoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->selectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
@@ -101,7 +105,7 @@ protected function setUp()
$this->eavEntityTypeMock = $this->getMockBuilder(Type::class)
->disableOriginalConstructor()
->getMock();
- $this->eavConfigMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class)
+ $this->eavConfigMock = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->setMethods(['getAttribute'])
->getMock();
@@ -109,7 +113,7 @@ protected function setUp()
->disableOriginalConstructor()
->setMethods(['validate'])
->getMock();
- $this->entityMetaDataInterfaceMock = $this->getMockBuilder(EntityMetadataInterface::class)
+ $this->entityMetaDataInterfaceMock = $this->getMockBuilder(EntityMetadataInterface::class)
->disableOriginalConstructor()
->getMock();
}
@@ -171,7 +175,7 @@ public function testDeleteEntity() : void
$this->setObjectProperty($attributeModel, 'metadataPool', $metadataPoolMock);
- $eavAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $eavAttributeMock = $this->getMockBuilder(AbstractAttribute::class)
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/Collection/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/Collection/FactoryTest.php
index 95aa333993a97..a6b0d26241cb8 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/Collection/FactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/Collection/FactoryTest.php
@@ -3,36 +3,44 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Category\Collection;
-class FactoryTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\ResourceModel\Category\Collection;
+use Magento\Catalog\Model\ResourceModel\Category\Collection\Factory;
+use Magento\Framework\ObjectManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class FactoryTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Category\Collection\Factory
+ * @var Factory
*/
protected $_model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_objectManager;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
- $this->_model = new \Magento\Catalog\Model\ResourceModel\Category\Collection\Factory($this->_objectManager);
+ $this->_objectManager = $this->createMock(ObjectManagerInterface::class);
+ $this->_model = new Factory($this->_objectManager);
}
public function testCreate()
{
- $objectOne = $this->createMock(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
- $objectTwo = $this->createMock(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
+ $objectOne = $this->createMock(Collection::class);
+ $objectTwo = $this->createMock(Collection::class);
$this->_objectManager->expects(
$this->exactly(2)
)->method(
'create'
)->with(
- \Magento\Catalog\Model\ResourceModel\Category\Collection::class,
+ Collection::class,
[]
)->will(
$this->onConsecutiveCalls($objectOne, $objectTwo)
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/FlatTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/FlatTest.php
index da6ed255d60ee..945701aeedbc1 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/FlatTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/FlatTest.php
@@ -3,26 +3,27 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Category;
-use Magento\Catalog\Model\ResourceModel\Category\Flat\CollectionFactory;
-use Magento\Catalog\Model\ResourceModel\Category\Flat\Collection;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Catalog\Model\ResourceModel\Category\Flat;
-use Magento\Framework\DB\Select;
-use Magento\Framework\DB\Adapter\AdapterInterface as Adapter;
+use Magento\Catalog\Model\ResourceModel\Category\Flat\Collection;
+use Magento\Catalog\Model\ResourceModel\Category\Flat\CollectionFactory;
use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface as Adapter;
+use Magento\Framework\DB\Select;
use Magento\Framework\Model\ResourceModel\Db\Context;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Category flat model test
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class FlatTest extends \PHPUnit\Framework\TestCase
+class FlatTest extends TestCase
{
const STORE_ID = 1;
const TABLE_NAME = 'test_table';
@@ -32,12 +33,12 @@ class FlatTest extends \PHPUnit\Framework\TestCase
const RECURSION_LEVEL = 0;
/**
- * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
private $categoryCollectionFactoryMock;
/**
- * @var Collection|\PHPUnit_Framework_MockObject_MockObject
+ * @var Collection|MockObject
*/
private $categoryCollectionMock;
@@ -52,39 +53,39 @@ class FlatTest extends \PHPUnit\Framework\TestCase
private $objectManager;
/**
- * @var Select|\PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
private $selectMock;
/**
- * @var Adapter|\PHPUnit_Framework_MockObject_MockObject
+ * @var Adapter|MockObject
*/
private $connectionMock;
/**
- * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceMock;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
private $contextMock;
/**
- * @var Store|\PHPUnit_Framework_MockObject_MockObject
+ * @var Store|MockObject
*/
private $storeMock;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManagerMock;
/**
* {@inheritdoc}
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/TreeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/TreeTest.php
index 44a8560d1ff6b..2d682743010fb 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/TreeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/TreeTest.php
@@ -3,54 +3,70 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Category;
use Magento\Catalog\Api\Data\CategoryInterface;
+use Magento\Catalog\Model\Attribute\Config;
+use Magento\Catalog\Model\ResourceModel\Category\Collection;
+use Magento\Catalog\Model\ResourceModel\Category\Collection\Factory;
+use Magento\Catalog\Model\ResourceModel\Category\Tree;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Data\Tree\Node;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Adapter\Pdo\Mysql;
+use Magento\Framework\DB\Select;
use Magento\Framework\EntityManager\EntityMetadata;
use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class TreeTest extends \PHPUnit\Framework\TestCase
+class TreeTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Category\Tree
+ * @var Tree
*/
protected $_model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_resource;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_attributeConfig;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $_collectionFactory;
/**
- * @var MetadataPool|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataPool|MockObject
*/
protected $metadataPoolMock;
/**
* {@inheritdoc}
*/
- protected function setUp()
+ protected function setUp(): void
{
- $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $select = $this->createMock(\Magento\Framework\DB\Select::class);
+ $objectHelper = new ObjectManager($this);
+ $select = $this->createMock(Select::class);
$select->expects($this->once())->method('from')->with('catalog_category_entity');
- $connection = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class);
+ $connection = $this->createMock(Mysql::class);
$connection->expects($this->once())->method('select')->will($this->returnValue($select));
- $this->_resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
+ $this->_resource = $this->createMock(ResourceConnection::class);
$this->_resource->expects(
$this->once()
)->method(
@@ -69,10 +85,10 @@ protected function setUp()
)->will(
$this->returnArgument(0)
);
- $eventManager = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
- $this->_attributeConfig = $this->createMock(\Magento\Catalog\Model\Attribute\Config::class);
+ $eventManager = $this->createMock(ManagerInterface::class);
+ $this->_attributeConfig = $this->createMock(Config::class);
$this->_collectionFactory = $this->createMock(
- \Magento\Catalog\Model\ResourceModel\Category\Collection\Factory::class
+ Factory::class
);
$this->metadataPoolMock = $this->getMockBuilder(MetadataPool::class)
@@ -80,7 +96,7 @@ protected function setUp()
->getMock();
$this->_model = $objectHelper->getObject(
- \Magento\Catalog\Model\ResourceModel\Category\Tree::class,
+ Tree::class,
[
'resource' => $this->_resource,
'eventManager' => $eventManager,
@@ -112,11 +128,11 @@ public function testGetCollection()
}
/**
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
protected function getCollectionMock()
{
- return $this->createMock(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
+ return $this->createMock(Collection::class);
}
public function testSetCollection()
@@ -129,8 +145,8 @@ public function testSetCollection()
public function testCallCleaningDuringSetCollection()
{
- /** @var \Magento\Catalog\Model\ResourceModel\Category\Tree $model */
- $model = $this->createPartialMock(\Magento\Catalog\Model\ResourceModel\Category\Tree::class, ['_clean']);
+ /** @var Tree $model */
+ $model = $this->createPartialMock(Tree::class, ['_clean']);
$model->expects($this->once())->method('_clean')->will($this->returnSelf());
$this->assertEquals($model, $model->setCollection($this->getCollectionMock()));
@@ -139,24 +155,24 @@ public function testCallCleaningDuringSetCollection()
public function testAddCollectionData()
{
- $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $select = $this->createMock(\Magento\Framework\DB\Select::class);
+ $objectHelper = new ObjectManager($this);
+ $select = $this->createMock(Select::class);
$select->expects($this->any())->method('from')->will($this->returnSelf());
$select->expects($this->any())->method('join')->will($this->returnSelf());
$select->expects($this->any())->method('joinInner')->will($this->returnSelf());
$select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
$select->expects($this->any())->method('where')->will($this->returnSelf());
- $connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
+ $connection = $this->createMock(AdapterInterface::class);
$connection->expects($this->any())->method('select')->will($this->returnValue($select));
$connection->expects($this->any())->method('fetchCol')->will($this->returnValue([]));
- $resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
+ $resource = $this->createMock(ResourceConnection::class);
$resource->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
$resource->expects($this->any())->method('getTableName')->will($this->returnArgument(0));
- $eventManager = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
- $attributeConfig = $this->createMock(\Magento\Catalog\Model\Attribute\Config::class);
+ $eventManager = $this->createMock(ManagerInterface::class);
+ $attributeConfig = $this->createMock(Config::class);
$attributes = ['attribute_one', 'attribute_two'];
$attributeConfig->expects($this->once())
@@ -164,16 +180,16 @@ public function testAddCollectionData()
->with('catalog_category')
->will($this->returnValue($attributes));
- $collection = $this->createMock(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
+ $collection = $this->createMock(Collection::class);
$collection->expects($this->never())->method('getAllIds')->will($this->returnValue([]));
$collection->expects($this->once())->method('getAllIdsSql')->will($this->returnValue($select));
- $collectionFactory = $this->createMock(\Magento\Catalog\Model\ResourceModel\Category\Collection\Factory::class);
+ $collectionFactory = $this->createMock(Factory::class);
$collectionFactory->expects($this->once())->method('create')->will($this->returnValue($collection));
- $store = $this->createMock(\Magento\Store\Model\Store::class);
+ $store = $this->createMock(Store::class);
$store->expects($this->any())->method('getId')->will($this->returnValue(1));
- $storeManager = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class);
+ $storeManager = $this->getMockForAbstractClass(StoreManagerInterface::class);
$storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
$categoryMetadataMock = $this->getMockBuilder(EntityMetadata::class)
@@ -189,7 +205,7 @@ public function testAddCollectionData()
->willReturn($categoryMetadataMock);
$model = $objectHelper->getObject(
- \Magento\Catalog\Model\ResourceModel\Category\Tree::class,
+ Tree::class,
[
'storeManager' => $storeManager,
'resource' => $resource,
@@ -200,7 +216,7 @@ public function testAddCollectionData()
]
);
- $nodeMock = $this->createPartialMock(\Magento\Framework\Data\Tree\Node::class, ['getId', 'getPath']);
+ $nodeMock = $this->createPartialMock(Node::class, ['getId', 'getPath']);
$nodeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
$nodeMock->expects($this->once())->method('getPath')->will($this->returnValue([]));
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/CategoryTest.php
index b7d05fd2b70ee..dbbcc6c6488ad 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/CategoryTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel;
@@ -10,6 +11,7 @@
use Magento\Catalog\Model\Indexer\Category\Product\Processor;
use Magento\Catalog\Model\ResourceModel\Category;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
+use Magento\Catalog\Model\ResourceModel\Category\TreeFactory;
use Magento\Eav\Model\Config;
use Magento\Eav\Model\Entity\Attribute;
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
@@ -21,11 +23,13 @@
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CategoryTest extends \PHPUnit\Framework\TestCase
+class CategoryTest extends TestCase
{
/**
* @var Category
@@ -33,74 +37,74 @@ class CategoryTest extends \PHPUnit\Framework\TestCase
protected $category;
/**
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
+ * @var Context|MockObject
*/
protected $contextMock;
/**
- * @var Select|\PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
private $selectMock;
/**
- * @var Adapter|\PHPUnit_Framework_MockObject_MockObject
+ * @var Adapter|MockObject
*/
private $connectionMock;
/**
- * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceMock;
/**
- * @var Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $eavConfigMock;
/**
- * @var Type|\PHPUnit_Framework_MockObject_MockObject
+ * @var Type|MockObject
*/
private $entityType;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManagerMock;
/**
- * @var Factory|\PHPUnit_Framework_MockObject_MockObject
+ * @var Factory|MockObject
*/
protected $factoryMock;
/**
- * @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
protected $managerMock;
/**
- * @var Category\TreeFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var Category\TreeFactory|MockObject
*/
protected $treeFactoryMock;
/**
- * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
protected $collectionFactoryMock;
/**
- * @var Json|\PHPUnit_Framework_MockObject_MockObject
+ * @var Json|MockObject
*/
private $serializerMock;
/**
- * @var Processor|\PHPUnit_Framework_MockObject_MockObject
+ * @var Processor|MockObject
*/
private $indexerProcessorMock;
/**
* {@inheritDoc}
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->selectMock = $this->getMockBuilder(Select::class)->disableOriginalConstructor()->getMock();
$this->selectMock->expects($this->at(2))->method('where')->willReturnSelf();
@@ -121,7 +125,7 @@ protected function setUp()
$this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)->getMock();
$this->factoryMock = $this->getMockBuilder(Factory::class)->disableOriginalConstructor()->getMock();
$this->managerMock = $this->getMockBuilder(ManagerInterface::class)->getMock();
- $this->treeFactoryMock = $this->getMockBuilder(Category\TreeFactory::class)
+ $this->treeFactoryMock = $this->getMockBuilder(TreeFactory::class)
->disableOriginalConstructor()
->getMock();
$this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ConfigTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ConfigTest.php
index abbcef942373e..0007da6dbeb3d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ConfigTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ConfigTest.php
@@ -3,46 +3,56 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel;
+use Magento\Catalog\Model\ResourceModel\Config;
+use Magento\Eav\Model\Entity\Type;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test for Magento\Catalog\Model\ResourceModel\Config
*/
-class ConfigTest extends \PHPUnit\Framework\TestCase
+class ConfigTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Config
+ * @var Config
*/
private $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $resource;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $storeManager;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $eavConfig;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
- $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->resource = $this->createMock(ResourceConnection::class);
+ $this->storeManager = $this->createMock(StoreManagerInterface::class);
$this->eavConfig = $this->createMock(\Magento\Eav\Model\Config::class);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\ResourceModel\Config::class,
+ Config::class,
[
'resource' => $this->resource,
'storeManager' => $this->storeManager,
@@ -59,10 +69,10 @@ public function testGetAttributesUsedForSortBy()
$storeId = 1;
$entityTypeId = 4;
- $connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
- $selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
- $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class);
- $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class);
+ $connectionMock = $this->createMock(AdapterInterface::class);
+ $selectMock = $this->createMock(Select::class);
+ $storeMock = $this->createMock(StoreInterface::class);
+ $entityTypeMock = $this->createMock(Type::class);
$this->resource->expects($this->atLeastOnce())->method('getConnection')->willReturn($connectionMock);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Eav/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Eav/AttributeTest.php
index 30f410501206d..df1968a973245 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Eav/AttributeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Eav/AttributeTest.php
@@ -3,21 +3,36 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Eav;
+use Magento\Catalog\Model\Indexer\Product\Flat\Processor;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
+use Magento\Framework\App\CacheInterface;
+use Magento\Framework\DB\Adapter\Pdo\Mysql;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\Model\ActionValidator\RemoveAction;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class AttributeTest extends \PHPUnit\Framework\TestCase
+class AttributeTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute
+ * @var Attribute
*/
protected $_model;
/**
- * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor
+ * @var Processor
*/
protected $_processor;
@@ -27,35 +42,35 @@ class AttributeTest extends \PHPUnit\Framework\TestCase
protected $_eavProcessor;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $contextMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $resourceMock;
/**
- * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
protected $eavConfigMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_processor = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\Processor::class);
+ $this->_processor = $this->createMock(Processor::class);
$this->_eavProcessor = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Eav\Processor::class);
- $eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
+ $eventManagerMock = $this->createMock(ManagerInterface::class);
- $cacheInterfaceMock = $this->createMock(\Magento\Framework\App\CacheInterface::class);
+ $cacheInterfaceMock = $this->createMock(CacheInterface::class);
- $actionValidatorMock = $this->createMock(\Magento\Framework\Model\ActionValidator\RemoveAction::class);
+ $actionValidatorMock = $this->createMock(RemoveAction::class);
$actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true));
$this->contextMock = $this->createPartialMock(
- \Magento\Framework\Model\Context::class,
+ Context::class,
['getEventDispatcher', 'getCacheManager', 'getActionValidator']
);
@@ -68,12 +83,12 @@ protected function setUp()
$this->contextMock->expects($this->any())->method('getActionValidator')
->will($this->returnValue($actionValidatorMock));
- $dbAdapterMock = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class);
+ $dbAdapterMock = $this->createMock(Mysql::class);
$dbAdapterMock->expects($this->any())->method('getTransactionLevel')->will($this->returnValue(1));
$this->resourceMock = $this->createPartialMock(
- \Magento\Framework\Model\ResourceModel\AbstractResource::class,
+ AbstractResource::class,
[
'_construct',
'getConnection',
@@ -85,7 +100,7 @@ protected function setUp()
]
);
- $this->eavConfigMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class)
+ $this->eavConfigMock = $this->getMockBuilder(Config::class)
->setMethods(['clear'])
->disableOriginalConstructor()
->getMock();
@@ -94,9 +109,9 @@ protected function setUp()
->method('getConnection')
->will($this->returnValue($dbAdapterMock));
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->_model = $objectManager->getObject(
- \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class,
+ Attribute::class,
[
'context' => $this->contextMock,
'productFlatIndexerProcessor' => $this->_processor,
@@ -124,10 +139,10 @@ public function testIndexerAfterSaveScopeChangeAttribute()
$this->_model->setOrigData(
'is_global',
- \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE
+ ScopedAttributeInterface::SCOPE_STORE
);
$this->_model->setOrigData('used_in_product_listing', 1);
- $this->_model->setIsGlobal(\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL);
+ $this->_model->setIsGlobal(ScopedAttributeInterface::SCOPE_GLOBAL);
$this->_model->afterSave();
}
@@ -157,16 +172,16 @@ public function testAfterDeleteEavCache()
public function testGetScopeGlobal()
{
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
$this->_model = $objectManagerHelper->getObject(
- \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class,
+ Attribute::class,
[
'context' => $this->contextMock,
'productFlatIndexerProcessor' => $this->_processor,
'indexerEavProcessor' => $this->_eavProcessor,
'resource' => $this->resourceMock,
'data' => [
- 'is_global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL
+ 'is_global' => ScopedAttributeInterface::SCOPE_GLOBAL
]
]
);
@@ -175,16 +190,16 @@ public function testGetScopeGlobal()
public function testGetScopeWebsite()
{
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
$this->_model = $objectManagerHelper->getObject(
- \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class,
+ Attribute::class,
[
'context' => $this->contextMock,
'productFlatIndexerProcessor' => $this->_processor,
'indexerEavProcessor' => $this->_eavProcessor,
'resource' => $this->resourceMock,
'data' => [
- 'is_global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE
+ 'is_global' => ScopedAttributeInterface::SCOPE_WEBSITE
]
]
);
@@ -193,9 +208,9 @@ public function testGetScopeWebsite()
public function testGetScopeStore()
{
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
$this->_model = $objectManagerHelper->getObject(
- \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class,
+ Attribute::class,
[
'context' => $this->contextMock,
'productFlatIndexerProcessor' => $this->_processor,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Indexer/ActiveTableSwitcherTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Indexer/ActiveTableSwitcherTest.php
index 86c11249ff8b7..7ba2811774d25 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Indexer/ActiveTableSwitcherTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Indexer/ActiveTableSwitcherTest.php
@@ -3,24 +3,29 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Indexer;
-class ActiveTableSwitcherTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use PHPUnit\Framework\TestCase;
+
+class ActiveTableSwitcherTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher
+ * @var ActiveTableSwitcher
*/
private $model;
- protected function setUp()
+ protected function setUp(): void
{
- $this->model = new \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher();
+ $this->model = new ActiveTableSwitcher();
}
public function testSwitch()
{
- $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
+ $connectionMock = $this->getMockBuilder(AdapterInterface::class)
->disableOriginalConstructor()
->getMock();
$tableName = 'tableName';
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/ActionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/ActionTest.php
index 0027fd9fecc11..56d1f70730456 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/ActionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/ActionTest.php
@@ -3,11 +3,11 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
-use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Factory;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Edit\WeightResolver;
@@ -101,7 +101,7 @@ class ActionTest extends TestCase
*/
private $productCollectionMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->contextMock = $this->getMockBuilder(Context::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php
index 5a1a5906ec4b9..bc46597905694 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php
@@ -3,13 +3,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product;
+use Magento\Catalog\Api\Data\CategoryInterface;
+use Magento\Catalog\Api\Data\CategoryLinkInterface;
+use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\ResourceModel\Product\CategoryLink;
-use \PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use Magento\Framework\EntityManager\EntityMetadataInterface;
+use Magento\Framework\EntityManager\MetadataPool;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CategoryLinkTest extends \PHPUnit\Framework\TestCase
+class CategoryLinkTest extends TestCase
{
/**
* @var CategoryLink
@@ -17,31 +27,31 @@ class CategoryLinkTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var \Magento\Framework\App\ResourceConnection|MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceMock;
/**
- * @var \Magento\Framework\EntityManager\MetadataPool|MockObject
+ * @var MetadataPool|MockObject
*/
private $metadataPoolMock;
/**
- * @var \Magento\Framework\DB\Select|MockObject
+ * @var Select|MockObject
*/
private $dbSelectMock;
/**
- * @var \Magento\Framework\DB\Adapter\AdapterInterface|MockObject
+ * @var AdapterInterface|MockObject
*/
private $connectionMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->resourceMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class)
+ $this->resourceMock = $this->getMockBuilder(ResourceConnection::class)
->disableOriginalConstructor()
->getMock();
- $this->metadataPoolMock = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class)
+ $this->metadataPoolMock = $this->getMockBuilder(MetadataPool::class)
->disableOriginalConstructor()
->getMock();
@@ -53,10 +63,10 @@ protected function setUp()
private function prepareAdapter()
{
- $this->dbSelectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $this->dbSelectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
- $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
+ $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
->getMockForAbstractClass();
$this->connectionMock->expects($this->any())->method('select')->willReturn($this->dbSelectMock);
$this->resourceMock->expects($this->any())
@@ -66,16 +76,16 @@ private function prepareAdapter()
private function prepareMetadata()
{
- $categoryLinkMetadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadataInterface::class)
+ $categoryLinkMetadata = $this->getMockBuilder(EntityMetadataInterface::class)
->getMockForAbstractClass();
$categoryLinkMetadata->expects($this->any())->method('getEntityTable')->willReturn('category_link_table');
- $categoryEntityMetadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadataInterface::class)
+ $categoryEntityMetadata = $this->getMockBuilder(EntityMetadataInterface::class)
->getMockForAbstractClass();
$categoryEntityMetadata->expects($this->any())->method('getEntityTable')->willReturn('category_entity_table');
$this->metadataPoolMock->expects($this->any())->method('getMetadata')->willReturnMap(
[
- [\Magento\Catalog\Api\Data\CategoryLinkInterface::class, $categoryLinkMetadata],
- [\Magento\Catalog\Api\Data\CategoryInterface::class, $categoryEntityMetadata],
+ [CategoryLinkInterface::class, $categoryLinkMetadata],
+ [CategoryInterface::class, $categoryEntityMetadata],
]
);
}
@@ -84,7 +94,7 @@ public function testGetCategoryLinks()
{
$this->prepareAdapter();
$this->prepareMetadata();
- $product = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)->getMockForAbstractClass();
+ $product = $this->getMockBuilder(ProductInterface::class)->getMockForAbstractClass();
$product->expects($this->any())->method('getId')->willReturn(1);
$this->connectionMock->expects($this->once())->method('fetchAll')->with($this->dbSelectMock)->willReturn(
[
@@ -112,7 +122,7 @@ public function testSaveCategoryLinks($newCategoryLinks, $dbCategoryLinks, $affe
{
$this->prepareAdapter();
$this->prepareMetadata();
- $product = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)->getMockForAbstractClass();
+ $product = $this->getMockBuilder(ProductInterface::class)->getMockForAbstractClass();
$product->expects($this->any())->method('getId')->willReturn(1);
$this->connectionMock->expects($this->once())
->method('fetchAll')
@@ -133,6 +143,7 @@ public function testSaveCategoryLinks($newCategoryLinks, $dbCategoryLinks, $affe
$expectedResult = [];
foreach ($affectedIds as $type => $ids) {
+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
$expectedResult = array_merge($expectedResult, $ids);
// Verify if the correct insert, update and/or delete actions are performed:
$this->setupExpectationsForConnection($type, $ids);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Collection/ProductLimitationTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Collection/ProductLimitationTest.php
index 2123e8a904415..9d0978e9c0316 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Collection/ProductLimitationTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Collection/ProductLimitationTest.php
@@ -3,22 +3,22 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Collection;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-/**
- * Class ProductLimitationTest
- */
-class ProductLimitationTest extends \PHPUnit\Framework\TestCase
+class ProductLimitationTest extends TestCase
{
/**
* @var ProductLimitation
*/
protected $productLimitation;
- protected function setUp()
+ protected function setUp(): void
{
$helper = new ObjectManager($this);
$this->productLimitation = $helper->getObject(ProductLimitation::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php
index 0316b2e374d2f..dad8d3db78d0a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php
@@ -3,146 +3,181 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product;
+use Magento\Catalog\Model\Indexer\Product\Flat\State;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Attribute\Backend\Tierprice;
+use Magento\Catalog\Model\Product\Gallery\ReadHandler;
+use Magento\Catalog\Model\Product\OptionFactory;
+use Magento\Catalog\Model\ResourceModel\Helper;
+use Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\GroupPrice\AbstractGroupPrice;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation;
use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory;
+use Magento\Catalog\Model\ResourceModel\Product\Gallery;
+use Magento\Catalog\Model\ResourceModel\Url;
+use Magento\Customer\Api\GroupManagementInterface;
+use Magento\Customer\Model\Session;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\AbstractEntity;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
+use Magento\Framework\Data\Collection\EntityFactory;
+use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Select;
+use Magento\Framework\EntityManager\EntityMetadataInterface;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\Module\Manager;
+use Magento\Framework\Stdlib\DateTime;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\Validator\UniversalFactory;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CollectionTest extends \PHPUnit\Framework\TestCase
+class CollectionTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManager;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $selectMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $connectionMock;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Collection
+ * @var Collection
*/
protected $collection;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $galleryResourceMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $entityMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $metadataPoolMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $galleryReadHandlerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $storeManager;
/**
- * @var \Magento\Framework\Data\Collection\EntityFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var EntityFactory|MockObject
*/
private $entityFactory;
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->entityFactory = $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class);
- $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)
+ $this->objectManager = new ObjectManager($this);
+ $this->entityFactory = $this->createMock(EntityFactory::class);
+ $logger = $this->getMockBuilder(LoggerInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $fetchStrategy = $this->getMockBuilder(\Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class)
+ $fetchStrategy = $this->getMockBuilder(FetchStrategyInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $eventManager = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class)
+ $eventManager = $this->getMockBuilder(ManagerInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $eavConfig = $this->getMockBuilder(\Magento\Eav\Model\Config::class)
+ $eavConfig = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
- $resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class)
+ $resource = $this->getMockBuilder(ResourceConnection::class)
->disableOriginalConstructor()
->getMock();
$eavEntityFactory = $this->getMockBuilder(\Magento\Eav\Model\EntityFactory::class)
->disableOriginalConstructor()
->getMock();
- $resourceHelper = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Helper::class)
+ $resourceHelper = $this->getMockBuilder(Helper::class)
->disableOriginalConstructor()
->getMock();
- $universalFactory = $this->getMockBuilder(\Magento\Framework\Validator\UniversalFactory::class)
+ $universalFactory = $this->getMockBuilder(UniversalFactory::class)
->disableOriginalConstructor()
->getMock();
- $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ $this->storeManager = $this->getMockBuilder(StoreManagerInterface::class)
->disableOriginalConstructor()
->setMethods(['getStore', 'getId', 'getWebsiteId'])
->getMockForAbstractClass();
- $moduleManager = $this->getMockBuilder(\Magento\Framework\Module\Manager::class)
+ $moduleManager = $this->getMockBuilder(Manager::class)
->disableOriginalConstructor()
->getMock();
- $catalogProductFlatState = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Flat\State::class)
+ $catalogProductFlatState = $this->getMockBuilder(State::class)
->disableOriginalConstructor()
->getMock();
- $scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
+ $scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $productOptionFactory = $this->getMockBuilder(\Magento\Catalog\Model\Product\OptionFactory::class)
+ $productOptionFactory = $this->getMockBuilder(OptionFactory::class)
->disableOriginalConstructor()
->getMock();
- $catalogUrl = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Url::class)
+ $catalogUrl = $this->getMockBuilder(Url::class)
->disableOriginalConstructor()
->getMock();
- $localeDate = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class)
+ $localeDate = $this->getMockBuilder(TimezoneInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $customerSession = $this->getMockBuilder(\Magento\Customer\Model\Session::class)
+ $customerSession = $this->getMockBuilder(Session::class)
->disableOriginalConstructor()
->getMock();
- $dateTime = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime::class)
+ $dateTime = $this->getMockBuilder(DateTime::class)
->disableOriginalConstructor()
->getMock();
- $groupManagement = $this->getMockBuilder(\Magento\Customer\Api\GroupManagementInterface::class)
+ $groupManagement = $this->getMockBuilder(GroupManagementInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
+ $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
->setMethods(['getId'])
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $this->selectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
- $this->entityMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\AbstractEntity::class)
+ $this->entityMock = $this->getMockBuilder(AbstractEntity::class)
->disableOriginalConstructor()
->getMock();
$this->galleryResourceMock = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Product\Gallery::class
+ Gallery::class
)->disableOriginalConstructor()->getMock();
$this->metadataPoolMock = $this->getMockBuilder(
- \Magento\Framework\EntityManager\MetadataPool::class
+ MetadataPool::class
)->disableOriginalConstructor()->getMock();
$this->galleryReadHandlerMock = $this->getMockBuilder(
- \Magento\Catalog\Model\Product\Gallery\ReadHandler::class
+ ReadHandler::class
)->disableOriginalConstructor()->getMock();
$this->storeManager->expects($this->any())->method('getId')->willReturn(1);
$this->storeManager->expects($this->any())->method('getStore')->willReturnSelf();
@@ -155,7 +190,7 @@ protected function setUp()
$this->connectionMock->expects($this->atLeastOnce())->method('select')->willReturn($this->selectMock);
$productLimitationMock = $this->createMock(
- \Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation::class
+ ProductLimitation::class
);
$productLimitationFactoryMock = $this->getMockBuilder(
ProductLimitationFactory::class
@@ -164,7 +199,7 @@ protected function setUp()
$productLimitationFactoryMock->method('create')
->willReturn($productLimitationMock);
$this->collection = $this->objectManager->getObject(
- \Magento\Catalog\Model\ResourceModel\Product\Collection::class,
+ Collection::class,
[
'entityFactory' => $this->entityFactory,
'logger' => $logger,
@@ -236,17 +271,17 @@ public function testAddMediaGalleryData()
$rowId = 4;
$linkField = 'row_id';
$mediaGalleriesMock = [[$linkField => $rowId]];
- $itemMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $itemMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->setMethods(['getOrigData'])
->getMock();
- $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $attributeMock = $this->getMockBuilder(AbstractAttribute::class)
->disableOriginalConstructor()
->getMock();
- $selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $selectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
- $metadataMock = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadataInterface::class)
+ $metadataMock = $this->getMockBuilder(EntityMetadataInterface::class)
->disableOriginalConstructor()
->getMock();
$this->collection->addItem($itemMock);
@@ -278,23 +313,23 @@ public function testAddMediaGalleryData()
public function testAddTierPriceDataByGroupId()
{
$customerGroupId = 2;
- $itemMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $itemMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->setMethods(['getData'])
->getMock();
- $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $attributeMock = $this->getMockBuilder(AbstractAttribute::class)
->disableOriginalConstructor()
->setMethods(['isScopeGlobal', 'getBackend'])
->getMock();
- $backend = $this->getMockBuilder(\Magento\Catalog\Model\Product\Attribute\Backend\Tierprice::class)
+ $backend = $this->getMockBuilder(Tierprice::class)
->disableOriginalConstructor()
->getMock();
$resource = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\GroupPrice\AbstractGroupPrice::class
+ AbstractGroupPrice::class
)
->disableOriginalConstructor()
->getMock();
- $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $select = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
$this->connectionMock->expects($this->once())->method('getAutoIncrementField')->willReturn('entity_id');
@@ -333,23 +368,23 @@ public function testAddTierPriceDataByGroupId()
*/
public function testAddTierPriceData()
{
- $itemMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $itemMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->setMethods(['getData'])
->getMock();
- $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $attributeMock = $this->getMockBuilder(AbstractAttribute::class)
->disableOriginalConstructor()
->setMethods(['isScopeGlobal', 'getBackend'])
->getMock();
- $backend = $this->getMockBuilder(\Magento\Catalog\Model\Product\Attribute\Backend\Tierprice::class)
+ $backend = $this->getMockBuilder(Tierprice::class)
->disableOriginalConstructor()
->getMock();
$resource = $this->getMockBuilder(
- \Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\GroupPrice\AbstractGroupPrice::class
+ AbstractGroupPrice::class
)
->disableOriginalConstructor()
->getMock();
- $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $select = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
$this->connectionMock->expects($this->once())->method('getAutoIncrementField')->willReturn('entity_id');
@@ -385,7 +420,7 @@ public function testAddTierPriceData()
*/
public function testGetNewEmptyItem()
{
- $item = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $item = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
$this->entityFactory->expects($this->once())->method('create')->willReturn($item);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CompositeBaseSelectProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CompositeBaseSelectProcessorTest.php
index f115654f73ca8..8a3943f44a932 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CompositeBaseSelectProcessorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CompositeBaseSelectProcessorTest.php
@@ -3,30 +3,31 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product;
use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface;
use Magento\Catalog\Model\ResourceModel\Product\CompositeBaseSelectProcessor;
use Magento\Framework\DB\Select;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class CompositeBaseSelectProcessorTest extends \PHPUnit\Framework\TestCase
+class CompositeBaseSelectProcessorTest extends TestCase
{
/**
* @var ObjectManager
*/
private $objectManager;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
}
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- */
public function testInitializeWithWrongProcessorInstance()
{
+ $this->expectException('Magento\Framework\Exception\InputException');
$processorValid = $this->createMock(BaseSelectProcessorInterface::class);
$processorInvalid = $this->createMock(\stdClass::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/FlatTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/FlatTest.php
index 638d455c31826..950f29fc0a8fa 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/FlatTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/FlatTest.php
@@ -3,30 +3,40 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product;
-class FlatTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Config;
+use Magento\Catalog\Model\Product\Attribute\DefaultAttributes;
+use Magento\Catalog\Model\ResourceModel\Product\Flat;
+use Magento\Framework\Model\ResourceModel\Db\Context;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\TestCase;
+
+class FlatTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Flat
+ * @var Flat
*/
protected $_model;
/**
- * @var \Magento\Store\Model\Store
+ * @var Store
*/
protected $_store;
/**
- * @var \Magento\Store\Model\StoreManagerInterface
+ * @var StoreManagerInterface
*/
protected $_storeManagerInterface;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_store = $this->createMock(\Magento\Store\Model\Store::class);
+ $this->_store = $this->createMock(Store::class);
- $this->_storeManagerInterface = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->_storeManagerInterface = $this->createMock(StoreManagerInterface::class);
$this->_storeManagerInterface->expects(
$this->any()
@@ -44,11 +54,11 @@ protected function setUp()
$this->returnValue($this->_store)
);
- $this->_model = new \Magento\Catalog\Model\ResourceModel\Product\Flat(
- $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class),
+ $this->_model = new Flat(
+ $this->createMock(Context::class),
$this->_storeManagerInterface,
- $this->createMock(\Magento\Catalog\Model\Config::class),
- $this->createMock(\Magento\Catalog\Model\Product\Attribute\DefaultAttributes::class)
+ $this->createMock(Config::class),
+ $this->createMock(DefaultAttributes::class)
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/GalleryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/GalleryTest.php
index 47ef3c999125f..02b32a7109d5a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/GalleryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/GalleryTest.php
@@ -3,35 +3,51 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product;
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ResourceModel\Product\Gallery;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Adapter\Pdo\Mysql;
+use Magento\Framework\DB\Select;
+use Magento\Framework\EntityManager\EntityMetadata;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
* Unit test for product media gallery resource.
*/
-class GalleryTest extends \PHPUnit\Framework\TestCase
+class GalleryTest extends TestCase
{
/**
- * @var \Magento\Framework\DB\Adapter\AdapterInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
protected $connection;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Gallery | \PHPUnit_Framework_MockObject_MockObject
+ * @var Gallery|MockObject
*/
protected $resource;
/**
- * @var \Magento\Catalog\Model\Product | \PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
protected $product;
/**
- * @var \Magento\Framework\DB\Select | \PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
protected $select;
/**
- * @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute | \PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractAttribute|MockObject
*/
protected $attribute;
@@ -48,15 +64,15 @@ class GalleryTest extends \PHPUnit\Framework\TestCase
'metadata' => ['DATA_TYPE' => 'text', 'NULLABLE' => true],
];
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
- $this->connection = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class);
+ $this->connection = $this->createMock(Mysql::class);
$this->connection->expects($this->any())
->method('setCacheAdapter');
- $metadata = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class);
+ $metadata = $this->createMock(EntityMetadata::class);
$metadata->expects($this->any())
->method('getLinkField')
->willReturn('entity_id');
@@ -64,24 +80,24 @@ protected function setUp()
->method('getEntityConnection')
->willReturn($this->connection);
- $metadataPool = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class);
+ $metadataPool = $this->createMock(MetadataPool::class);
$metadataPool->expects($this->once())
->method('getMetadata')
- ->with(\Magento\Catalog\Api\Data\ProductInterface::class)
+ ->with(ProductInterface::class)
->willReturn($metadata);
- $resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
+ $resource = $this->createMock(ResourceConnection::class);
$resource->expects($this->any())->method('getTableName')->willReturn('table');
$this->resource = $objectManager->getObject(
- \Magento\Catalog\Model\ResourceModel\Product\Gallery::class,
+ Gallery::class,
[
'metadataPool' => $metadataPool,
'resource' => $resource
]
);
- $this->product = $this->createMock(\Magento\Catalog\Model\Product::class);
- $this->select = $this->createMock(\Magento\Framework\DB\Select::class);
- $this->attribute = $this->createMock(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class);
+ $this->product = $this->createMock(Product::class);
+ $this->select = $this->createMock(Select::class);
+ $this->attribute = $this->createMock(AbstractAttribute::class);
}
public function testLoadDataFromTableByValueId()
@@ -389,7 +405,7 @@ public function testLoadGallery()
->with('entity.entity_id = ?', $productId)
->willReturnSelf();
$this->select->expects($this->once())->method('order')
- ->with($positionCheckSql . ' ' . \Magento\Framework\DB\Select::SQL_ASC)
+ ->with($positionCheckSql . ' ' . Select::SQL_ASC)
->willReturnSelf();
$this->connection->expects($this->once())->method('fetchAll')
->with($this->select)
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/ImageTest.php
index af2cb6f06ed5a..647b235b08bbe 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/ImageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/ImageTest.php
@@ -7,23 +7,21 @@
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product;
+use Magento\Catalog\Model\ResourceModel\Product\Gallery;
use Magento\Catalog\Model\ResourceModel\Product\Image;
+use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Query\BatchIteratorInterface;
use Magento\Framework\DB\Query\Generator;
use Magento\Framework\DB\Select;
-use Magento\Framework\App\ResourceConnection;
-use Magento\Catalog\Model\ResourceModel\Product\Gallery;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
-use Magento\Framework\DB\Query\BatchIteratorInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class ImageTest
- * @package Magento\Catalog\Test\Unit\Model\ResourceModel\Product
- */
-class ImageTest extends \PHPUnit\Framework\TestCase
+class ImageTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManager;
@@ -45,7 +43,7 @@ class ImageTest extends \PHPUnit\Framework\TestCase
protected function setUp(): void
{
$this->objectManager =
- new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ new ObjectManager($this);
$this->connectionMock = $this->createMock(AdapterInterface::class);
$this->resourceMock = $this->createMock(ResourceConnection::class);
$this->resourceMock->method('getConnection')
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Eav/BatchSizeCalculatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Eav/BatchSizeCalculatorTest.php
index fb44b65b0ee11..73191971d0607 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Eav/BatchSizeCalculatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Eav/BatchSizeCalculatorTest.php
@@ -3,14 +3,16 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer\Eav;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\BatchSizeCalculator;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Indexer\BatchSizeManagement;
-use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\BatchSizeCalculator;
+use PHPUnit\Framework\TestCase;
-class BatchSizeCalculatorTest extends \PHPUnit\Framework\TestCase
+class BatchSizeCalculatorTest extends TestCase
{
public function testEstimateBatchSize()
{
@@ -34,11 +36,9 @@ public function testEstimateBatchSize()
$this->assertEquals($batchSizes[$indexerId], $model->estimateBatchSize($connectionMock, $indexerId));
}
- /**
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- */
public function testEstimateBatchSizeThrowsExceptionIfIndexerIdIsNotRecognized()
{
+ $this->expectException('Magento\Framework\Exception\NoSuchEntityException');
$model = new BatchSizeCalculator(
[],
[]
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Eav/DecimalRowSizeEstimatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Eav/DecimalRowSizeEstimatorTest.php
index 643d0ae3899ca..0c052c55c8e5a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Eav/DecimalRowSizeEstimatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Eav/DecimalRowSizeEstimatorTest.php
@@ -3,19 +3,22 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer\Eav;
-use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalRowSizeEstimator;
-use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Decimal;
-use Magento\Store\Api\StoreManagementInterface;
-use Magento\Framework\EntityManager\MetadataPool;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\Decimal;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\DecimalRowSizeEstimator;
use Magento\Framework\DB\Adapter\AdapterInterface;
-use Magento\Framework\EntityManager\EntityMetadataInterface;
use Magento\Framework\DB\Select;
+use Magento\Framework\EntityManager\EntityMetadataInterface;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Store\Api\StoreManagementInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class DecimalRowSizeEstimatorTest extends \PHPUnit\Framework\TestCase
+class DecimalRowSizeEstimatorTest extends TestCase
{
/**
* @var DecimalRowSizeEstimator
@@ -23,26 +26,26 @@ class DecimalRowSizeEstimatorTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $indexerResourceMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $storeManagementMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $metadataPoolMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $connectionMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->connectionMock = $this->createMock(AdapterInterface::class);
$this->indexerResourceMock = $this->createMock(Decimal::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPriceTest.php
index 945c61f44e99c..a668217f1fec2 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPriceTest.php
@@ -3,90 +3,106 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer;
use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\LinkedProductSelectBuilderByIndexPrice;
+use Magento\Customer\Model\Session;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use Magento\Framework\EntityManager\EntityMetadataInterface;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Indexer\Dimension;
+use Magento\Framework\Indexer\DimensionFactory;
+use Magento\Framework\Search\Request\IndexScopeResolverInterface;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class LinkedProductSelectBuilderByIndexPriceTest extends \PHPUnit\Framework\TestCase
+class LinkedProductSelectBuilderByIndexPriceTest extends TestCase
{
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManagerMock;
/**
- * @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var ResourceConnection|MockObject
*/
private $resourceMock;
/**
- * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject
+ * @var Session|MockObject
*/
private $customerSessionMock;
/**
- * @var \Magento\Framework\EntityManager\MetadataPool|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataPool|MockObject
*/
private $metadataPoolMock;
/**
- * @var BaseSelectProcessorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var BaseSelectProcessorInterface|MockObject
*/
private $baseSelectProcessorMock;
/**
- * @var \Magento\Framework\Search\Request\IndexScopeResolverInterface|\PHPUnit\Framework\MockObject\MockObject
+ * @var IndexScopeResolverInterface|MockObject
*/
private $indexScopeResolverMock;
/**
- * @var \Magento\Framework\Indexer\Dimension|\PHPUnit\Framework\MockObject\MockObject
+ * @var Dimension|MockObject
*/
private $dimensionMock;
/**
- * @var \Magento\Framework\Indexer\DimensionFactory|\PHPUnit\Framework\MockObject\MockObject
+ * @var DimensionFactory|MockObject
*/
private $dimensionFactoryMock;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\LinkedProductSelectBuilderByIndexPrice
+ * @var LinkedProductSelectBuilderByIndexPrice
*/
private $model;
- protected function setUp()
+ protected function setUp(): void
{
- $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->resourceMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class)
+ $this->resourceMock = $this->getMockBuilder(ResourceConnection::class)
->disableOriginalConstructor()->getMock();
- $this->customerSessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class)
+ $this->customerSessionMock = $this->getMockBuilder(Session::class)
->disableOriginalConstructor()
->getMock();
- $this->metadataPoolMock = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class)
+ $this->metadataPoolMock = $this->getMockBuilder(MetadataPool::class)
->disableOriginalConstructor()
->getMock();
$this->baseSelectProcessorMock =
- $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface::class)
+ $this->getMockBuilder(BaseSelectProcessorInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->indexScopeResolverMock = $this->createMock(
- \Magento\Framework\Search\Request\IndexScopeResolverInterface::class
+ IndexScopeResolverInterface::class
);
- $this->dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class);
- $this->dimensionFactoryMock = $this->createMock(\Magento\Framework\Indexer\DimensionFactory::class);
+ $this->dimensionMock = $this->createMock(Dimension::class);
+ $this->dimensionFactoryMock = $this->createMock(DimensionFactory::class);
$this->dimensionFactoryMock->method('create')->willReturn($this->dimensionMock);
- $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class);
+ $storeMock = $this->createMock(StoreInterface::class);
$storeMock->method('getId')->willReturn(1);
$storeMock->method('getWebsiteId')->willReturn(1);
$this->storeManagerMock->method('getStore')->willReturn($storeMock);
- $this->model = new \Magento\Catalog\Model\ResourceModel\Product\Indexer\LinkedProductSelectBuilderByIndexPrice(
+ $this->model = new LinkedProductSelectBuilderByIndexPrice(
$this->storeManagerMock,
$this->resourceMock,
$this->customerSessionMock,
@@ -101,15 +117,15 @@ public function testBuild()
{
$productId = 10;
$storeId = 1;
- $metadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadataInterface::class)
+ $metadata = $this->getMockBuilder(EntityMetadataInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
+ $connection = $this->getMockBuilder(AdapterInterface::class)
->getMockForAbstractClass();
- $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $select = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
- $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
+ $storeMock = $this->getMockBuilder(StoreInterface::class)
->getMockForAbstractClass();
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
$this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->willReturn(1);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/BatchSizeCalculatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/BatchSizeCalculatorTest.php
index 9508782cb4a99..151902cf29974 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/BatchSizeCalculatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/BatchSizeCalculatorTest.php
@@ -3,18 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer\Price;
-class BatchSizeCalculatorTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\Indexer\BatchSizeManagementInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class BatchSizeCalculatorTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator
+ * @var BatchSizeCalculator
*/
private $model;
/**
- * @var \Magento\Framework\Indexer\BatchSizeManagementInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var BatchSizeManagementInterface|MockObject
*/
private $estimatorMock;
@@ -23,11 +30,11 @@ class BatchSizeCalculatorTest extends \PHPUnit\Framework\TestCase
*/
private $batchRowsCount;
- protected function setUp()
+ protected function setUp(): void
{
- $this->estimatorMock = $this->createMock(\Magento\Framework\Indexer\BatchSizeManagementInterface::class);
+ $this->estimatorMock = $this->createMock(BatchSizeManagementInterface::class);
$this->batchRowsCount = 200;
- $this->model = new \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator(
+ $this->model = new BatchSizeCalculator(
['default' => $this->batchRowsCount],
['default' => $this->estimatorMock],
[]
@@ -36,7 +43,7 @@ protected function setUp()
public function testEstimateBatchSize()
{
- $connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
+ $connectionMock = $this->createMock(AdapterInterface::class);
$typeId = 'default';
$batchSize = 100500;
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductBatchSizeAdjusterTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductBatchSizeAdjusterTest.php
index 69def72af1669..01913edb61715 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductBatchSizeAdjusterTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductBatchSizeAdjusterTest.php
@@ -3,13 +3,16 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer\Price;
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductBatchSizeAdjuster;
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductRelationsCalculator;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CompositeProductBatchSizeAdjusterTest extends \PHPUnit\Framework\TestCase
+class CompositeProductBatchSizeAdjusterTest extends TestCase
{
/**
* @var CompositeProductBatchSizeAdjuster
@@ -17,11 +20,11 @@ class CompositeProductBatchSizeAdjusterTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|CompositeProductRelationsCalculator
+ * @var MockObject|CompositeProductRelationsCalculator
*/
private $relationsCalculatorMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->relationsCalculatorMock = $this->getMockBuilder(CompositeProductRelationsCalculator::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductRelationsCalculatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductRelationsCalculatorTest.php
index 3eda8616275a1..b125e54211cb0 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductRelationsCalculatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductRelationsCalculatorTest.php
@@ -3,16 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer\Price;
-use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice;
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductRelationsCalculator;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CompositeProductRelationsCalculatorTest extends \PHPUnit\Framework\TestCase
+class CompositeProductRelationsCalculatorTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|DefaultPrice
+ * @var MockObject|DefaultPrice
*/
private $defaultPriceMock;
@@ -21,7 +26,7 @@ class CompositeProductRelationsCalculatorTest extends \PHPUnit\Framework\TestCas
*/
private $model;
- protected function setUp()
+ protected function setUp(): void
{
$this->defaultPriceMock = $this->getMockBuilder(DefaultPrice::class)->disableOriginalConstructor()->getMock();
$this->model = new CompositeProductRelationsCalculator($this->defaultPriceMock);
@@ -32,11 +37,11 @@ public function testGetMaxRelationsCount()
$tableName = 'catalog_product_relation';
$maxRelatedProductCount = 200;
- $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)->getMock();
+ $connectionMock = $this->getMockBuilder(AdapterInterface::class)->getMock();
$this->defaultPriceMock->expects($this->once())->method('getConnection')->willReturn($connectionMock);
$this->defaultPriceMock->expects($this->once())->method('getTable')->with($tableName)->willReturn($tableName);
- $relationSelectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $relationSelectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
$relationSelectMock->expects($this->once())
@@ -49,7 +54,7 @@ public function testGetMaxRelationsCount()
$relationSelectMock->expects($this->once())->method('group')->with('parent_id')->willReturnSelf();
$connectionMock->expects($this->at(0))->method('select')->willReturn($relationSelectMock);
- $maxSelectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $maxSelectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
$maxSelectMock->expects($this->once())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductRowSizeEstimatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductRowSizeEstimatorTest.php
index 728044b89cafe..5d0702661f164 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductRowSizeEstimatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductRowSizeEstimatorTest.php
@@ -3,12 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer\Price;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductRelationsCalculator;
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductRowSizeEstimator;
+use Magento\Customer\Model\ResourceModel\Group\Collection;
+use Magento\Customer\Model\ResourceModel\Group\CollectionFactory;
+use Magento\Store\Api\WebsiteManagementInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CompositeProductRowSizeEstimatorTest extends \PHPUnit\Framework\TestCase
+class CompositeProductRowSizeEstimatorTest extends TestCase
{
/**
* @var CompositeProductRowSizeEstimator
@@ -16,29 +23,29 @@ class CompositeProductRowSizeEstimatorTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $websiteManagementMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $relationsCalculatorMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $collectionFactoryMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->websiteManagementMock = $this->createMock(\Magento\Store\Api\WebsiteManagementInterface::class);
+ $this->websiteManagementMock = $this->createMock(WebsiteManagementInterface::class);
$this->collectionFactoryMock = $this->createPartialMock(
- \Magento\Customer\Model\ResourceModel\Group\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
$this->relationsCalculatorMock = $this->createMock(
- \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductRelationsCalculator::class
+ CompositeProductRelationsCalculator::class
);
$this->model = new CompositeProductRowSizeEstimator(
$this->websiteManagementMock,
@@ -53,7 +60,7 @@ public function testEstimateRowSize()
$maxRelatedProductCount = 10;
$this->websiteManagementMock->expects($this->once())->method('getCount')->willReturn(100);
- $collectionMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Group\Collection::class);
+ $collectionMock = $this->createMock(Collection::class);
$this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($collectionMock);
$collectionMock->expects($this->once())->method('getSize')->willReturn(200);
$this->relationsCalculatorMock->expects($this->once())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/DefaultPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/DefaultPriceTest.php
index 04529ef523d13..91530a6cf8fae 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/DefaultPriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/DefaultPriceTest.php
@@ -3,30 +3,36 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer\Price;
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice;
+use Magento\Framework\App\ResourceConnection;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class DefaultPriceTest extends \PHPUnit\Framework\TestCase
+class DefaultPriceTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice
+ * @var DefaultPrice
*/
private $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $resourceMock;
- protected function setUp()
+ protected function setUp(): void
{
$objectManagerHelper = new ObjectManager($this);
- $this->resourceMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class)
+ $this->resourceMock = $this->getMockBuilder(ResourceConnection::class)
->disableOriginalConstructor()
->getMock();
$this->model = $objectManagerHelper->getObject(
- \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice::class,
+ DefaultPrice::class,
[
'resources' => $this->resourceMock
]
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/IndexTableRowSizeEstimatorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/IndexTableRowSizeEstimatorTest.php
index c0ecc4370816b..14bda621cc429 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/IndexTableRowSizeEstimatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/IndexTableRowSizeEstimatorTest.php
@@ -3,34 +3,42 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer\Price;
-class IndexTableRowSizeEstimatorTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableRowSizeEstimator;
+use Magento\Customer\Model\ResourceModel\Group\Collection;
+use Magento\Customer\Model\ResourceModel\Group\CollectionFactory;
+use Magento\Store\Api\WebsiteManagementInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class IndexTableRowSizeEstimatorTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableRowSizeEstimator
+ * @var IndexTableRowSizeEstimator
*/
private $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $websiteManagementMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $collectionFactoryMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->websiteManagementMock = $this->createMock(\Magento\Store\Api\WebsiteManagementInterface::class);
+ $this->websiteManagementMock = $this->createMock(WebsiteManagementInterface::class);
$this->collectionFactoryMock = $this->createPartialMock(
- \Magento\Customer\Model\ResourceModel\Group\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
- $this->model = new \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableRowSizeEstimator(
+ $this->model = new IndexTableRowSizeEstimator(
$this->websiteManagementMock,
$this->collectionFactoryMock
);
@@ -41,7 +49,7 @@ public function testEstimateRowSize()
$expectedValue = 4000000;
$this->websiteManagementMock->expects($this->once())->method('getCount')->willReturn(100);
- $collectionMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Group\Collection::class);
+ $collectionMock = $this->createMock(Collection::class);
$this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($collectionMock);
$collectionMock->expects($this->once())->method('getSize')->willReturn(200);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/TemporaryTableStrategyTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/TemporaryTableStrategyTest.php
index 8b19fa3aa8e8c..85111dbdf3e9c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/TemporaryTableStrategyTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/TemporaryTableStrategyTest.php
@@ -3,34 +3,41 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer;
use Magento\Catalog\Model\ResourceModel\Product\Indexer\TemporaryTableStrategy;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\Indexer\Table\Strategy;
+use Magento\Framework\Indexer\Table\StrategyInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class TemporaryTableStrategyTest extends \PHPUnit\Framework\TestCase
+class TemporaryTableStrategyTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\TemporaryTableStrategy
+ * @var TemporaryTableStrategy
*/
private $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Indexer\Table\Strategy
+ * @var MockObject|Strategy
*/
private $tableStrategyMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\ResourceConnection
+ * @var MockObject|ResourceConnection
*/
private $resourceMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->tableStrategyMock = $this->createMock(\Magento\Framework\Indexer\Table\Strategy::class);
- $this->resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
+ $this->tableStrategyMock = $this->createMock(Strategy::class);
+ $this->resourceMock = $this->createMock(ResourceConnection::class);
- $this->model = new \Magento\Catalog\Model\ResourceModel\Product\Indexer\TemporaryTableStrategy(
+ $this->model = new TemporaryTableStrategy(
$this->tableStrategyMock,
$this->resourceMock
);
@@ -51,7 +58,7 @@ public function testSetUseIdxTable()
public function testGetTableName()
{
$tablePrefix = 'prefix';
- $expectedResult = $tablePrefix . \Magento\Framework\Indexer\Table\StrategyInterface::IDX_SUFFIX;
+ $expectedResult = $tablePrefix . StrategyInterface::IDX_SUFFIX;
$this->tableStrategyMock->expects($this->once())->method('getUseIdxTable')->willReturn(true);
$this->resourceMock->expects($this->once())
->method('getTableName')
@@ -64,10 +71,10 @@ public function testPrepareTableName()
{
$tablePrefix = 'prefix';
$expectedResult = $tablePrefix . TemporaryTableStrategy::TEMP_SUFFIX;
- $tempTableName = $tablePrefix . \Magento\Framework\Indexer\Table\StrategyInterface::TMP_SUFFIX;
+ $tempTableName = $tablePrefix . StrategyInterface::TMP_SUFFIX;
$this->tableStrategyMock->expects($this->once())->method('getUseIdxTable')->willReturn(false);
- $connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
+ $connectionMock = $this->createMock(AdapterInterface::class);
$this->resourceMock->expects($this->once())
->method('getConnection')
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Link/Product/CollectionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Link/Product/CollectionTest.php
index a29e76c5c8ff1..6f0120db7420f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Link/Product/CollectionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Link/Product/CollectionTest.php
@@ -3,97 +3,125 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Link\Product;
+use Magento\Catalog\Helper\Data;
+use Magento\Catalog\Model\Indexer\Product\Flat\State;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\OptionFactory;
+use Magento\Catalog\Model\ResourceModel\Helper;
use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation;
use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory;
+use Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection;
+use Magento\Catalog\Model\ResourceModel\Url;
+use Magento\Customer\Model\Session;
+use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\AbstractEntity;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
+use Magento\Framework\Data\Collection\EntityFactory;
+use Magento\Framework\DataObject;
+use Magento\Framework\DB\Adapter\Pdo\Mysql;
+use Magento\Framework\DB\Select;
use Magento\Framework\EntityManager\EntityMetadataInterface;
use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\Stdlib\DateTime;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\Validator\UniversalFactory;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyFields)
*/
-class CollectionTest extends \PHPUnit\Framework\TestCase
+class CollectionTest extends TestCase
{
- /** @var \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection */
+ /** @var Collection */
protected $collection;
- /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */
+ /** @var ObjectManager */
private $objectManager;
- /** @var \Magento\Framework\Data\Collection\EntityFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var EntityFactory|MockObject */
protected $entityFactoryMock;
- /** @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var LoggerInterface|MockObject */
protected $loggerMock;
- /** @var \Magento\Framework\Data\Collection\Db\FetchStrategyInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var FetchStrategyInterface|MockObject */
protected $fetchStrategyMock;
- /** @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ManagerInterface|MockObject */
protected $managerInterfaceMock;
- /** @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Config|MockObject */
protected $configMock;
- /** @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ResourceConnection|MockObject */
protected $resourceMock;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
protected $entityFactoryMock2;
- /** @var \Magento\Catalog\Model\ResourceModel\Helper|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Helper|MockObject */
protected $helperMock;
- /** @var \Magento\Framework\Validator\UniversalFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var UniversalFactory|MockObject */
protected $universalFactoryMock;
- /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var StoreManagerInterface|MockObject */
protected $storeManagerMock;
- /** @var \Magento\Catalog\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Data|MockObject */
protected $catalogHelperMock;
- /** @var \Magento\Catalog\Model\Indexer\Product\Flat\State|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var State|MockObject */
protected $stateMock;
- /** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ScopeConfigInterface|MockObject */
protected $scopeConfigInterfaceMock;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var MockObject */
protected $optionFactoryMock;
- /** @var \Magento\Catalog\Model\ResourceModel\Url|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Url|MockObject */
protected $urlMock;
- /** @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var TimezoneInterface|MockObject */
protected $timezoneInterfaceMock;
- /** @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Session|MockObject */
protected $sessionMock;
- /** @var \Magento\Framework\Stdlib\DateTime|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var DateTime|MockObject */
protected $dateTimeMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->entityFactoryMock = $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class);
- $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class);
+ $this->objectManager = new ObjectManager($this);
+ $this->entityFactoryMock = $this->createMock(EntityFactory::class);
+ $this->loggerMock = $this->createMock(LoggerInterface::class);
$this->fetchStrategyMock = $this->createMock(
- \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class
+ FetchStrategyInterface::class
);
- $this->managerInterfaceMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
- $this->configMock = $this->createMock(\Magento\Eav\Model\Config::class);
- $this->resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
+ $this->managerInterfaceMock = $this->createMock(ManagerInterface::class);
+ $this->configMock = $this->createMock(Config::class);
+ $this->resourceMock = $this->createMock(ResourceConnection::class);
$this->entityFactoryMock2 = $this->createMock(\Magento\Eav\Model\EntityFactory::class);
- $this->helperMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Helper::class);
- $entity = $this->createMock(\Magento\Eav\Model\Entity\AbstractEntity::class);
- $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $this->helperMock = $this->createMock(Helper::class);
+ $entity = $this->createMock(AbstractEntity::class);
+ $select = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
- $connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class)
+ $connection = $this->getMockBuilder(Mysql::class)
->disableOriginalConstructor()
->getMock();
$connection->expects($this->any())
@@ -101,25 +129,25 @@ protected function setUp()
->willReturn($select);
$entity->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
$entity->expects($this->any())->method('getDefaultAttributes')->will($this->returnValue([]));
- $this->universalFactoryMock = $this->createMock(\Magento\Framework\Validator\UniversalFactory::class);
+ $this->universalFactoryMock = $this->createMock(UniversalFactory::class);
$this->universalFactoryMock->expects($this->any())->method('create')->will($this->returnValue($entity));
- $this->storeManagerMock = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->storeManagerMock = $this->getMockForAbstractClass(StoreManagerInterface::class);
$this->storeManagerMock
->expects($this->any())
->method('getStore')
->willReturnCallback(
function ($store) {
- return is_object($store) ? $store : new \Magento\Framework\DataObject(['id' => 42]);
+ return is_object($store) ? $store : new DataObject(['id' => 42]);
}
);
- $this->catalogHelperMock = $this->createMock(\Magento\Catalog\Helper\Data::class);
- $this->stateMock = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\State::class);
- $this->scopeConfigInterfaceMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
- $this->optionFactoryMock = $this->createMock(\Magento\Catalog\Model\Product\OptionFactory::class);
- $this->urlMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Url::class);
- $this->timezoneInterfaceMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
- $this->sessionMock = $this->createMock(\Magento\Customer\Model\Session::class);
- $this->dateTimeMock = $this->createMock(\Magento\Framework\Stdlib\DateTime::class);
+ $this->catalogHelperMock = $this->createMock(Data::class);
+ $this->stateMock = $this->createMock(State::class);
+ $this->scopeConfigInterfaceMock = $this->createMock(ScopeConfigInterface::class);
+ $this->optionFactoryMock = $this->createMock(OptionFactory::class);
+ $this->urlMock = $this->createMock(Url::class);
+ $this->timezoneInterfaceMock = $this->createMock(TimezoneInterface::class);
+ $this->sessionMock = $this->createMock(Session::class);
+ $this->dateTimeMock = $this->createMock(DateTime::class);
$productLimitationFactoryMock = $this->getMockBuilder(
ProductLimitationFactory::class
)->disableOriginalConstructor()->setMethods(['create'])->getMock();
@@ -133,7 +161,7 @@ function ($store) {
$metadataPoolMock->method('getMetadata')->willReturn($metadataMock);
$this->collection = $this->objectManager->getObject(
- \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection::class,
+ Collection::class,
[
'entityFactory' => $this->entityFactoryMock,
'logger' => $this->loggerMock,
@@ -161,10 +189,10 @@ function ($store) {
public function testSetProduct()
{
- /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product */
- $product = $this->createMock(\Magento\Catalog\Model\Product::class);
+ /** @var Product|MockObject $product */
+ $product = $this->createMock(Product::class);
$product->expects($this->any())->method('getId')->will($this->returnValue('5'));
- $productStore = new \Magento\Framework\DataObject(['id' => 33]);
+ $productStore = new DataObject(['id' => 33]);
$product->expects($this->any())->method('getStore')->will($this->returnValue($productStore));
$this->collection->setProduct($product);
$this->assertEquals(33, $this->collection->getStoreId());
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/LinkTest.php
index e35576d855727..707e05b4a98a1 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/LinkTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/LinkTest.php
@@ -3,46 +3,56 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product;
-class LinkTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\ResourceModel\Product\Link;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class LinkTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Link
+ * @var Link
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $resource;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $connection;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $dbSelect;
- protected function setUp()
+ protected function setUp(): void
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
+ $objectManager = new ObjectManager($this);
+ $this->resource = $this->createMock(ResourceConnection::class);
$this->connection =
- $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
+ $this->createMock(AdapterInterface::class);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\ResourceModel\Product\Link::class,
+ Link::class,
['resource' => $this->resource]
);
}
protected function prepareAdapter()
{
- $this->dbSelect = $this->createMock(\Magento\Framework\DB\Select::class);
+ $this->dbSelect = $this->createMock(Select::class);
// method flow
$this->resource->expects(
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Option/CollectionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Option/CollectionTest.php
index 2ea99f0177772..7918c9b8d6f69 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Option/CollectionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Option/CollectionTest.php
@@ -3,23 +3,44 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Option;
-use \Magento\Catalog\Model\ResourceModel\Product\Option\Collection;
-use \Magento\Catalog\Model\ResourceModel\Product\Option\Value;
+use Magento\Catalog\Model\ResourceModel\Product\Option;
+use Magento\Catalog\Model\ResourceModel\Product\Option\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\Option\Value;
+use Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory;
+use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
+use Magento\Framework\Data\Collection\Db\FetchStrategy\Query;
+use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
+use Magento\Framework\Data\Collection\EntityFactory;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Adapter\Pdo\Mysql;
+use Magento\Framework\DB\Select;
+use Magento\Framework\EntityManager\EntityMetadata;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Event\Manager;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\StoreManager;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CollectionTest extends \PHPUnit\Framework\TestCase
+class CollectionTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
private $objectManager;
/**
- * @var \Magento\Framework\EntityManager\MetadataPool
+ * @var MetadataPool
*/
protected $metadataPoolMock;
@@ -29,83 +50,83 @@ class CollectionTest extends \PHPUnit\Framework\TestCase
protected $collection;
/**
- * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
protected $loggerMock;
/**
- * @var \Magento\Framework\Data\Collection\EntityFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var EntityFactory|MockObject
*/
protected $entityFactoryMock;
/**
- * @var \Magento\Framework\Data\Collection\Db\FetchStrategyInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var FetchStrategyInterface|MockObject
*/
protected $fetchStrategyMock;
/**
- * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
protected $eventManagerMock;
/**
- * @var Value\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var Value\CollectionFactory|MockObject
*/
protected $optionsFactoryMock;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManagerMock;
/**
- * @var \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var JoinProcessorInterface|MockObject
*/
protected $joinProcessor;
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product\Option|\PHPUnit_Framework_MockObject_MockObject
+ * @var Option|MockObject
*/
protected $resourceMock;
/**
- * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AdapterInterface|MockObject
*/
protected $connection;
/**
- * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
protected $selectMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
$this->entityFactoryMock = $this->createPartialMock(
- \Magento\Framework\Data\Collection\EntityFactory::class,
+ EntityFactory::class,
['create']
);
- $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class);
+ $this->loggerMock = $this->createMock(LoggerInterface::class);
$this->fetchStrategyMock = $this->createPartialMock(
- \Magento\Framework\Data\Collection\Db\FetchStrategy\Query::class,
+ Query::class,
['fetchAll']
);
- $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\Manager::class);
+ $this->eventManagerMock = $this->createMock(Manager::class);
$this->optionsFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class);
+ $this->storeManagerMock = $this->createMock(StoreManager::class);
$this->joinProcessor = $this->getMockBuilder(
- \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class
+ JoinProcessorInterface::class
)->disableOriginalConstructor()->getMockForAbstractClass();
$this->resourceMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\Option::class,
+ Option::class,
['getConnection', '__wakeup', 'getMainTable', 'getTable']
);
- $this->selectMock = $this->createPartialMock(\Magento\Framework\DB\Select::class, ['from', 'reset', 'join']);
+ $this->selectMock = $this->createPartialMock(Select::class, ['from', 'reset', 'join']);
$this->connection =
- $this->createPartialMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select']);
+ $this->createPartialMock(Mysql::class, ['select']);
$this->connection->expects($this->once())
->method('select')
->will($this->returnValue($this->selectMock));
@@ -126,8 +147,8 @@ protected function setUp()
'catalog_product_entity',
'catalog_product_entity'
);
- $this->metadataPoolMock = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class);
- $metadata = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class);
+ $this->metadataPoolMock = $this->createMock(MetadataPool::class);
+ $metadata = $this->createMock(EntityMetadata::class);
$metadata->expects($this->any())->method('getLinkField')->willReturn('id');
$this->metadataPoolMock->expects($this->any())->method('getMetadata')->willReturn($metadata);
$this->selectMock->expects($this->exactly(2))->method('join');
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/StatusBaseSelectProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/StatusBaseSelectProcessorTest.php
index ee487041600b5..55628e1c810c4 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/StatusBaseSelectProcessorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/StatusBaseSelectProcessorTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product;
use Magento\Catalog\Api\Data\ProductInterface;
@@ -16,31 +18,34 @@
use Magento\Framework\EntityManager\EntityMetadataInterface;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Store\Model\StoreManagerInterface;
+use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class StatusBaseSelectProcessorTest extends \PHPUnit\Framework\TestCase
+class StatusBaseSelectProcessorTest extends TestCase
{
/**
- * @var Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $eavConfig;
/**
- * @var MetadataPool|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataPool|MockObject
*/
private $metadataPool;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManager;
/**
- * @var Select|\PHPUnit_Framework_MockObject_MockObject
+ * @var Select|MockObject
*/
private $select;
@@ -49,7 +54,7 @@ class StatusBaseSelectProcessorTest extends \PHPUnit\Framework\TestCase
*/
private $statusBaseSelectProcessor;
- protected function setUp()
+ protected function setUp(): void
{
$this->eavConfig = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
$this->metadataPool = $this->getMockBuilder(MetadataPool::class)->disableOriginalConstructor()->getMock();
@@ -79,7 +84,7 @@ public function testProcess()
->with(ProductInterface::class)
->willReturn($metadata);
- /** @var AttributeInterface|\PHPUnit_Framework_MockObject_MockObject $statusAttribute */
+ /** @var AttributeInterface|MockObject $statusAttribute */
$statusAttribute = $this->getMockBuilder(AttributeInterface::class)
->setMethods(['getBackendTable', 'getAttributeId'])
->getMock();
@@ -94,7 +99,7 @@ public function testProcess()
->with(Product::ENTITY, ProductInterface::STATUS)
->willReturn($statusAttribute);
- $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)->getMock();
+ $storeMock = $this->getMockBuilder(StoreInterface::class)->getMock();
$this->storeManager->expects($this->once())
->method('getStore')
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Website/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Website/LinkTest.php
index 04cf28c586df9..4839cf18e1578 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Website/LinkTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Website/LinkTest.php
@@ -3,12 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Website;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\ResourceModel\Product\Website\Link;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\DB\Select;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class LinkTest extends \PHPUnit\Framework\TestCase
+class LinkTest extends TestCase
{
/**
* @var Link
@@ -16,26 +23,26 @@ class LinkTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $resource;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $connection;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $dbSelect;
- protected function setUp()
+ protected function setUp(): void
{
- $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
+ $this->resource = $this->createMock(ResourceConnection::class);
$this->connection =
- $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
- $this->dbSelect = $this->getMockBuilder(\Magento\Framework\Db\Select::class)
+ $this->createMock(AdapterInterface::class);
+ $this->dbSelect = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
$this->connection->expects($this->any())
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ProductTest.php
index 0606a31befcb7..e1296e6707f9e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ProductTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ProductTest.php
@@ -3,43 +3,52 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Model\ResourceModel;
+use Magento\Catalog\Model\ResourceModel\Product;
+use Magento\Eav\Model\Entity\Attribute\Set;
+use Magento\Eav\Model\Entity\Attribute\SetFactory;
+use Magento\Eav\Model\Entity\Type;
+use Magento\Eav\Model\Entity\TypeFactory;
+use Magento\Framework\DataObject;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ProductTest extends \PHPUnit\Framework\TestCase
+class ProductTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\ResourceModel\Product
+ * @var Product
*/
protected $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $setFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $typeFactoryMock;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
$this->setFactoryMock = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute\SetFactory::class,
+ SetFactory::class,
['create', '__wakeup']
);
$this->typeFactoryMock = $this->createPartialMock(
- \Magento\Eav\Model\Entity\TypeFactory::class,
+ TypeFactory::class,
['create', '__wakeup']
);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Model\ResourceModel\Product::class,
+ Product::class,
[
'setFactory' => $this->setFactoryMock,
'typeFactory' => $this->typeFactoryMock,
@@ -53,14 +62,14 @@ public function testValidateWrongAttributeSet()
$expectedErrorMessage = ['attribute_set' => 'Invalid attribute set entity type'];
$productMock = $this->createPartialMock(
- \Magento\Framework\DataObject::class,
+ DataObject::class,
['getAttributeSetId', '__wakeup']
);
$attributeSetMock = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute\Set::class,
+ Set::class,
['load', 'getEntityTypeId', '__wakeup']
);
- $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class);
+ $entityTypeMock = $this->createMock(Type::class);
$this->typeFactoryMock->expects($this->once())->method('create')->will($this->returnValue($entityTypeMock));
$entityTypeMock->expects($this->once())->method('loadByCode')->with('catalog_product')->willReturnSelf();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ProductWebsiteAssignmentHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ProductWebsiteAssignmentHandlerTest.php
index 664aa311008f2..d47c634a43d86 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ProductWebsiteAssignmentHandlerTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/ProductWebsiteAssignmentHandlerTest.php
@@ -9,6 +9,7 @@
use Magento\Catalog\Model\ResourceModel\Product\Website\Link;
use Magento\Catalog\Model\ResourceModel\ProductWebsiteAssignmentHandler;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class ProductWebsiteAssignmentHandlerTest extends TestCase
@@ -19,11 +20,11 @@ class ProductWebsiteAssignmentHandlerTest extends TestCase
protected $handler;
/**
- * @var Link|\PHPUnit_Framework_MockObject_MockObject
+ * @var Link|MockObject
*/
protected $productLinkMock;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Rss/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Rss/CategoryTest.php
index a2c270f1c65e4..853996d1afd6e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Rss/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Rss/CategoryTest.php
@@ -3,19 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Rss;
+use Magento\Catalog\Model\Layer;
+use Magento\Catalog\Model\Layer\Resolver;
+use Magento\Catalog\Model\Product\Visibility;
+use Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use Magento\Catalog\Model\Rss\Category;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class CategoryTest
- *
- * @package Magento\Catalog\Model\Rss
- */
-class CategoryTest extends \PHPUnit\Framework\TestCase
+class CategoryTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Rss\Category
+ * @var Category
*/
protected $model;
@@ -25,37 +31,37 @@ class CategoryTest extends \PHPUnit\Framework\TestCase
protected $objectManagerHelper;
/**
- * @var \Magento\Catalog\Model\Layer\Category|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Catalog\Model\Layer\Category|MockObject
*/
protected $categoryLayer;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $collectionFactory;
/**
- * @var \Magento\Catalog\Model\Product\Visibility|\PHPUnit_Framework_MockObject_MockObject
+ * @var Visibility|MockObject
*/
protected $visibility;
- protected function setUp()
+ protected function setUp(): void
{
$this->categoryLayer = $this->createPartialMock(
\Magento\Catalog\Model\Layer\Category::class,
['setStore', '__wakeup']
);
$this->collectionFactory = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
- $this->visibility = $this->createPartialMock(\Magento\Catalog\Model\Product\Visibility::class, [
+ $this->visibility = $this->createPartialMock(Visibility::class, [
'getVisibleInCatalogIds',
'__wakeup'
]);
- /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver $layerResolver */
- $layerResolver = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Resolver::class)
+ /** @var MockObject|Resolver $layerResolver */
+ $layerResolver = $this->getMockBuilder(Resolver::class)
->disableOriginalConstructor()
->setMethods(['get', 'create'])
->getMock();
@@ -64,9 +70,9 @@ protected function setUp()
->will($this->returnValue($this->categoryLayer));
$this->objectManagerHelper = new ObjectManagerHelper($this);
- /** @var \Magento\Catalog\Model\Rss\Category model */
+ /** @var Category model */
$this->model = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Model\Rss\Category::class,
+ Category::class,
[
'layerResolver' => $layerResolver,
'collectionFactory' => $this->collectionFactory,
@@ -88,7 +94,7 @@ public function testGetProductCollection()
->expects($this->once())
->method('getVisibleInCatalogIds')
->will($this->returnValue($visibleInCatalogIds));
- $products = $this->createPartialMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class, [
+ $products = $this->createPartialMock(Collection::class, [
'setStoreId',
'addAttributeToSort',
'setVisibility',
@@ -97,7 +103,7 @@ public function testGetProductCollection()
'addCountToCategories',
]);
$resourceCollection = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection::class,
+ AbstractCollection::class,
[
'addAttributeToSelect',
'addAttributeToFilter',
@@ -158,7 +164,7 @@ public function testGetProductCollection()
$category->expects($this->once())
->method('getProductCollection')
->will($this->returnValue($products));
- $layer = $this->createPartialMock(\Magento\Catalog\Model\Layer::class, [
+ $layer = $this->createPartialMock(Layer::class, [
'setCurrentCategory',
'prepareProductCollection',
'getProductCollection',
@@ -172,8 +178,8 @@ public function testGetProductCollection()
->method('getProductCollection')
->will($this->returnValue($products));
- /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver $layerResolver */
- $layerResolver = $this->getMockBuilder(\Magento\Catalog\Model\Layer\Resolver::class)
+ /** @var MockObject|Resolver $layerResolver */
+ $layerResolver = $this->getMockBuilder(Resolver::class)
->disableOriginalConstructor()
->setMethods(['get', 'create'])
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NewProductsTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NewProductsTest.php
index faf839f29c90d..130de9bce1f09 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NewProductsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NewProductsTest.php
@@ -3,18 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Rss\Product;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Visibility;
+use Magento\Catalog\Model\ProductFactory;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Catalog\Model\Rss\Product\NewProducts;
+use Magento\Framework\Stdlib\DateTime\Timezone;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class NewProductsTest
- * @package Magento\Catalog\Model\Rss\Product
- */
-class NewProductsTest extends \PHPUnit\Framework\TestCase
+class NewProductsTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Rss\Product\NewProducts
+ * @var NewProducts
*/
protected $newProducts;
@@ -24,36 +31,36 @@ class NewProductsTest extends \PHPUnit\Framework\TestCase
protected $objectManagerHelper;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ProductFactory
+ * @var MockObject|ProductFactory
*/
protected $productFactory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product
+ * @var MockObject|Product
*/
protected $product;
/**
- * @var \Magento\Catalog\Model\Product\Visibility|\PHPUnit_Framework_MockObject_MockObject
+ * @var Visibility|MockObject
*/
protected $visibility;
/**
- * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var TimezoneInterface|MockObject
*/
protected $timezone;
- protected function setUp()
+ protected function setUp(): void
{
- $this->product = $this->createMock(\Magento\Catalog\Model\Product::class);
- $this->productFactory = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']);
+ $this->product = $this->createMock(Product::class);
+ $this->productFactory = $this->createPartialMock(ProductFactory::class, ['create']);
$this->productFactory->expects($this->any())->method('create')->will($this->returnValue($this->product));
- $this->visibility = $this->createMock(\Magento\Catalog\Model\Product\Visibility::class);
- $this->timezone = $this->createMock(\Magento\Framework\Stdlib\DateTime\Timezone::class);
+ $this->visibility = $this->createMock(Visibility::class);
+ $this->timezone = $this->createMock(Timezone::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->newProducts = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Model\Rss\Product\NewProducts::class,
+ NewProducts::class,
[
'productFactory' => $this->productFactory,
'visibility' => $this->visibility,
@@ -64,7 +71,7 @@ protected function setUp()
public function testGetProductsCollection()
{
- /** @var \DateTime|\PHPUnit_Framework_MockObject_MockObject $dateObject */
+ /** @var \DateTime|MockObject $dateObject */
$dateObject = $this->createMock(\DateTime::class);
$dateObject->expects($this->any())
->method('setTime')
@@ -77,9 +84,9 @@ public function testGetProductsCollection()
->method('date')
->will($this->returnValue($dateObject));
- /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */
+ /** @var Collection $productCollection */
$productCollection =
- $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
+ $this->createMock(Collection::class);
$this->product->expects($this->once())->method('getResourceCollection')->will(
$this->returnValue($productCollection)
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NotifyStockTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NotifyStockTest.php
index 8cb76930a52dc..633859f00b02e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NotifyStockTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/NotifyStockTest.php
@@ -3,18 +3,27 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Rss\Product;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Attribute\Source\Status;
+use Magento\Catalog\Model\ProductFactory;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Catalog\Model\Rss\Product\NotifyStock;
+use Magento\CatalogInventory\Model\ResourceModel\Stock;
+use Magento\CatalogInventory\Model\ResourceModel\StockFactory;
+use Magento\Framework\Event\Manager;
+use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class NotifyStockTest
- * @package Magento\Catalog\Model\Rss\Product
- */
-class NotifyStockTest extends \PHPUnit\Framework\TestCase
+class NotifyStockTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Rss\Product\NotifyStock
+ * @var NotifyStock
*/
protected $notifyStock;
@@ -24,55 +33,54 @@ class NotifyStockTest extends \PHPUnit\Framework\TestCase
protected $objectManagerHelper;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
-
protected $productFactory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product
+ * @var MockObject|Product
*/
protected $product;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\CatalogInventory\Model\ResourceModel\StockFactory
+ * @var MockObject|StockFactory
*/
protected $stockFactory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\CatalogInventory\Model\ResourceModel\Stock
+ * @var MockObject|Stock
*/
protected $stock;
/**
- * @var \Magento\Catalog\Model\Product\Attribute\Source\Status|\PHPUnit_Framework_MockObject_MockObject
+ * @var Status|MockObject
*/
protected $status;
/**
- * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
protected $eventManager;
- protected function setUp()
+ protected function setUp(): void
{
- $this->product = $this->createMock(\Magento\Catalog\Model\Product::class);
- $this->productFactory = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']);
+ $this->product = $this->createMock(Product::class);
+ $this->productFactory = $this->createPartialMock(ProductFactory::class, ['create']);
$this->productFactory->expects($this->any())->method('create')->will($this->returnValue($this->product));
- $this->stock = $this->createMock(\Magento\CatalogInventory\Model\ResourceModel\Stock::class);
+ $this->stock = $this->createMock(Stock::class);
$this->stockFactory = $this->createPartialMock(
- \Magento\CatalogInventory\Model\ResourceModel\StockFactory::class,
+ StockFactory::class,
['create']
);
$this->stockFactory->expects($this->any())->method('create')->will($this->returnValue($this->stock));
- $this->status = $this->createMock(\Magento\Catalog\Model\Product\Attribute\Source\Status::class);
- $this->eventManager = $this->createMock(\Magento\Framework\Event\Manager::class);
+ $this->status = $this->createMock(Status::class);
+ $this->eventManager = $this->createMock(Manager::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->notifyStock = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Model\Rss\Product\NotifyStock::class,
+ NotifyStock::class,
[
'productFactory' => $this->productFactory,
'stockFactory' => $this->stockFactory,
@@ -84,9 +92,9 @@ protected function setUp()
public function testGetProductsCollection()
{
- /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */
+ /** @var Collection $productCollection */
$productCollection =
- $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
+ $this->createMock(Collection::class);
$this->product->expects($this->once())->method('getCollection')->will($this->returnValue($productCollection));
$productCollection->expects($this->once())->method('addAttributeToSelect')->will($this->returnSelf());
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/SpecialTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/SpecialTest.php
index 648fe4802eadd..a5bf29a3925d3 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/SpecialTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Rss/Product/SpecialTest.php
@@ -3,18 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Rss\Product;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ProductFactory;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Catalog\Model\Rss\Product\Special;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManager;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class SpecialTest
- * @package Magento\Catalog\Model\Rss\Product
- */
-class SpecialTest extends \PHPUnit\Framework\TestCase
+class SpecialTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\Rss\Product\Special
+ * @var Special
*/
protected $special;
@@ -24,30 +31,30 @@ class SpecialTest extends \PHPUnit\Framework\TestCase
protected $objectManagerHelper;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $productFactory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product
+ * @var MockObject|Product
*/
protected $product;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManager;
- protected function setUp()
+ protected function setUp(): void
{
- $this->product = $this->createMock(\Magento\Catalog\Model\Product::class);
- $this->productFactory = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']);
+ $this->product = $this->createMock(Product::class);
+ $this->productFactory = $this->createPartialMock(ProductFactory::class, ['create']);
$this->productFactory->expects($this->any())->method('create')->will($this->returnValue($this->product));
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class);
+ $this->storeManager = $this->createMock(StoreManager::class);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->special = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Model\Rss\Product\Special::class,
+ Special::class,
[
'productFactory' => $this->productFactory,
'storeManager' => $this->storeManager
@@ -58,16 +65,16 @@ protected function setUp()
public function testGetProductsCollection()
{
$storeId = 1;
- $store = $this->createMock(\Magento\Store\Model\Store::class);
+ $store = $this->createMock(Store::class);
$this->storeManager->expects($this->once())->method('getStore')->with($storeId)->will(
$this->returnValue($store)
);
$websiteId = 1;
$store->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId));
- /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */
+ /** @var Collection $productCollection */
$productCollection =
- $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
+ $this->createMock(Collection::class);
$this->product->expects($this->once())->method('getResourceCollection')->will(
$this->returnValue($productCollection)
);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php b/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php
index db3f0f6960944..fb96e50802257 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php
@@ -3,102 +3,121 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\System\Config\Backend\Catalog\Url\Rewrite;
+use Magento\Catalog\Model\System\Config\Backend\Catalog\Url\Rewrite\Suffix;
+use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator;
+use Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator;
+use Magento\Framework\App\Cache\Type\Block;
+use Magento\Framework\App\Cache\Type\Collection;
+use Magento\Framework\App\Cache\TypeList;
+use Magento\Framework\App\Cache\TypeListInterface;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Registry;
+use Magento\Store\Model\StoreManager;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\UrlRewrite\Helper\UrlRewrite;
+use Magento\UrlRewrite\Model\UrlFinderInterface;
+use PHPUnit\Framework\TestCase;
+
/**
- * Class SuffixTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class SuffixTest extends \PHPUnit\Framework\TestCase
+class SuffixTest extends TestCase
{
/**
- * @var \Magento\Framework\Model\Context
+ * @var Context
*/
protected $context;
/**
- * @var \Magento\Framework\Event\ManagerInterface
+ * @var ManagerInterface
*/
protected $eventDispatcher;
-
+
/**
- * @var \Magento\Framework\Registry
+ * @var Registry
*/
protected $registry;
-
+
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface
+ * @var ScopeConfigInterface
*/
protected $config;
-
+
/**
- * @var \Magento\Framework\App\Cache\TypeListInterface
+ * @var TypeListInterface
*/
protected $cacheTypeList;
-
+
/**
- * @var \Magento\UrlRewrite\Helper\UrlRewrite
+ * @var UrlRewrite
*/
protected $urlRewriteHelper;
-
+
/**
- * @var \Magento\Store\Model\StoreManagerInterface
+ * @var StoreManagerInterface
*/
protected $storeManager;
-
+
/**
- * @var \Magento\Framework\App\ResourceConnection
+ * @var ResourceConnection
*/
protected $appResource;
-
+
/**
- * @var \Magento\UrlRewrite\Model\UrlFinderInterface
+ * @var UrlFinderInterface
*/
protected $urlFinder;
/**
- * @var \Magento\Catalog\Model\System\Config\Backend\Catalog\Url\Rewrite\Suffix
+ * @var Suffix
*/
protected $suffixModel;
- public function setUp()
+ public function setUp(): void
{
- $this->eventDispatcher = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class)
+ $this->eventDispatcher = $this->getMockBuilder(ManagerInterface::class)
->disableOriginalConstructor()
->setMethods(['dispatch'])
->getMock();
$this->eventDispatcher->method('dispatch')->willReturnSelf();
- $this->context = $this->getMockBuilder(\Magento\Framework\Model\Context::class)
+ $this->context = $this->getMockBuilder(Context::class)
->disableOriginalConstructor()
->setMethods(['getEventDispatcher'])
->getMock();
$this->context->method('getEventDispatcher')->willReturn($this->eventDispatcher);
-
- $this->registry = $this->createMock(\Magento\Framework\Registry::class);
- $this->config = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
- $this->cacheTypeList = $this->getMockBuilder(\Magento\Framework\App\Cache\TypeList::class)
+
+ $this->registry = $this->createMock(Registry::class);
+ $this->config = $this->createMock(ScopeConfigInterface::class);
+ $this->cacheTypeList = $this->getMockBuilder(TypeList::class)
->disableOriginalConstructor()
->setMethods(['invalidate'])
->getMock();
- $this->urlRewriteHelper = $this->getMockBuilder(\Magento\UrlRewrite\Helper\UrlRewrite::class)
+ $this->urlRewriteHelper = $this->getMockBuilder(UrlRewrite::class)
->disableOriginalConstructor()
->getMock();
- $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManager::class)
+ $this->storeManager = $this->getMockBuilder(StoreManager::class)
->disableOriginalConstructor()
->setMethods(['getStores'])
->getMock();
$this->storeManager->method('getStores')->willReturn([]);
-
- $this->appResource =$this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class)
+
+ $this->appResource =$this->getMockBuilder(ResourceConnection::class)
->disableOriginalConstructor()
->getMock();
- $this->urlFinder =$this->getMockBuilder(\Magento\UrlRewrite\Model\UrlFinderInterface::class)
+ $this->urlFinder =$this->getMockBuilder(UrlFinderInterface::class)
->setMethods(['findAllByData', 'findOneByData'])
->getMock();
$this->urlFinder->method('findAllByData')->willReturn([]);
-
- $this->suffixModel = new \Magento\Catalog\Model\System\Config\Backend\Catalog\Url\Rewrite\Suffix(
+
+ $this->suffixModel = new Suffix(
$this->context,
$this->registry,
$this->config,
@@ -114,33 +133,33 @@ public function testAfterSaveCleanCache()
{
$this->suffixModel->setValue('new');
$this->suffixModel->setPath(
- \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX
+ CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX
);
$this->cacheTypeList->expects($this->exactly(2))->method('invalidate')->withConsecutive(
[$this->equalTo([
- \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER,
- \Magento\Framework\App\Cache\Type\Collection::TYPE_IDENTIFIER
+ Block::TYPE_IDENTIFIER,
+ Collection::TYPE_IDENTIFIER
])],
[$this->equalTo('config')]
);
$this->suffixModel->afterSave();
}
-
+
public function testAfterSaveWithoutChanges()
{
$this->suffixModel->setValue('');
$this->suffixModel->setPath(
- \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX
+ CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX
);
$this->cacheTypeList->expects($this->never())->method('invalidate');
$this->suffixModel->afterSave();
}
-
+
public function testAfterSaveProduct()
{
$this->suffixModel->setValue('new');
$this->suffixModel->setPath(
- \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::XML_PATH_PRODUCT_URL_SUFFIX
+ ProductUrlPathGenerator::XML_PATH_PRODUCT_URL_SUFFIX
);
$this->cacheTypeList->expects($this->once())->method('invalidate')->with('config');
$this->suffixModel->afterSave();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Source/InputtypeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Source/InputtypeTest.php
index 4a1f31654d1ca..c3ebe1b7f7c1f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Source/InputtypeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Source/InputtypeTest.php
@@ -3,24 +3,30 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\System\Config\Source;
-class InputtypeTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\System\Config\Source\Inputtype;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
+class InputtypeTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $_helper;
/**
- * @var \Magento\Catalog\Model\System\Config\Source\Inputtype
+ * @var Inputtype
*/
protected $_model;
- protected function setUp()
+ protected function setUp(): void
{
- $this->_helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->_model = $this->_helper->getObject(\Magento\Catalog\Model\System\Config\Source\Inputtype::class);
+ $this->_helper = new ObjectManager($this);
+ $this->_model = $this->_helper->getObject(Inputtype::class);
}
public function testToOptionArrayIsArray()
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php
index 92477226b03b3..d30ee5b2e9c97 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php
@@ -3,17 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\Template\Filter;
-class FactoryTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Template\Filter\Factory;
+use Magento\Framework\Filter\Template;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class FactoryTest extends TestCase
{
/**
- * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManagerInterface|MockObject
*/
protected $_objectManagerMock;
/**
- * @var \Magento\Catalog\Model\Template\Filter\Factory
+ * @var Factory
*/
protected $_factory;
@@ -22,13 +31,13 @@ class FactoryTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->_objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
+ $this->_objectManagerMock = $this->createMock(ObjectManagerInterface::class);
- $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManagerHelper = new ObjectManager($this);
$this->_factory = $objectManagerHelper->getObject(
- \Magento\Catalog\Model\Template\Filter\Factory::class,
+ Factory::class,
['objectManager' => $this->_objectManagerMock]
);
}
@@ -40,7 +49,7 @@ protected function setUp()
*/
public function testCreate()
{
- $className = \Magento\Framework\Filter\Template::class;
+ $className = Template::class;
$filterMock = $this->createMock($className);
$this->_objectManagerMock->expects(
@@ -64,7 +73,7 @@ public function testCreate()
*/
public function testCreateWithArguments()
{
- $className = \Magento\Framework\Filter\Template::class;
+ $className = Template::class;
$arguments = ['foo', 'bar'];
$filterMock = $this->createMock($className);
@@ -85,12 +94,12 @@ public function testCreateWithArguments()
/**
* Test wrong type exception
*
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage WrongClass doesn't extend \Magento\Framework\Filter\Template
* @return void
*/
public function testWrongTypeException()
{
+ $this->expectException('Magento\Framework\Exception\LocalizedException');
+ $this->expectExceptionMessage('WrongClass doesn\'t extend \Magento\Framework\Filter\Template');
$className = 'WrongClass';
$filterMock = $this->getMockBuilder($className)->disableOriginalConstructor()->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/Image/ContextTest.php b/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/Image/ContextTest.php
index e73a2f30e2b10..e172fc83349b4 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/Image/ContextTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/Image/ContextTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\View\Asset\Image;
use Magento\Catalog\Model\Product\Media\ConfigInterface;
@@ -10,11 +12,10 @@
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class ContextTest
- */
-class ContextTest extends \PHPUnit\Framework\TestCase
+class ContextTest extends TestCase
{
/**
* @var Context
@@ -22,21 +23,21 @@ class ContextTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var WriteInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WriteInterface|MockObject
*/
protected $mediaDirectory;
/**
- * @var ContextInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ContextInterface|MockObject
*/
protected $mediaConfig;
/**
- * @var Filesystem|\PHPUnit_Framework_MockObject_MockObject
+ * @var Filesystem|MockObject
*/
protected $filesystem;
- protected function setUp()
+ protected function setUp(): void
{
$this->mediaConfig = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass();
$this->mediaConfig->expects($this->any())->method('getBaseMediaPath')->willReturn('catalog/product');
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php
index 6832d5b3399d7..9565d370191e3 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php
@@ -3,49 +3,49 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\View\Asset;
use Magento\Catalog\Model\Product\Media\ConfigInterface;
use Magento\Catalog\Model\View\Asset\Image;
-use Magento\Framework\Encryption\Encryptor;
use Magento\Framework\Encryption\EncryptorInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\View\Asset\ContextInterface;
use Magento\Framework\View\Asset\Repository;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class ImageTest
- */
-class ImageTest extends \PHPUnit\Framework\TestCase
+class ImageTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\View\Asset\Image
+ * @var Image
*/
protected $model;
/**
- * @var ContextInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ContextInterface|MockObject
*/
protected $mediaConfig;
/**
- * @var EncryptorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var EncryptorInterface|MockObject
*/
protected $encryptor;
/**
- * @var ContextInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ContextInterface|MockObject
*/
protected $context;
/**
- * @var Repository|\PHPUnit_Framework_MockObject_MockObject
+ * @var Repository|MockObject
*/
private $assetRepo;
private $objectManager;
- protected function setUp()
+ protected function setUp(): void
{
$this->mediaConfig = $this->createMock(ConfigInterface::class);
$this->encryptor = $this->createMock(EncryptorInterface::class);
@@ -128,7 +128,7 @@ public function testGetPath($filePath, $miscParams, $readableParams)
->with($readableParams, $this->anything())
->willReturn($hashPath);
static::assertEquals(
- $absolutePath . '/cache/'. $hashPath . $filePath,
+ $absolutePath . '/cache/' . $hashPath . $filePath,
$imageModel->getPath()
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/PlaceholderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/PlaceholderTest.php
index 58007145d21a4..2278cfc3480c6 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/PlaceholderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/PlaceholderTest.php
@@ -3,39 +3,42 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Model\View\Asset;
-use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Catalog\Model\View\Asset\Placeholder;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\View\Asset\ContextInterface;
+use Magento\Framework\View\Asset\MergeableInterface;
use Magento\Framework\View\Asset\Repository;
+use Magento\Store\Model\ScopeInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class PlaceholderTest
- */
-class PlaceholderTest extends \PHPUnit\Framework\TestCase
+class PlaceholderTest extends TestCase
{
/**
- * @var \Magento\Catalog\Model\View\Asset\Placeholder
+ * @var Placeholder
*/
protected $model;
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $scopeConfig;
/**
- * @var Repository|\PHPUnit_Framework_MockObject_MockObject
+ * @var Repository|MockObject
*/
protected $repository;
/**
- * @var ContextInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ContextInterface|MockObject
*/
protected $imageContext;
- protected function setUp()
+ protected function setUp(): void
{
$this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)->getMockForAbstractClass();
$this->imageContext = $this->getMockBuilder(ContextInterface::class)->getMockForAbstractClass();
@@ -88,13 +91,13 @@ public function testGetPathAndGetSourceFile($imageType, $placeholderPath)
->method('getValue')
->with(
"catalog/placeholder/{$imageType}_placeholder",
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
null
)->willReturn($placeholderPath);
if ($placeholderPath == null) {
$this->imageContext->expects($this->never())->method('getPath');
- $assetMock = $this->getMockBuilder(\Magento\Framework\View\Asset\MergeableInterface::class)
+ $assetMock = $this->getMockBuilder(MergeableInterface::class)
->getMockForAbstractClass();
$expectedResult = 'path/to_default/placeholder/by_type';
$assetMock->expects($this->any())->method('getSourceFile')->willReturn($expectedResult);
@@ -128,7 +131,7 @@ public function testGetUrl($imageType, $placeholderPath)
->method('getValue')
->with(
"catalog/placeholder/{$imageType}_placeholder",
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
null
)->willReturn($placeholderPath);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/_files/converted_view.php b/app/code/Magento/Catalog/Test/Unit/Model/_files/converted_view.php
index e225ec0daef6e..1d8818e3b28ac 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/_files/converted_view.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/_files/converted_view.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
return [
"media" => [
"Magento_Catalog" => [
diff --git a/app/code/Magento/Catalog/Test/Unit/Observer/MenuCategoryDataTest.php b/app/code/Magento/Catalog/Test/Unit/Observer/MenuCategoryDataTest.php
index f37c2e58ce5b4..f4445cd5828f5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Observer/MenuCategoryDataTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Observer/MenuCategoryDataTest.php
@@ -3,53 +3,61 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Observer;
+use Magento\Catalog\Helper\Category;
+use Magento\Catalog\Helper\Data;
+use Magento\Catalog\Model\Indexer\Category\Flat\State;
+use Magento\Catalog\Model\Layer\Resolver;
+use Magento\Catalog\Observer\MenuCategoryData;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class MenuCategoryDataTest extends \PHPUnit\Framework\TestCase
+class MenuCategoryDataTest extends TestCase
{
/**
- * @var \Magento\Catalog\Observer\MenuCategoryData
+ * @var MenuCategoryData
*/
protected $_observer;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Helper\Category
+ * @var MockObject|Category
*/
protected $_catalogCategory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category
+ * @var MockObject|\Magento\Catalog\Model\Category
*/
protected $_childrenCategory;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category
+ * @var MockObject|\Magento\Catalog\Model\Category
*/
protected $_category;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Indexer\Category\Flat\State
+ * @var MockObject|State
*/
protected $_categoryFlatState;
- protected function setUp()
+ protected function setUp(): void
{
$this->_catalogCategory = $this->createPartialMock(
- \Magento\Catalog\Helper\Category::class,
+ Category::class,
['getStoreCategories', 'getCategoryUrl']
);
- $layerResolver = $this->createMock(\Magento\Catalog\Model\Layer\Resolver::class);
+ $layerResolver = $this->createMock(Resolver::class);
$layerResolver->expects($this->once())->method('get')->willReturn(null);
$this->_observer = (new ObjectManager($this))->getObject(
- \Magento\Catalog\Observer\MenuCategoryData::class,
+ MenuCategoryData::class,
[
'layerResolver' => $layerResolver,
'catalogCategory' => $this->_catalogCategory,
- 'catalogData' => $this->createMock(\Magento\Catalog\Helper\Data::class),
+ 'catalogData' => $this->createMock(Data::class),
]
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Observer/SynchronizeWebsiteAttributesOnStoreChangeTest.php b/app/code/Magento/Catalog/Test/Unit/Observer/SynchronizeWebsiteAttributesOnStoreChangeTest.php
index 5f38c5d262c8d..ff4cee3e1668d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Observer/SynchronizeWebsiteAttributesOnStoreChangeTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Observer/SynchronizeWebsiteAttributesOnStoreChangeTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Observer;
@@ -10,8 +11,9 @@
use Magento\Catalog\Observer\SynchronizeWebsiteAttributesOnStoreChange;
use Magento\Framework\Event\Observer;
use Magento\Store\Model\Store;
+use PHPUnit\Framework\TestCase;
-class SynchronizeWebsiteAttributesOnStoreChangeTest extends \PHPUnit\Framework\TestCase
+class SynchronizeWebsiteAttributesOnStoreChangeTest extends TestCase
{
/**
* @param $invalidDataObject
diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php
index c5a3e5dab7678..964d541a93dee 100644
--- a/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php
@@ -3,65 +3,77 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Plugin\Block;
+use Magento\Catalog\Helper\Category;
+use Magento\Catalog\Model\Layer;
+use Magento\Catalog\Model\Layer\Resolver;
+use Magento\Catalog\Model\ResourceModel\Category\Collection;
+use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
+use Magento\Catalog\Model\ResourceModel\Category\StateDependentCollectionFactory;
+use Magento\Catalog\Plugin\Block\Topmenu;
+use Magento\Framework\Data\Tree;
+use Magento\Framework\Data\Tree\Node;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class TopmenuTest
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class TopmenuTest extends \PHPUnit\Framework\TestCase
+class TopmenuTest extends TestCase
{
/**
- * @var \Magento\Catalog\Plugin\Block\Topmenu
+ * @var Topmenu
*/
protected $block;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\StoreManagerInterface
+ * @var MockObject|StoreManagerInterface
*/
protected $storeManagerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\Store
+ * @var MockObject|Store
*/
protected $storeMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver
+ * @var MockObject|Resolver
*/
protected $layerResolverMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer
+ * @var MockObject|Layer
*/
protected $catalogLayerMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory
+ * @var MockObject|CollectionFactory
*/
protected $categoryCollectionFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ResourceModel\Category\Collection
+ * @var MockObject|Collection
*/
protected $categoryCollectionMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Helper\Category
+ * @var MockObject|Category
*/
protected $categoryHelperMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category
+ * @var MockObject|\Magento\Catalog\Model\Category
*/
protected $childrenCategoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category
+ * @var MockObject|\Magento\Catalog\Model\Category
*/
protected $categoryMock;
@@ -70,24 +82,24 @@ class TopmenuTest extends \PHPUnit\Framework\TestCase
*
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$rootCategoryId = 2;
$categoryParentId = 3;
$categoryParentIds = [1, 2, 3];
$this->childrenCategoryMock = $this->_getCleanMock(\Magento\Catalog\Model\Category::class);
- $this->categoryHelperMock = $this->_getCleanMock(\Magento\Catalog\Helper\Category::class);
- $this->catalogLayerMock = $this->_getCleanMock(\Magento\Catalog\Model\Layer::class);
+ $this->categoryHelperMock = $this->_getCleanMock(Category::class);
+ $this->catalogLayerMock = $this->_getCleanMock(Layer::class);
$this->categoryMock = $this->_getCleanMock(\Magento\Catalog\Model\Category::class);
- $this->layerResolverMock = $this->_getCleanMock(\Magento\Catalog\Model\Layer\Resolver::class);
- $this->storeMock = $this->_getCleanMock(\Magento\Store\Model\Store::class);
- $this->storeManagerMock = $this->_getCleanMock(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->layerResolverMock = $this->_getCleanMock(Resolver::class);
+ $this->storeMock = $this->_getCleanMock(Store::class);
+ $this->storeManagerMock = $this->_getCleanMock(StoreManagerInterface::class);
$this->categoryCollectionMock = $this->_getCleanMock(
- \Magento\Catalog\Model\ResourceModel\Category\Collection::class
+ Collection::class
);
$this->categoryCollectionFactoryMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Category\StateDependentCollectionFactory::class,
+ StateDependentCollectionFactory::class,
['create']
);
@@ -115,7 +127,7 @@ protected function setUp()
->willReturn($this->categoryCollectionMock);
$this->block = (new ObjectManager($this))->getObject(
- \Magento\Catalog\Plugin\Block\Topmenu::class,
+ Topmenu::class,
[
'catalogCategory' => $this->categoryHelperMock,
'categoryCollectionFactory' => $this->categoryCollectionFactoryMock,
@@ -129,7 +141,7 @@ protected function setUp()
* Get clean mock by class name
*
* @param string $className
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
protected function _getCleanMock($className)
{
@@ -142,9 +154,9 @@ protected function _getCleanMock($className)
*/
public function testBeforeGetHtml()
{
- $treeMock = $this->createMock(\Magento\Framework\Data\Tree::class);
+ $treeMock = $this->createMock(Tree::class);
- $parentCategoryNodeMock = $this->_getCleanMock(\Magento\Framework\Data\Tree\Node::class);
+ $parentCategoryNodeMock = $this->_getCleanMock(Node::class);
$parentCategoryNodeMock->expects($this->once())->method('getTree')->will($this->returnValue($treeMock));
$parentCategoryNodeMock->expects($this->once())->method('addChild');
diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Attribute/Backend/AttributeValidationTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Attribute/Backend/AttributeValidationTest.php
index 463ecf881977e..8ac4ae16f595b 100644
--- a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Attribute/Backend/AttributeValidationTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Attribute/Backend/AttributeValidationTest.php
@@ -8,14 +8,17 @@
namespace Magento\Catalog\Test\Unit\Plugin\Model\Attribute\Backend;
use Magento\Catalog\Plugin\Model\Attribute\Backend\AttributeValidation;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Store\Model\StoreManagerInterface;
-use Magento\Store\Api\Data\StoreInterface;
-use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
use Magento\Framework\DataObject;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class AttributeValidationTest extends \PHPUnit\Framework\TestCase
+class AttributeValidationTest extends TestCase
{
/**
* @var AttributeValidation
@@ -23,12 +26,12 @@ class AttributeValidationTest extends \PHPUnit\Framework\TestCase
private $attributeValidation;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManagerMock;
/**
- * @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreInterface|MockObject
*/
private $storeMock;
@@ -48,21 +51,21 @@ class AttributeValidationTest extends \PHPUnit\Framework\TestCase
private $isProceedMockCalled = false;
/**
- * @var AbstractBackend|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractBackend|MockObject
*/
private $subjectMock;
/**
- * @var AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractAttribute|MockObject
*/
private $attributeMock;
/**
- * @var DataObject|\PHPUnit_Framework_MockObject_MockObject
+ * @var DataObject|MockObject
*/
private $entityMock;
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
@@ -110,7 +113,7 @@ protected function setUp()
* @param bool $defaultStoreUsed
* @param null|int|string $storeId
* @dataProvider aroundValidateDataProvider
- * @throws \Magento\Framework\Exception\NoSuchEntityException
+ * @throws NoSuchEntityException
* @return void
*/
public function testAroundValidate(bool $shouldProceedRun, bool $defaultStoreUsed, $storeId)
diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
index 712aeba59dffe..28b1ff3246673 100644
--- a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Plugin\Model\AttributeSetRepository;
@@ -12,6 +13,7 @@
use Magento\Eav\Api\AttributeSetRepositoryInterface;
use Magento\Eav\Api\Data\AttributeSetInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
@@ -25,14 +27,14 @@ class RemoveProductsTest extends TestCase
private $testSubject;
/**
- * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
private $collectionFactory;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
$this->collectionFactory = $this->getMockBuilder(CollectionFactory::class)
@@ -54,7 +56,7 @@ public function testAfterDelete()
{
$attributeSetId = '1';
- /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collection */
+ /** @var Collection|MockObject $collection */
$collection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
@@ -68,12 +70,12 @@ public function testAfterDelete()
->method('create')
->willReturn($collection);
- /** @var AttributeSetRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject $attributeSetRepository */
+ /** @var AttributeSetRepositoryInterface|MockObject $attributeSetRepository */
$attributeSetRepository = $this->getMockBuilder(AttributeSetRepositoryInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- /** @var AttributeSetInterface|\PHPUnit_Framework_MockObject_MockObject $attributeSet */
+ /** @var AttributeSetInterface|MockObject $attributeSet */
$attributeSet = $this->getMockBuilder(AttributeSetInterface::class)
->setMethods(['getId'])
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Indexer/Category/Product/ExecuteTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Indexer/Category/Product/ExecuteTest.php
index a0c2f8c483fd0..1e56ca6d9fab8 100644
--- a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Indexer/Category/Product/ExecuteTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Indexer/Category/Product/ExecuteTest.php
@@ -3,29 +3,35 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Plugin\Model\Indexer\Category\Product;
-use \Magento\Catalog\Plugin\Model\Indexer\Category\Product\Execute;
+use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction;
+use Magento\Catalog\Plugin\Model\Indexer\Category\Product\Execute;
+use Magento\Framework\App\Cache\TypeListInterface;
+use Magento\PageCache\Model\Config;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ExecuteTest extends \PHPUnit\Framework\TestCase
+class ExecuteTest extends TestCase
{
- /** @var \Magento\Catalog\Plugin\Model\Indexer\Category\Product\Execute */
+ /** @var Execute */
protected $execute;
- /** @var \Magento\PageCache\Model\Config|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Config|MockObject */
protected $config;
- /** @var \Magento\Framework\App\Cache\TypeListInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var TypeListInterface|MockObject */
protected $typeList;
- protected function setUp()
+ protected function setUp(): void
{
- $this->config = $this->getMockBuilder(\Magento\PageCache\Model\Config::class)
+ $this->config = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->setMethods(['isEnabled'])
->getMock();
- $this->typeList = $this->getMockBuilder(\Magento\Framework\App\Cache\TypeListInterface::class)
+ $this->typeList = $this->getMockBuilder(TypeListInterface::class)
->disableOriginalConstructor()
->setMethods(['invalidate'])
->getMockForAbstractClass();
@@ -35,11 +41,11 @@ protected function setUp()
public function testAfterExecute()
{
- $subject = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Category\Product\AbstractAction::class)
+ $subject = $this->getMockBuilder(AbstractAction::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $result = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Category\Product\AbstractAction::class)
+ $result = $this->getMockBuilder(AbstractAction::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -57,11 +63,11 @@ public function testAfterExecute()
public function testAfterExecuteInvalidate()
{
- $subject = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Category\Product\AbstractAction::class)
+ $subject = $this->getMockBuilder(AbstractAction::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $result = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Category\Product\AbstractAction::class)
+ $result = $this->getMockBuilder(AbstractAction::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Product/Action/UpdateAttributesFlushCacheTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Product/Action/UpdateAttributesFlushCacheTest.php
index 8b44a072a777b..f6bfa76fa4127 100644
--- a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Product/Action/UpdateAttributesFlushCacheTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Product/Action/UpdateAttributesFlushCacheTest.php
@@ -3,29 +3,36 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Plugin\Model\Product\Action;
-use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Action;
+use Magento\Catalog\Plugin\Model\Product\Action\UpdateAttributesFlushCache;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\Indexer\CacheContext;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
-class UpdateAttributesFlushCacheTest extends \PHPUnit\Framework\TestCase
+class UpdateAttributesFlushCacheTest extends TestCase
{
/**
- * @var \Magento\Catalog\Plugin\Model\Product\Action\UpdateAttributesFlushCache
+ * @var UpdateAttributesFlushCache
*/
private $model;
- protected function setUp()
+ protected function setUp(): void
{
- $cacheContextMock = $this->createMock(\Magento\Framework\Indexer\CacheContext::class);
+ $cacheContextMock = $this->createMock(CacheContext::class);
- $eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
+ $eventManagerMock = $this->createMock(ManagerInterface::class);
$eventManagerMock->expects($this->once())
->method('dispatch')
->with('clean_cache_by_tags', ['object' => $cacheContextMock]);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->model = $objectManager->getObject(
- \Magento\Catalog\Plugin\Model\Product\Action\UpdateAttributesFlushCache::class,
+ UpdateAttributesFlushCache::class,
[
'cacheContext' => $cacheContextMock,
'eventManager' => $eventManagerMock,
@@ -35,15 +42,15 @@ protected function setUp()
public function testAroundUpdateAttributes()
{
- /** @var \Magento\Catalog\Model\Product\Action $productActionMock */
- $productActionMock = $this->createMock(\Magento\Catalog\Model\Product\Action::class);
+ /** @var Action $productActionMock */
+ $productActionMock = $this->createMock(Action::class);
$this->model->afterUpdateAttributes($productActionMock, $productActionMock);
}
public function testAroundUpdateWebsites()
{
- /** @var \Magento\Catalog\Model\Product\Action $productActionMock */
- $productActionMock = $this->createMock(\Magento\Catalog\Model\Product\Action::class);
+ /** @var Action $productActionMock */
+ $productActionMock = $this->createMock(Action::class);
$this->model->afterUpdateWebsites($productActionMock, $productActionMock);
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/Attribute/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/Attribute/SaveTest.php
index bb64981d4d7db..e8db5ebe38140 100644
--- a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/Attribute/SaveTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/Attribute/SaveTest.php
@@ -3,18 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Plugin\Model\ResourceModel\Attribute;
+use Magento\Catalog\Model\ResourceModel\Attribute;
use Magento\Catalog\Plugin\Model\ResourceModel\Attribute\Save;
-use Magento\PageCache\Model\Config;
use Magento\Framework\App\Cache\TypeListInterface;
-use Magento\Catalog\Model\ResourceModel\Attribute;
+use Magento\PageCache\Model\Config;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class SaveTest extends \PHPUnit\Framework\TestCase
+class SaveTest extends TestCase
{
/**
- * @var Attribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var Attribute|MockObject
*/
private $subjectMock;
@@ -24,16 +27,16 @@ class SaveTest extends \PHPUnit\Framework\TestCase
protected $save;
/**
- * @var Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
protected $config;
/**
- * @var TypeListInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var TypeListInterface|MockObject
*/
protected $typeList;
- protected function setUp()
+ protected function setUp(): void
{
$this->config = $this->createPartialMock(Config::class, ['isEnabled']);
$this->typeList = $this->getMockForAbstractClass(
diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/ConfigTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/ConfigTest.php
index 142de8fd1c5df..41da7ec32ea4d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/ConfigTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/ResourceModel/ConfigTest.php
@@ -40,7 +40,7 @@ class ConfigTest extends TestCase
*/
private $configResourceModelMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->cacheMock = $this->createMock(CacheInterface::class);
$this->cacheStateMock = $this->createMock(StateInterface::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php
index 279c3c3ac8587..81ac41f0aebba 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php
@@ -3,66 +3,76 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Pricing\Price;
-/**
- * Base price test
- */
-class BasePriceTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Pricing\Price\BasePrice;
+use Magento\Catalog\Pricing\Price\RegularPrice;
+use Magento\Catalog\Pricing\Price\SpecialPrice;
+use Magento\Catalog\Pricing\Price\TierPrice;
+use Magento\Framework\Pricing\Adjustment\Calculator;
+use Magento\Framework\Pricing\Price\PriceInterface;
+use Magento\Framework\Pricing\PriceInfo\Base;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class BasePriceTest extends TestCase
{
/**
- * @var \Magento\Catalog\Pricing\Price\BasePrice|\PHPUnit_Framework_MockObject_MockObject
+ * @var BasePrice|MockObject
*/
protected $basePrice;
/**
- * @var \Magento\Framework\Pricing\PriceInfo\Base |\PHPUnit_Framework_MockObject_MockObject
+ * @var Base|MockObject
*/
protected $priceInfoMock;
/**
- * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
protected $saleableItemMock;
/**
- * @var \Magento\Framework\Pricing\Adjustment\Calculator|\PHPUnit_Framework_MockObject_MockObject
+ * @var Calculator|MockObject
*/
protected $calculatorMock;
/**
- * @var \Magento\Catalog\Pricing\Price\RegularPrice|\PHPUnit_Framework_MockObject_MockObject
+ * @var RegularPrice|MockObject
*/
protected $regularPriceMock;
/**
- * @var \Magento\Catalog\Pricing\Price\TierPrice|\PHPUnit_Framework_MockObject_MockObject
+ * @var TierPrice|MockObject
*/
protected $tierPriceMock;
/**
- * @var \Magento\Catalog\Pricing\Price\SpecialPrice|\PHPUnit_Framework_MockObject_MockObject
+ * @var SpecialPrice|MockObject
*/
protected $specialPriceMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject[]
+ * @var MockObject[]
*/
protected $prices;
/**
* Set up
*/
- protected function setUp()
+ protected function setUp(): void
{
$qty = 1;
- $this->saleableItemMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $this->priceInfoMock = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class);
- $this->regularPriceMock = $this->createMock(\Magento\Catalog\Pricing\Price\RegularPrice::class);
- $this->tierPriceMock = $this->createMock(\Magento\Catalog\Pricing\Price\TierPrice::class);
- $this->specialPriceMock = $this->createMock(\Magento\Catalog\Pricing\Price\SpecialPrice::class);
- $this->calculatorMock = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class);
+ $this->saleableItemMock = $this->createMock(Product::class);
+ $this->priceInfoMock = $this->createMock(Base::class);
+ $this->regularPriceMock = $this->createMock(RegularPrice::class);
+ $this->tierPriceMock = $this->createMock(TierPrice::class);
+ $this->specialPriceMock = $this->createMock(SpecialPrice::class);
+ $this->calculatorMock = $this->createMock(Calculator::class);
$this->saleableItemMock->expects($this->once())
->method('getPriceInfo')
@@ -73,9 +83,9 @@ protected function setUp()
'special_price' => $this->specialPriceMock,
];
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $helper = new ObjectManager($this);
$this->basePrice = $helper->getObject(
- \Magento\Catalog\Pricing\Price\BasePrice::class,
+ BasePrice::class,
[
'saleableItem' => $this->saleableItemMock,
'quantity' => $qty,
@@ -118,7 +128,7 @@ public function testGetAmount()
{
$amount = 20.;
- $priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class)
+ $priceMock = $this->getMockBuilder(PriceInterface::class)
->getMockForAbstractClass();
$this->priceInfoMock->expects($this->once())
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CalculateCustomOptionCatalogRuleTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CalculateCustomOptionCatalogRuleTest.php
index 1a99ac5d451f0..894408048b536 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CalculateCustomOptionCatalogRuleTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CalculateCustomOptionCatalogRuleTest.php
@@ -57,7 +57,7 @@ class CalculateCustomOptionCatalogRuleTest extends TestCase
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
$this->saleableItemMock = $this->createMock(Product::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/ConfiguredPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/ConfiguredPriceTest.php
index facd79bafa128..62f7245b6104b 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/ConfiguredPriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/ConfiguredPriceTest.php
@@ -3,15 +3,27 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Pricing\Price;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Configuration\Item\ItemInterface;
+use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface;
+use Magento\Catalog\Model\Product\Option;
+use Magento\Catalog\Model\Product\Option\Type\DefaultType;
use Magento\Catalog\Pricing\Price\ConfiguredPrice;
+use Magento\Framework\Pricing\Adjustment\Calculator;
+use Magento\Framework\Pricing\Price\PriceInterface;
+use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\Pricing\PriceInfo\Base;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test for \Magento\Catalog\Pricing\Price\ConfiguredPrice
*/
-class ConfiguredPriceTest extends \PHPUnit\Framework\TestCase
+class ConfiguredPriceTest extends TestCase
{
/**
* @var float
@@ -19,22 +31,22 @@ class ConfiguredPriceTest extends \PHPUnit\Framework\TestCase
protected $basePriceValue = 800.;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $item;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $product;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $calculator;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $priceInfo;
@@ -44,34 +56,34 @@ class ConfiguredPriceTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceCurrencyInterface|MockObject
*/
protected $priceCurrencyMock;
/**
* Initialize base dependencies
*/
- protected function setUp()
+ protected function setUp(): void
{
- $basePrice = $this->createMock(\Magento\Framework\Pricing\Price\PriceInterface::class);
+ $basePrice = $this->createMock(PriceInterface::class);
$basePrice->expects($this->any())->method('getValue')->will($this->returnValue($this->basePriceValue));
- $this->priceInfo = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class);
+ $this->priceInfo = $this->createMock(Base::class);
$this->priceInfo->expects($this->any())->method('getPrice')->will($this->returnValue($basePrice));
- $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ $this->product = $this->getMockBuilder(Product::class)
->setMethods(['getPriceInfo', 'getOptionById', 'getResource', '__wakeup'])
->disableOriginalConstructor()
->getMock();
$this->product->expects($this->once())->method('getPriceInfo')->will($this->returnValue($this->priceInfo));
- $this->item = $this->getMockBuilder(\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class)
+ $this->item = $this->getMockBuilder(ItemInterface::class)
->getMock();
$this->item->expects($this->any())->method('getProduct')->will($this->returnValue($this->product));
- $this->calculator = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class);
+ $this->calculator = $this->createMock(Calculator::class);
- $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class);
+ $this->priceCurrencyMock = $this->createMock(PriceCurrencyInterface::class);
$this->model = new ConfiguredPrice($this->product, 1, $this->calculator, $this->priceCurrencyMock);
$this->model->setItem($this->item);
@@ -83,7 +95,7 @@ protected function setUp()
public function testOptionsValueGetter()
{
$optionCollection = $this->createMock(
- \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class
+ OptionInterface::class
);
$optionCollection->expects($this->any())->method('getValue')->will($this->returnValue('1,2,3'));
@@ -93,7 +105,7 @@ public function testOptionsValueGetter()
$this->product->expects($this->any())->method('getOptionById')->will($optionCallback);
$itemOption = $this->createMock(
- \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class
+ OptionInterface::class
);
$optionsList = [
'option_1' => $itemOption,
@@ -111,11 +123,11 @@ public function testOptionsValueGetter()
/**
* @param int $optionId
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
protected function createProductOptionStub($optionId)
{
- $option = $this->createMock(\Magento\Catalog\Model\Product\Option::class);
+ $option = $this->createMock(Option::class);
$option->expects($this->any())->method('getId')->will($this->returnValue($optionId));
$option->expects($this->atLeastOnce())->method('groupFactory')->will(
$this->returnValue($this->createOptionTypeStub($option))
@@ -124,12 +136,12 @@ protected function createProductOptionStub($optionId)
}
/**
- * @param \Magento\Catalog\Model\Product\Option $option
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @param Option $option
+ * @return MockObject
*/
- protected function createOptionTypeStub(\Magento\Catalog\Model\Product\Option $option)
+ protected function createOptionTypeStub(Option $option)
{
- $optionType = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\Type\DefaultType::class)
+ $optionType = $this->getMockBuilder(DefaultType::class)
->setMethods(['setOption', 'setConfigurationItem', 'setConfigurationItemOption', 'getOptionPrice'])
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php
index e21cad7a32a99..0937ec64f8bda 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php
@@ -3,71 +3,83 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Pricing\Price;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Option;
+use Magento\Catalog\Model\Product\Option\Type\DefaultType;
+use Magento\Catalog\Model\Product\Option\Type\Select;
use Magento\Catalog\Model\Product\Option\Value;
-
use Magento\Catalog\Pricing\Price\CustomOptionPrice;
+use Magento\Framework\DataObject;
+use Magento\Framework\Pricing\Adjustment\Calculator;
+use Magento\Framework\Pricing\Price\PriceInterface;
+use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\Pricing\PriceInfo\Base;
use Magento\Framework\Pricing\PriceInfoInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
- * Class OptionPriceTest
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CustomOptionPriceTest extends \PHPUnit\Framework\TestCase
+class CustomOptionPriceTest extends TestCase
{
/**
- * @var \Magento\Catalog\Pricing\Price\CustomOptionPrice
+ * @var CustomOptionPrice
*/
protected $object;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $product;
/**
- * @var \Magento\Framework\Pricing\PriceInfo\Base|\PHPUnit_Framework_MockObject_MockObject
+ * @var Base|MockObject
*/
protected $priceInfo;
/**
- * @var \Magento\Framework\Pricing\Adjustment\Calculator|\PHPUnit_Framework_MockObject_MockObject
+ * @var Calculator|MockObject
*/
protected $calculator;
/**
- * @var \Magento\Framework\Pricing\Amount\Base|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\Pricing\Amount\Base|MockObject
*/
protected $amount;
/**
- * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceCurrencyInterface|MockObject
*/
protected $priceCurrencyMock;
/**
* SetUp
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->product = $this->createPartialMock(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
['getOptionById', '__wakeup', 'getPriceInfo', 'getOptions']
);
- $this->priceInfo = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class);
+ $this->priceInfo = $this->createMock(Base::class);
$this->product->expects($this->any())
->method('getPriceInfo')
->will($this->returnValue($this->priceInfo));
- $this->calculator = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class);
+ $this->calculator = $this->createMock(Calculator::class);
$this->amount = $this->createMock(\Magento\Framework\Pricing\Amount\Base::class);
- $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class);
+ $this->priceCurrencyMock = $this->createMock(PriceCurrencyInterface::class);
$this->object = new CustomOptionPrice(
$this->product,
@@ -88,7 +100,7 @@ protected function setupOptions(array $optionsData)
$optionValueMax = $this->getOptionValueMock($optionData['max_option_price']);
$optionValueMin = $this->getOptionValueMock($optionData['min_option_price']);
- $optionItemMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class)
+ $optionItemMock = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->setMethods(['getValues', '__wakeup', 'getIsRequire', 'getId', 'getType'])
->getMock();
@@ -117,7 +129,7 @@ protected function setupSingleValueOptions($optionsData)
{
$options = [];
foreach ($optionsData as $optionData) {
- $optionItemMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class)
+ $optionItemMock = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->setMethods([
'getValues',
@@ -166,7 +178,7 @@ public function testGetValue()
$option2Id = 2;
$option2MaxPrice = 200;
$option2MinPrice = 20;
- $option2Type = \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_CHECKBOX;
+ $option2Type = ProductCustomOptionInterface::OPTION_TYPE_CHECKBOX;
$optionsData = [
[
@@ -281,11 +293,11 @@ public function testGetCustomOptionRange()
/**
* @param int $price
- * @return \PHPUnit_Framework_MockObject_MockObject
+ * @return MockObject
*/
protected function getOptionValueMock($price)
{
- $optionValueMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\Value::class)
+ $optionValueMock = $this->getMockBuilder(Value::class)
->disableOriginalConstructor()
->setMethods(['getPriceType', 'getPrice', 'getId', '__wakeup', 'getOption', 'getData'])
->getMock();
@@ -299,10 +311,10 @@ protected function getOptionValueMock($price)
$optionValueMock->expects($this->any())
->method('getData')
- ->with(\Magento\Catalog\Model\Product\Option\Value::KEY_PRICE)
+ ->with(Value::KEY_PRICE)
->willReturn($price);
- $optionMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class)
+ $optionMock = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->setMethods(['getProduct'])
->getMock();
@@ -311,7 +323,7 @@ protected function getOptionValueMock($price)
$optionMock->expects($this->any())->method('getProduct')->willReturn($this->product);
- $priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class)
+ $priceMock = $this->getMockBuilder(PriceInterface::class)
->disableOriginalConstructor()
->setMethods(['getValue'])
->getMockForAbstractClass();
@@ -331,15 +343,15 @@ public function testGetSelectedOptions()
$optionId2 = 2;
$optionValue = 10;
$optionType = 'select';
- $optionValueMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\DefaultType::class)
+ $optionValueMock = $this->getMockBuilder(DefaultType::class)
->disableOriginalConstructor()
->setMethods(['getValue'])
->getMock();
- $optionMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class)
+ $optionMock = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->setMethods(['getId', 'getType', 'groupFactory', '__wakeup'])
->getMock();
- $groupMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\Type\Select::class)
+ $groupMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->setMethods(['setOption', 'setConfigurationItemOption', 'getOptionPrice'])
->getMock();
@@ -369,7 +381,7 @@ public function testGetSelectedOptions()
$optionValueMock->expects($this->once())
->method('getValue')
->will($this->returnValue($optionValue));
- $optionIds = new \Magento\Framework\DataObject(['value' => '1,2']);
+ $optionIds = new DataObject(['value' => '1,2']);
$customOptions = ['option_ids' => $optionIds, 'option_1' => $optionValueMock, 'option_2' => null];
$this->product->setCustomOptions($customOptions);
@@ -409,7 +421,7 @@ public function testGetOptions()
$optionValueMock->expects($this->once())
->method('getId')
->will($this->returnValue($id));
- $optionItemMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class)
+ $optionItemMock = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->setMethods(['getValues', '__wakeup'])
->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/FinalPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/FinalPriceTest.php
index a1d35988c2985..586e31661a9d1 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/FinalPriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/FinalPriceTest.php
@@ -3,66 +3,76 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Pricing\Price;
-/**
- * Final Price test
- */
-class FinalPriceTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Pricing\Price\BasePrice;
+use Magento\Catalog\Pricing\Price\FinalPrice;
+use Magento\Framework\Pricing\Adjustment\Calculator;
+use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\Pricing\PriceInfo\Base;
+use Magento\Framework\Pricing\PriceInfoInterface;
+use Magento\Framework\Pricing\SaleableInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class FinalPriceTest extends TestCase
{
/**
- * @var \Magento\Catalog\Pricing\Price\FinalPrice
+ * @var FinalPrice
*/
protected $model;
/**
- * @var \Magento\Framework\Pricing\PriceInfoInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceInfoInterface|MockObject
*/
protected $priceInfoMock;
/**
- * @var \Magento\Catalog\Pricing\Price\BasePrice|\PHPUnit_Framework_MockObject_MockObject
+ * @var BasePrice|MockObject
*/
protected $basePriceMock;
/**
- * @var \Magento\Framework\Pricing\SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var SaleableInterface|MockObject
*/
protected $saleableMock;
/**
- * @var \Magento\Framework\Pricing\Adjustment\Calculator|\PHPUnit_Framework_MockObject_MockObject
+ * @var Calculator|MockObject
*/
protected $calculatorMock;
/**
- * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceCurrencyInterface|MockObject
*/
protected $priceCurrencyMock;
/**
* Set up function
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->saleableMock = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $this->saleableMock = $this->createMock(Product::class);
$this->priceInfoMock = $this->basePriceMock = $this->createMock(
- \Magento\Framework\Pricing\PriceInfo\Base::class
+ Base::class
);
- $this->basePriceMock = $this->createMock(\Magento\Catalog\Pricing\Price\BasePrice::class);
+ $this->basePriceMock = $this->createMock(BasePrice::class);
- $this->calculatorMock = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class);
+ $this->calculatorMock = $this->createMock(Calculator::class);
$this->saleableMock->expects($this->once())
->method('getPriceInfo')
->will($this->returnValue($this->priceInfoMock));
$this->priceInfoMock->expects($this->any())
->method('getPrice')
- ->with($this->equalTo(\Magento\Catalog\Pricing\Price\BasePrice::PRICE_CODE))
+ ->with($this->equalTo(BasePrice::PRICE_CODE))
->will($this->returnValue($this->basePriceMock));
- $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class);
+ $this->priceCurrencyMock = $this->createMock(PriceCurrencyInterface::class);
- $this->model = new \Magento\Catalog\Pricing\Price\FinalPrice(
+ $this->model = new FinalPrice(
$this->saleableMock,
1,
$this->calculatorMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/MinimalTierPriceCalculatorTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/MinimalTierPriceCalculatorTest.php
index 1c50271976d15..26921f65190a3 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/MinimalTierPriceCalculatorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/MinimalTierPriceCalculatorTest.php
@@ -3,18 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Pricing\Price;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Catalog\Pricing\Price\MinimalTierPriceCalculator;
-use Magento\Framework\Pricing\SaleableInterface;
-use Magento\Framework\Pricing\PriceInfoInterface;
use Magento\Catalog\Pricing\Price\TierPrice;
-use Magento\Framework\Pricing\Amount\AmountInterface;
use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
+use Magento\Framework\Pricing\Amount\AmountInterface;
+use Magento\Framework\Pricing\PriceInfoInterface;
+use Magento\Framework\Pricing\SaleableInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class MinimalTierPriceCalculatorTest extends \PHPUnit\Framework\TestCase
+class MinimalTierPriceCalculatorTest extends TestCase
{
/**
* @var ObjectManager
@@ -27,26 +30,26 @@ class MinimalTierPriceCalculatorTest extends \PHPUnit\Framework\TestCase
private $object;
/**
- * @var SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var SaleableInterface|MockObject
*/
private $saleable;
/**
- * @var PriceInfoInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceInfoInterface|MockObject
*/
private $priceInfo;
/**
- * @var TierPrice|\PHPUnit_Framework_MockObject_MockObject
+ * @var TierPrice|MockObject
*/
private $price;
/**
- * @var CalculatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CalculatorInterface|MockObject
*/
private $calculator;
- public function setUp()
+ public function setUp(): void
{
$this->price = $this->createMock(TierPrice::class);
$this->priceInfo = $this->getMockForAbstractClass(PriceInfoInterface::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/RegularPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/RegularPriceTest.php
index 970331cc70963..bdecb15cf0f52 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/RegularPriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/RegularPriceTest.php
@@ -3,56 +3,61 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Pricing\Price;
-use \Magento\Catalog\Pricing\Price\RegularPrice;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Pricing\Price\RegularPrice;
+use Magento\Framework\Pricing\Adjustment\Calculator;
+use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\Pricing\PriceInfo\Base;
+use Magento\Framework\Pricing\PriceInfoInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class RegularPriceTest
- */
-class RegularPriceTest extends \PHPUnit\Framework\TestCase
+class RegularPriceTest extends TestCase
{
/**
- * @var \Magento\Catalog\Pricing\Price\RegularPrice
+ * @var RegularPrice
*/
protected $regularPrice;
/**
- * @var \Magento\Framework\Pricing\PriceInfoInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceInfoInterface|MockObject
*/
protected $priceInfoMock;
/**
- * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
protected $saleableItemMock;
/**
- * @var \Magento\Framework\Pricing\Adjustment\Calculator|\PHPUnit_Framework_MockObject_MockObject
+ * @var Calculator|MockObject
*/
protected $calculatorMock;
/**
- * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceCurrencyInterface|MockObject
*/
protected $priceCurrencyMock;
/**
* Test setUp
*/
- protected function setUp()
+ protected function setUp(): void
{
$qty = 1;
- $this->saleableItemMock = $this->createMock(\Magento\Catalog\Model\Product::class);
- $this->priceInfoMock = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class);
- $this->calculatorMock = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class);
+ $this->saleableItemMock = $this->createMock(Product::class);
+ $this->priceInfoMock = $this->createMock(Base::class);
+ $this->calculatorMock = $this->createMock(Calculator::class);
$this->saleableItemMock->expects($this->once())
->method('getPriceInfo')
->will($this->returnValue($this->priceInfoMock));
- $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class);
+ $this->priceCurrencyMock = $this->createMock(PriceCurrencyInterface::class);
$this->regularPrice = new RegularPrice(
$this->saleableItemMock,
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/SpecialPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/SpecialPriceTest.php
index 3219967ba95e1..2ddc34e6c9a29 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/SpecialPriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/SpecialPriceTest.php
@@ -3,26 +3,36 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Pricing\Price;
-class SpecialPriceTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Pricing\Price\SpecialPrice;
+use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\Pricing\PriceInfoInterface;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class SpecialPriceTest extends TestCase
{
/**
- * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+ * @var ObjectManager
*/
protected $objectManager;
/**
- * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceCurrencyInterface|MockObject
*/
protected $priceCurrencyMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class);
+ $this->priceCurrencyMock = $this->createMock(PriceCurrencyInterface::class);
- $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->objectManager = new ObjectManager($this);
}
/**
@@ -36,7 +46,7 @@ public function testGetValue($isValidInterval, $specialPrice, $specialPriceValue
{
$expected = 56.34;
$specialPriceModel = $this->objectManager->getObject(
- \Magento\Catalog\Pricing\Price\SpecialPrice::class,
+ SpecialPrice::class,
[
'saleableItem' => $this->prepareSaleableItem($specialPrice),
'localeDate' => $this->prepareLocaleDate($isValidInterval),
@@ -58,12 +68,12 @@ public function testGetValue($isValidInterval, $specialPrice, $specialPriceValue
/**
* @param float $specialPrice
- * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product
+ * @return MockObject|Product
*/
protected function prepareSaleableItem($specialPrice)
{
$saleableItemMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
['getSpecialPrice', 'getPriceInfo', 'getStore', '__wakeup']
);
@@ -72,7 +82,7 @@ protected function prepareSaleableItem($specialPrice)
->will($this->returnValue($specialPrice));
$priceInfo = $this->getMockBuilder(
- \Magento\Framework\Pricing\PriceInfoInterface::class
+ PriceInfoInterface::class
)->disableOriginalConstructor()->getMockForAbstractClass();
$priceInfo->expects($this->any())
@@ -88,12 +98,12 @@ protected function prepareSaleableItem($specialPrice)
/**
* @param bool $isValidInterval
- * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Stdlib\DateTime\TimezoneInterface
+ * @return MockObject|TimezoneInterface
*/
protected function prepareLocaleDate($isValidInterval)
{
$localeDate = $this->getMockBuilder(
- \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class
+ TimezoneInterface::class
)->disableOriginalConstructor()->getMockForAbstractClass();
$localeDate->expects($this->any())
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php
index ade8829b278ae..18e5d7beeb87e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php
@@ -3,22 +3,34 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Pricing\Price;
-use Magento\Catalog\Pricing\Price\TierPrice;
+use Magento\Catalog\Model\Product;
use Magento\Catalog\Pricing\Price\FinalPrice;
-use Magento\Framework\Pricing\Amount\AmountInterface;
-use Magento\Framework\Pricing\Price\PriceInterface;
+use Magento\Catalog\Pricing\Price\TierPrice;
+use Magento\Customer\Api\GroupManagementInterface;
use Magento\Customer\Model\Group;
+use Magento\Customer\Model\Group\RetrieverInterface;
use Magento\Customer\Model\GroupManagement;
+use Magento\Customer\Model\Session;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
+use Magento\Framework\Pricing\Adjustment\Calculator;
+use Magento\Framework\Pricing\Amount\AmountInterface;
+use Magento\Framework\Pricing\Price\PriceInterface;
+use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\Pricing\PriceInfo\Base;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Test for \Magento\Catalog\Pricing\Price\TierPrice
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class TierPriceTest extends \PHPUnit\Framework\TestCase
+class TierPriceTest extends TestCase
{
/**
* Test customer group
@@ -28,12 +40,12 @@ class TierPriceTest extends \PHPUnit\Framework\TestCase
private $customerGroup = Group::NOT_LOGGED_IN_ID;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $priceInfo;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $product;
@@ -43,12 +55,12 @@ class TierPriceTest extends \PHPUnit\Framework\TestCase
private $quantity = 3.;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $calculator;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $session;
@@ -58,42 +70,42 @@ class TierPriceTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceCurrencyInterface|MockObject
*/
private $priceCurrencyMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
private $groupManagement;
/**
- * @var \Magento\Customer\Model\Group\RetrieverInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RetrieverInterface|MockObject
*/
private $customerGroupRetriever;
/**
* Initialize base dependencies
*/
- protected function setUp()
+ protected function setUp(): void
{
- $this->priceInfo = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class);
+ $this->priceInfo = $this->createMock(Base::class);
$this->product = $this->createPartialMock(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
['getPriceInfo', 'hasCustomerGroupId', 'getCustomerGroupId', 'getResource', '__wakeup']
);
$this->product->expects($this->any())->method('getPriceInfo')->will($this->returnValue($this->priceInfo));
- $this->customerGroupRetriever = $this->getMockBuilder(\Magento\Customer\Model\Group\RetrieverInterface::class)
+ $this->customerGroupRetriever = $this->getMockBuilder(RetrieverInterface::class)
->disableOriginalConstructor()->getMock();
- $this->session = $this->createMock(\Magento\Customer\Model\Session::class);
+ $this->session = $this->createMock(Session::class);
$this->session->expects($this->any())->method('getCustomerGroupId')
->will($this->returnValue($this->customerGroup));
- $this->customerGroupRetriever = $this->createMock(\Magento\Customer\Model\Group\RetrieverInterface::class);
- $this->calculator = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class);
- $this->groupManagement = $this->createMock(\Magento\Customer\Api\GroupManagementInterface::class);
+ $this->customerGroupRetriever = $this->createMock(RetrieverInterface::class);
+ $this->calculator = $this->createMock(Calculator::class);
+ $this->groupManagement = $this->createMock(GroupManagementInterface::class);
- $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class);
+ $this->priceCurrencyMock = $this->createMock(PriceCurrencyInterface::class);
$this->model = new TierPrice(
$this->product,
@@ -212,9 +224,9 @@ public function testGetterStoredTierPrices()
$this->product->expects($this->once())->method('getCustomerGroupId')
->will($this->returnValue($this->customerGroup));
- $backendMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class);
+ $backendMock = $this->createMock(AbstractBackend::class);
- $attributeMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class);
+ $attributeMock = $this->createMock(AbstractAttribute::class);
$attributeMock->expects($this->once())->method('getBackend')->will($this->returnValue($backendMock));
$productResource = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product::class);
@@ -354,7 +366,7 @@ public function providerForGetterTierPriceList()
*/
public function testGetSavePercent($basePrice, $tierPrice, $savedPercent)
{
- /** @var AmountInterface|\PHPUnit_Framework_MockObject_MockObject $amount */
+ /** @var AmountInterface|MockObject $amount */
$amount = $this->getMockForAbstractClass(AmountInterface::class);
$amount->expects($this->any())
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php
index 397cd0fb2d165..dc1474f1d40ca 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php
@@ -3,117 +3,139 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Pricing\Render;
+use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolverInterface;
use Magento\Catalog\Pricing\Price\FinalPrice;
use Magento\Catalog\Pricing\Price\MinimalPriceCalculatorInterface;
+use Magento\Catalog\Pricing\Price\RegularPrice;
+use Magento\Catalog\Pricing\Render\FinalPriceBox;
+use Magento\Framework\App\Cache\StateInterface;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\State;
+use Magento\Framework\Event\Test\Unit\ManagerStub;
use Magento\Framework\Pricing\Amount\AmountInterface;
+use Magento\Framework\Pricing\Price\PriceInterface;
+use Magento\Framework\Pricing\PriceInfoInterface;
use Magento\Framework\Pricing\Render\Amount;
+use Magento\Framework\Pricing\Render\PriceBox;
+use Magento\Framework\Pricing\Render\RendererPool;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\UrlInterface;
+use Magento\Framework\View\Element\Template\Context;
+use Magento\Framework\View\Element\Template\File\Resolver;
+use Magento\Framework\View\Layout;
+use Magento\Framework\View\LayoutInterface;
+use Magento\Msrp\Pricing\Price\MsrpPrice;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
/**
- * Class FinalPriceBoxTest
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class FinalPriceBoxTest extends \PHPUnit\Framework\TestCase
+class FinalPriceBoxTest extends TestCase
{
/**
- * @var \Magento\Catalog\Pricing\Render\FinalPriceBox
+ * @var FinalPriceBox
*/
protected $object;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $priceType;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $priceInfo;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $priceBox;
/**
- * @var \Magento\Framework\View\LayoutInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutInterface|MockObject
*/
protected $layout;
/**
- * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
+ * @var Product|MockObject
*/
protected $product;
/**
- * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LoggerInterface|MockObject
*/
protected $logger;
/**
- * @var \Magento\Framework\Pricing\Render\RendererPool|\PHPUnit_Framework_MockObject_MockObject
+ * @var RendererPool|MockObject
*/
protected $rendererPool;
/**
- * @var \Magento\Framework\Pricing\Price\PriceInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceInterface|MockObject
*/
protected $price;
/**
- * @var SalableResolverInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var SalableResolverInterface|MockObject
*/
private $salableResolverMock;
/**
- * @var MinimalPriceCalculatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var MinimalPriceCalculatorInterface|MockObject
*/
private $minimalPriceCalculator;
- protected function setUp()
+ protected function setUp(): void
{
$this->product = $this->createPartialMock(
- \Magento\Catalog\Model\Product::class,
+ Product::class,
['getPriceInfo', '__wakeup', 'getCanShowPrice', 'isSalable', 'getId']
);
- $this->priceInfo = $this->createMock(\Magento\Framework\Pricing\PriceInfoInterface::class);
+ $this->priceInfo = $this->createMock(PriceInfoInterface::class);
$this->product->expects($this->any())
->method('getPriceInfo')
->will($this->returnValue($this->priceInfo));
- $eventManager = $this->createMock(\Magento\Framework\Event\Test\Unit\ManagerStub::class);
- $this->layout = $this->createMock(\Magento\Framework\View\Layout::class);
+ $eventManager = $this->createMock(ManagerStub::class);
+ $this->layout = $this->createMock(Layout::class);
- $this->priceBox = $this->createMock(\Magento\Framework\Pricing\Render\PriceBox::class);
- $this->logger = $this->createMock(\Psr\Log\LoggerInterface::class);
+ $this->priceBox = $this->createMock(PriceBox::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$this->layout->expects($this->any())->method('getBlock')->willReturn($this->priceBox);
- $cacheState = $this->getMockBuilder(\Magento\Framework\App\Cache\StateInterface::class)
+ $cacheState = $this->getMockBuilder(StateInterface::class)
->getMockForAbstractClass();
- $appState = $this->getMockBuilder(\Magento\Framework\App\State::class)
+ $appState = $this->getMockBuilder(State::class)
->disableOriginalConstructor()
->getMock();
- $resolver = $this->getMockBuilder(\Magento\Framework\View\Element\Template\File\Resolver::class)
+ $resolver = $this->getMockBuilder(Resolver::class)
->disableOriginalConstructor()
->getMock();
- $urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)->getMockForAbstractClass();
+ $urlBuilder = $this->getMockBuilder(UrlInterface::class)->getMockForAbstractClass();
- $store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)->getMockForAbstractClass();
- $storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ $store = $this->getMockBuilder(StoreInterface::class)->getMockForAbstractClass();
+ $storeManager = $this->getMockBuilder(StoreManagerInterface::class)
->setMethods(['getStore', 'getCode'])
->getMockForAbstractClass();
$storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
- $scopeConfigMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class);
- $context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class);
+ $scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
+ $context = $this->createMock(Context::class);
$context->expects($this->any())
->method('getEventManager')
->will($this->returnValue($eventManager));
@@ -142,23 +164,23 @@ protected function setUp()
->method('getUrlBuilder')
->will($this->returnValue($urlBuilder));
- $this->rendererPool = $this->getMockBuilder(\Magento\Framework\Pricing\Render\RendererPool::class)
+ $this->rendererPool = $this->getMockBuilder(RendererPool::class)
->disableOriginalConstructor()
->getMock();
- $this->price = $this->createMock(\Magento\Framework\Pricing\Price\PriceInterface::class);
+ $this->price = $this->createMock(PriceInterface::class);
$this->price->expects($this->any())
->method('getPriceCode')
- ->will($this->returnValue(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE));
+ ->will($this->returnValue(FinalPrice::PRICE_CODE));
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->salableResolverMock = $this->getMockBuilder(SalableResolverInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->minimalPriceCalculator = $this->getMockForAbstractClass(MinimalPriceCalculatorInterface::class);
$this->object = $objectManager->getObject(
- \Magento\Catalog\Pricing\Render\FinalPriceBox::class,
+ FinalPriceBox::class,
[
'context' => $context,
'saleableItem' => $this->product,
@@ -173,7 +195,7 @@ protected function setUp()
public function testRenderMsrpDisabled()
{
- $priceType = $this->createMock(\Magento\Msrp\Pricing\Price\MsrpPrice::class);
+ $priceType = $this->createMock(MsrpPrice::class);
$this->priceInfo->expects($this->once())
->method('getPrice')
->with($this->equalTo('msrp_price'))
@@ -208,7 +230,7 @@ public function testNotSalableItem()
public function testRenderMsrpEnabled()
{
- $priceType = $this->createMock(\Magento\Msrp\Pricing\Price\MsrpPrice::class);
+ $priceType = $this->createMock(MsrpPrice::class);
$this->priceInfo->expects($this->once())
->method('getPrice')
->with($this->equalTo('msrp_price'))
@@ -224,7 +246,7 @@ public function testRenderMsrpEnabled()
->with($this->equalTo($this->product))
->will($this->returnValue(true));
- $priceBoxRender = $this->getMockBuilder(\Magento\Framework\Pricing\Render\PriceBox::class)
+ $priceBoxRender = $this->getMockBuilder(PriceBox::class)
->disableOriginalConstructor()
->getMock();
$priceBoxRender->expects($this->once())
@@ -316,10 +338,10 @@ public function testRenderAmountMinimal()
*/
public function testHasSpecialPrice($regularPrice, $finalPrice, $expectedResult)
{
- $regularPriceType = $this->createMock(\Magento\Catalog\Pricing\Price\RegularPrice::class);
- $finalPriceType = $this->createMock(\Magento\Catalog\Pricing\Price\FinalPrice::class);
- $regularPriceAmount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class);
- $finalPriceAmount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class);
+ $regularPriceType = $this->createMock(RegularPrice::class);
+ $finalPriceType = $this->createMock(FinalPrice::class);
+ $regularPriceAmount = $this->getMockForAbstractClass(AmountInterface::class);
+ $finalPriceAmount = $this->getMockForAbstractClass(AmountInterface::class);
$regularPriceAmount->expects($this->once())
->method('getValue')
@@ -337,11 +359,11 @@ public function testHasSpecialPrice($regularPrice, $finalPrice, $expectedResult)
$this->priceInfo->expects($this->at(0))
->method('getPrice')
- ->with(\Magento\Catalog\Pricing\Price\RegularPrice::PRICE_CODE)
+ ->with(RegularPrice::PRICE_CODE)
->will($this->returnValue($regularPriceType));
$this->priceInfo->expects($this->at(1))
->method('getPrice')
- ->with(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)
+ ->with(FinalPrice::PRICE_CODE)
->will($this->returnValue($finalPriceType));
$this->assertEquals($expectedResult, $this->object->hasSpecialPrice());
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/PriceBoxTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/PriceBoxTest.php
index e4d531e91fa07..6f54d3874a8e5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/PriceBoxTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/PriceBoxTest.php
@@ -3,37 +3,43 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Pricing\Render;
-/**
- * Class PriceBoxTest
- */
-class PriceBoxTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Pricing\Render\PriceBox;
+use Magento\Framework\Json\Helper\Data;
+use Magento\Framework\Math\Random;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class PriceBoxTest extends TestCase
{
/**
- * @var \Magento\Catalog\Pricing\Render\PriceBox
+ * @var PriceBox
*/
protected $object;
/**
- * @var \Magento\Framework\Json\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var Data|MockObject
*/
protected $jsonHelperMock;
/**
- * @var \Magento\Framework\Math\Random|\PHPUnit_Framework_MockObject_MockObject
+ * @var Random|MockObject
*/
protected $mathRandom;
- protected function setUp()
+ protected function setUp(): void
{
- $this->jsonHelperMock = $this->createPartialMock(\Magento\Framework\Json\Helper\Data::class, ['jsonEncode']);
- $this->mathRandom = $this->createMock(\Magento\Framework\Math\Random::class);
+ $this->jsonHelperMock = $this->createPartialMock(Data::class, ['jsonEncode']);
+ $this->mathRandom = $this->createMock(Random::class);
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->object = $objectManager->getObject(
- \Magento\Catalog\Pricing\Render\PriceBox::class,
+ PriceBox::class,
[
'jsonHelper' => $this->jsonHelperMock,
'mathRandom' => $this->mathRandom,
@@ -79,7 +85,7 @@ public function testGetRandomString()
*/
public function testGetCanDisplayQty($typeCode, $expected)
{
- $product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getTypeId', '__wakeup']);
+ $product = $this->createPartialMock(Product::class, ['getTypeId', '__wakeup']);
$product->expects($this->once())
->method('getTypeId')
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/RenderTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/RenderTest.php
index 37c6e3a059c0c..409d87458fedb 100644
--- a/app/code/Magento/Catalog/Test/Unit/Pricing/RenderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/RenderTest.php
@@ -3,45 +3,55 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Pricing;
-/**
- * Class RenderTest
- */
-class RenderTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Pricing\Render;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Event\Test\Unit\ManagerStub;
+use Magento\Framework\Registry;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Element\Template\Context;
+use Magento\Framework\View\Layout;
+use Magento\Framework\View\LayoutInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class RenderTest extends TestCase
{
/**
- * @var \Magento\Catalog\Pricing\Render
+ * @var Render
*/
protected $object;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registry;
/**
- * @var \Magento\Framework\View\LayoutInterface | \PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutInterface|MockObject
*/
protected $layout;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var MockObject
*/
protected $pricingRenderBlock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->registry = $this->createPartialMock(\Magento\Framework\Registry::class, ['registry']);
+ $this->registry = $this->createPartialMock(Registry::class, ['registry']);
$this->pricingRenderBlock = $this->createMock(\Magento\Framework\Pricing\Render::class);
- $this->layout = $this->createMock(\Magento\Framework\View\Layout::class);
+ $this->layout = $this->createMock(Layout::class);
- $eventManager = $this->createMock(\Magento\Framework\Event\Test\Unit\ManagerStub::class);
- $scopeConfigMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class);
- $context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class);
+ $eventManager = $this->createMock(ManagerStub::class);
+ $scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
+ $context = $this->createMock(Context::class);
$context->expects($this->any())
->method('getEventManager')
->will($this->returnValue($eventManager));
@@ -52,9 +62,9 @@ protected function setUp()
->method('getScopeConfig')
->will($this->returnValue($scopeConfigMock));
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->object = $objectManager->getObject(
- \Magento\Catalog\Pricing\Render::class,
+ Render::class,
[
'context' => $context,
'registry' => $this->registry,
@@ -71,7 +81,7 @@ public function testToHtmlProductFromRegistry()
{
$expectedValue = 'string';
- $product = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $product = $this->createMock(Product::class);
$this->layout->expects($this->any())
->method('getBlock')
@@ -100,7 +110,7 @@ public function testToHtmlProductFromParentBlock()
{
$expectedValue = 'string';
- $product = $this->createMock(\Magento\Catalog\Model\Product::class);
+ $product = $this->createMock(Product::class);
$this->registry->expects($this->never())
->method('registry');
diff --git a/app/code/Magento/Catalog/Test/Unit/Setup/CategorySetupTest.php b/app/code/Magento/Catalog/Test/Unit/Setup/CategorySetupTest.php
index ad26074155531..3c1deb795287d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Setup/CategorySetupTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Setup/CategorySetupTest.php
@@ -3,17 +3,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Setup;
-class CategorySetupTest extends \PHPUnit\Framework\TestCase
+use Magento\Catalog\Setup\CategorySetup;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\TestCase;
+
+class CategorySetupTest extends TestCase
{
- /** @var \Magento\Catalog\Setup\CategorySetup */
+ /** @var CategorySetup */
protected $unit;
- protected function setUp()
+ protected function setUp(): void
{
- $this->unit = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject(
- \Magento\Catalog\Setup\CategorySetup::class
+ $this->unit = (new ObjectManager($this))->getObject(
+ CategorySetup::class
);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/AllowedProductTypesTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/AllowedProductTypesTest.php
index d7230e6fa80c3..f3b9c4d187517 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/AllowedProductTypesTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/AllowedProductTypesTest.php
@@ -3,13 +3,16 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use Magento\Catalog\Ui\AllowedProductTypes;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Ui\AllowedProductTypes;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\TestCase;
-class AllowedProductTypesTest extends \PHPUnit\Framework\TestCase
+class AllowedProductTypesTest extends TestCase
{
/**
* @var ObjectManagerHelper
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php
index ba81d42e75c76..3346a01fedc7a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php
@@ -13,8 +13,8 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
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;
+use Magento\Ui\Component\Listing\Columns\ColumnInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/FilterFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/FilterFactoryTest.php
index 1e72b7ba35864..57521ec8bbc68 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/FilterFactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/FilterFactoryTest.php
@@ -52,7 +52,7 @@ class FilterFactoryTest extends TestCase
/**
* Setup environment for test
*/
- protected function setUp()
+ protected function setUp(): void
{
$objectManager = new ObjectManager($this);
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Listing/Columns/AbstractColumnTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Listing/Columns/AbstractColumnTest.php
index c07c96e4a8162..12ff0d7ee15d3 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Listing/Columns/AbstractColumnTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Listing/Columns/AbstractColumnTest.php
@@ -3,18 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\Component\Listing\Columns;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
+use Magento\Framework\View\Element\UiComponent\Processor;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
-use Magento\Framework\View\Element\UiComponent\Processor;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class AbstractColumnTest
- */
-abstract class AbstractColumnTest extends \PHPUnit\Framework\TestCase
+abstract class AbstractColumnTest extends TestCase
{
/**
* @var Column
@@ -22,17 +23,17 @@ abstract class AbstractColumnTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var ContextInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ContextInterface|MockObject
*/
protected $contextMock;
/**
- * @var UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var UiComponentFactory|MockObject
*/
protected $uiComponentFactoryMock;
/**
- * @var Processor|\PHPUnit_Framework_MockObject_MockObject
+ * @var Processor|MockObject
*/
protected $processorMock;
@@ -41,7 +42,7 @@ abstract class AbstractColumnTest extends \PHPUnit\Framework\TestCase
*/
protected $objectManager;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Listing/Columns/AttributeSetTextTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Listing/Columns/AttributeSetTextTest.php
index c9afe3dbb7210..601f14921de28 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Listing/Columns/AttributeSetTextTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Listing/Columns/AttributeSetTextTest.php
@@ -3,31 +3,31 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\Component\Listing\Columns;
use Magento\Catalog\Ui\Component\Listing\Columns\AttributeSetText;
use Magento\Eav\Api\AttributeSetRepositoryInterface;
use Magento\Eav\Api\Data\AttributeSetInterface;
+use PHPUnit\Framework\MockObject\MockObject;
-/**
- * Class AttributeSetTextTest
- */
class AttributeSetTextTest extends AbstractColumnTest
{
const ATTRIBUTE_SET_ID = 4;
const ATTRIBUTE_SET_NAME = 'Default';
/**
- * @var AttributeSetRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeSetRepositoryInterface|MockObject
*/
protected $attributeSetRepositoryMock;
/**
- * @var AttributeSetInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeSetInterface|MockObject
*/
protected $attributeSetMock;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Listing/Columns/StatusTextTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Listing/Columns/StatusTextTest.php
index 0beef4d913091..0e07dc06856fa 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Listing/Columns/StatusTextTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Listing/Columns/StatusTextTest.php
@@ -3,26 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\Component\Listing\Columns;
-use Magento\Catalog\Ui\Component\Listing\Columns\StatusText;
-use Magento\Catalog\Model\Product\Attribute\Source\Status;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Model\Product\Attribute\Source\Status;
+use Magento\Catalog\Ui\Component\Listing\Columns\StatusText;
+use PHPUnit\Framework\MockObject\MockObject;
-/**
- * Class StatusTextTest
- */
class StatusTextTest extends AbstractColumnTest
{
const STATUS_ID = 1;
const STATUS_TEXT = 'Enabled';
/**
- * @var Status|\PHPUnit_Framework_MockObject_MockObject
+ * @var Status|MockObject
*/
protected $statusMock;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/Form/Categories/OptionsTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/Form/Categories/OptionsTest.php
index c2c3a63bafae8..ed0292ba2361e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/Form/Categories/OptionsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/Form/Categories/OptionsTest.php
@@ -3,15 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\Component\Product\Form\Categories;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
+use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
use Magento\Catalog\Ui\Component\Product\Form\Categories\Options as CategoriesOptions;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
-use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
-use Magento\Catalog\Model\Category;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class OptionsTest extends \PHPUnit\Framework\TestCase
+class OptionsTest extends TestCase
{
/**
* @var CategoriesOptions
@@ -24,7 +28,7 @@ class OptionsTest extends \PHPUnit\Framework\TestCase
protected $objectManagerHelper;
/**
- * @var CategoryCollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryCollectionFactory|MockObject
*/
protected $categoryCollectionFactoryMock;
@@ -39,7 +43,7 @@ class OptionsTest extends \PHPUnit\Framework\TestCase
Category::KEY_IS_ACTIVE => 'getIsActive'
];
- protected function setUp()
+ protected function setUp(): void
{
$this->categoryCollectionFactoryMock = $this->getMockBuilder(CategoryCollectionFactory::class)
->setMethods(['create'])
@@ -141,7 +145,7 @@ public function testToOptionArray()
/**
* @param array $categories
- * @return CategoryCollection|\PHPUnit_Framework_MockObject_MockObject
+ * @return CategoryCollection|MockObject
*/
protected function getCategoryCollectionMock($categories)
{
@@ -168,7 +172,7 @@ protected function getCategoryCollectionMock($categories)
/**
* @param array $data
- * @return Category|\PHPUnit_Framework_MockObject_MockObject
+ * @return Category|MockObject
*/
protected function getCategoryMock($data)
{
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php
index f34ebd2e1cf4d..b7e41b61237a1 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php
@@ -11,12 +11,14 @@
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
+use Magento\Framework\View\Element\UiComponent\Processor;
use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* MassAction test for Component Product
*/
-class MassActionTest extends \PHPUnit\Framework\TestCase
+class MassActionTest extends TestCase
{
/**
* @var ContextInterface|MockObject
@@ -38,7 +40,7 @@ class MassActionTest extends \PHPUnit\Framework\TestCase
*/
private $massAction;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
@@ -72,7 +74,7 @@ public function testGetComponentName()
*/
public function testPrepare($componentName, $componentData, $isAllowed = true, $expectActionConfig = true)
{
- $processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class)
+ $processor = $this->getMockBuilder(Processor::class)
->disableOriginalConstructor()
->getMock();
$this->contextMock->expects($this->atLeastOnce())->method('getProcessor')->willReturn($processor);
@@ -108,6 +110,7 @@ public function getPrepareDataProvider() : array
'type' => 'first_action',
'label' => 'First Action',
'url' => '/module/controller/firstAction',
+ '__disableTmpl' => true
],
],
[
@@ -127,6 +130,7 @@ public function getPrepareDataProvider() : array
'url' => '/module/controller/secondSubAction2'
],
],
+ '__disableTmpl' => true
],
],
[
@@ -146,6 +150,7 @@ public function getPrepareDataProvider() : array
'url' => '/module/controller/disable'
],
],
+ '__disableTmpl' => true
],
],
[
@@ -165,6 +170,7 @@ public function getPrepareDataProvider() : array
'url' => '/module/controller/disable'
],
],
+ '__disableTmpl' => true
],
false,
false
@@ -175,6 +181,7 @@ public function getPrepareDataProvider() : array
'type' => 'delete',
'label' => 'First Action',
'url' => '/module/controller/delete',
+ '__disableTmpl' => true
],
],
[
@@ -183,6 +190,7 @@ public function getPrepareDataProvider() : array
'type' => 'delete',
'label' => 'First Action',
'url' => '/module/controller/delete',
+ '__disableTmpl' => true
],
false,
false
@@ -193,6 +201,7 @@ public function getPrepareDataProvider() : array
'type' => 'delete',
'label' => 'First Action',
'url' => '/module/controller/attributes',
+ '__disableTmpl' => true
],
],
[
@@ -201,6 +210,7 @@ public function getPrepareDataProvider() : array
'type' => 'delete',
'label' => 'First Action',
'url' => '/module/controller/attributes',
+ '__disableTmpl' => true
],
false,
false
@@ -232,7 +242,7 @@ public function testIsActionAllowed($expected, $actionType, $callNum, $resource
public function isActionAllowedDataProvider()
{
return [
- 'other' => [true, 'other', 0,],
+ 'other' => [true, 'other', 0],
'delete-allowed' => [true, 'delete', 1, 'Magento_Catalog::products'],
'delete-not-allowed' => [false, 'delete', 1, 'Magento_Catalog::products', false],
'status-allowed' => [true, 'status', 1, 'Magento_Catalog::products'],
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/CatalogEavValidationRulesTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/CatalogEavValidationRulesTest.php
index 57b277a786ea3..357cb8d04e59a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/CatalogEavValidationRulesTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/CatalogEavValidationRulesTest.php
@@ -3,13 +3,17 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Catalog\Ui\DataProvider\CatalogEavValidationRules;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class CatalogEavValidationRulesTest extends \PHPUnit\Framework\TestCase
+class CatalogEavValidationRulesTest extends TestCase
{
/**
* @var ObjectManagerHelper
@@ -24,7 +28,7 @@ class CatalogEavValidationRulesTest extends \PHPUnit\Framework\TestCase
/**
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->catalogEavValidationRules = $this->objectManagerHelper->getObject(CatalogEavValidationRules::class);
@@ -40,8 +44,8 @@ protected function setUp()
*/
public function testBuild($frontendInput, $frontendClass, array $eavConfig, array $expectedResult)
{
- /** @var \Magento\Catalog\Api\Data\ProductAttributeInterface|MockObject $attribute */
- $attribute = $this->createMock(\Magento\Catalog\Api\Data\ProductAttributeInterface::class);
+ /** @var ProductAttributeInterface|MockObject $attribute */
+ $attribute = $this->createMock(ProductAttributeInterface::class);
$attribute->expects($this->once())
->method('getFrontendInput')
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php
index 473f1aea33618..56a057f02ef90 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php
@@ -3,20 +3,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Locator\LocatorInterface;
+use Magento\Framework\Stdlib\ArrayManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Ui\DataProvider\Modifier\ModifierInterface;
-use Magento\Framework\Stdlib\ArrayManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class AbstractDataProviderTest
* @SuppressWarnings(PHPMD.NumberOfChildren)
*/
-abstract class AbstractModifierTest extends \PHPUnit\Framework\TestCase
+abstract class AbstractModifierTest extends TestCase
{
/**
* @var ModifierInterface
@@ -29,26 +32,26 @@ abstract class AbstractModifierTest extends \PHPUnit\Framework\TestCase
protected $objectManager;
/**
- * @var LocatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var LocatorInterface|MockObject
*/
protected $locatorMock;
/**
- * @var ProductInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductInterface|MockObject
*/
protected $productMock;
/**
- * @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreInterface|MockObject
*/
protected $storeMock;
/**
- * @var ArrayManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var ArrayManager|MockObject
*/
protected $arrayManagerMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
$this->locatorMock = $this->getMockBuilder(LocatorInterface::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedPricingTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedPricingTest.php
index e455ad47ee626..177f17abad67e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedPricingTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedPricingTest.php
@@ -3,73 +3,74 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing;
-use Magento\Store\Model\StoreManagerInterface;
use Magento\Customer\Api\Data\GroupInterface as CustomerGroupInterface;
use Magento\Customer\Api\GroupManagementInterface;
use Magento\Customer\Api\GroupRepositoryInterface;
+use Magento\Directory\Helper\Data as DirectoryHelper;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Module\Manager as ModuleManager;
-use Magento\Directory\Helper\Data as DirectoryHelper;
-use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
-use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
/**
- * Class AdvancedPricingTest
- *
* @method AdvancedPricing getModel
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AdvancedPricingTest extends AbstractModifierTest
{
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManagerMock;
/**
- * @var GroupRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupRepositoryInterface|MockObject
*/
protected $groupRepositoryMock;
/**
- * @var GroupManagementInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupManagementInterface|MockObject
*/
protected $groupManagementMock;
/**
- * @var SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var SearchCriteriaBuilder|MockObject
*/
protected $searchCriteriaBuilderMock;
/**
- * @var ModuleManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var ModuleManager|MockObject
*/
protected $moduleManagerMock;
/**
- * @var DirectoryHelper|\PHPUnit_Framework_MockObject_MockObject
+ * @var DirectoryHelper|MockObject
*/
protected $directoryHelperMock;
/**
- * @var ProductResource|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductResource|MockObject
*/
protected $productResourceMock;
/**
- * @var Attribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var Attribute|MockObject
*/
protected $attributeMock;
/**
- * @var CustomerGroupInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var CustomerGroupInterface|MockObject
*/
protected $customerGroupMock;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AttributeSetTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AttributeSetTest.php
index e36021fc7ebf6..093307a57df5b 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AttributeSetTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AttributeSetTest.php
@@ -3,44 +3,45 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
+use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AttributeSet;
-use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection;
+use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory;
use Magento\Framework\UrlInterface;
-use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
+use PHPUnit\Framework\MockObject\MockObject;
/**
- * Class AttributeSetTest
- *
* @method \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AttributeSet getModel
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AttributeSetTest extends AbstractModifierTest
{
/**
- * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
protected $attributeSetCollectionFactoryMock;
/**
- * @var Collection|\PHPUnit_Framework_MockObject_MockObject
+ * @var Collection|MockObject
*/
protected $attributeSetCollectionMock;
/**
- * @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlInterface|MockObject
*/
protected $urlBuilderMock;
/**
- * @var ProductResource|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductResource|MockObject
*/
protected $productResourceMock;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->attributeSetCollectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AttributesTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AttributesTest.php
index 613f7db243d3d..829676bbb6df1 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AttributesTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AttributesTest.php
@@ -3,34 +3,34 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Attributes;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Registry;
use Magento\Framework\UrlInterface;
+use PHPUnit\Framework\MockObject\MockObject;
-/**
- * Class AttributesTest
- */
class AttributesTest extends AbstractModifierTest
{
/**
- * @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlInterface|MockObject
*/
protected $urlBuilderMock;
/**
- * @var Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registryMock;
/**
- * @var AuthorizationInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AuthorizationInterface|MockObject
*/
protected $authorizationMock;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CategoriesTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CategoriesTest.php
index bceafee0f82a4..824c9e066fba1 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CategoriesTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CategoriesTest.php
@@ -7,52 +7,51 @@
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
-use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Categories;
-use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
+use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
+use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Categories;
+use Magento\Framework\AuthorizationInterface;
use Magento\Framework\DB\Helper as DbHelper;
use Magento\Framework\UrlInterface;
use Magento\Store\Model\Store;
-use Magento\Framework\AuthorizationInterface;
+use PHPUnit\Framework\MockObject\MockObject;
/**
- * Class CategoriesTest
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CategoriesTest extends AbstractModifierTest
{
/**
- * @var CategoryCollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryCollectionFactory|MockObject
*/
protected $categoryCollectionFactoryMock;
/**
- * @var DbHelper|\PHPUnit_Framework_MockObject_MockObject
+ * @var DbHelper|MockObject
*/
protected $dbHelperMock;
/**
- * @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlInterface|MockObject
*/
protected $urlBuilderMock;
/**
- * @var Store|\PHPUnit_Framework_MockObject_MockObject
+ * @var Store|MockObject
*/
protected $storeMock;
/**
- * @var CategoryCollection|\PHPUnit_Framework_MockObject_MockObject
+ * @var CategoryCollection|MockObject
*/
protected $categoryCollectionMock;
/**
- * @var AuthorizationInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AuthorizationInterface|MockObject
*/
private $authorizationMock;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->categoryCollectionFactoryMock = $this->getMockBuilder(CategoryCollectionFactory::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php
index dd9819cdbc5ab..c1ed6b597caa9 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php
@@ -3,47 +3,47 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
-use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions;
-use Magento\Catalog\Model\ProductOptions\ConfigInterface;
use Magento\Catalog\Model\Config\Source\Product\Options\Price as ProductOptionsPrice;
-use Magento\Store\Model\StoreManagerInterface;
-use Magento\Store\Api\Data\StoreInterface;
-use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Catalog\Model\Product\Option as ProductOption;
+use Magento\Catalog\Model\ProductOptions\ConfigInterface;
+use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions;
+use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
-/**
- * Class CustomOptionsTest
- */
class CustomOptionsTest extends AbstractModifierTest
{
/**
- * @var ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ConfigInterface|MockObject
*/
protected $productOptionsConfigMock;
/**
- * @var ProductOptionsPrice|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductOptionsPrice|MockObject
*/
protected $productOptionsPriceMock;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManagerMock;
/**
- * @var \Magento\Store\Api\Data\StoreInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreInterface|MockObject
*/
protected $storeMock;
/**
- * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PriceCurrencyInterface|MockObject
*/
protected $priceCurrency;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->productOptionsConfigMock = $this->getMockBuilder(ConfigInterface::class)
@@ -192,11 +192,11 @@ public function testFileExtensionRequired()
*
* @param array $data
* @param array $values
- * @return \Magento\Catalog\Model\Product\Option|\PHPUnit_Framework_MockObject_MockObject
+ * @return \Magento\Catalog\Model\Product\Option|MockObject
*/
protected function getProductOptionMock(array $data, array $values = [])
{
- /** @var ProductOption|\PHPUnit_Framework_MockObject_MockObject $productOptionMock */
+ /** @var ProductOption|MockObject $productOptionMock */
$productOptionMock = $this->getMockBuilder(ProductOption::class)
->disableOriginalConstructor()
->setMethods(['getValues'])
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php
index 917ef2bd522f8..1aa8d7526a30e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php
@@ -3,46 +3,47 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
+use Magento\Catalog\Api\ProductAttributeGroupRepositoryInterface;
+use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute as EavAttribute;
+use Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory as EavAttributeFactory;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav;
+use Magento\Eav\Api\Data\AttributeGroupInterface;
use Magento\Eav\Model\Config;
-use Magento\Eav\Model\Entity\Attribute\Source\SourceInterface;
-use Magento\Framework\App\RequestInterface;
-use Magento\Framework\Phrase;
-use Magento\Store\Model\StoreManagerInterface;
-use Magento\Store\Api\Data\StoreInterface;
-use Magento\Ui\DataProvider\EavValidationRules;
-use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection as GroupCollection;
-use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory as GroupCollectionFactory;
use Magento\Eav\Model\Entity\Attribute\Group;
-use Magento\Catalog\Model\ResourceModel\Eav\Attribute as EavAttribute;
+use Magento\Eav\Model\Entity\Attribute\Source\SourceInterface;
use Magento\Eav\Model\Entity\Type as EntityType;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection as AttributeCollection;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory as AttributeCollectionFactory;
-use Magento\Ui\DataProvider\Mapper\FormElement as FormElementMapper;
-use Magento\Ui\DataProvider\Mapper\MetaProperties as MetaPropertiesMapper;
-use Magento\Framework\Api\SearchCriteriaBuilder;
-use Magento\Catalog\Api\ProductAttributeGroupRepositoryInterface;
+use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection as GroupCollection;
+use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory as GroupCollectionFactory;
+use Magento\Framework\Api\AbstractSimpleObject;
+use Magento\Framework\Api\AttributeInterface;
use Magento\Framework\Api\SearchCriteria;
-use Magento\Framework\Api\SortOrderBuilder;
-use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
+use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SearchResultsInterface;
-use Magento\Catalog\Api\Data\ProductAttributeInterface;
-use Magento\Framework\Api\AttributeInterface;
-use Magento\Eav\Api\Data\AttributeGroupInterface;
-use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Framework\Api\SortOrderBuilder;
+use Magento\Framework\App\RequestInterface;
use Magento\Framework\Currency;
+use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Locale\Currency as CurrencyLocale;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\Phrase;
use Magento\Framework\Stdlib\ArrayManager;
-use Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory as EavAttributeFactory;
-use Magento\Framework\Event\ManagerInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Ui\DataProvider\EavValidationRules;
+use Magento\Ui\DataProvider\Mapper\FormElement as FormElementMapper;
+use Magento\Ui\DataProvider\Mapper\MetaProperties as MetaPropertiesMapper;
use PHPUnit\Framework\MockObject\MockObject;
/**
- * Class to test Data provider for eav attributes on product page
- *
* @method Eav getModel
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -202,7 +203,7 @@ class EavTest extends AbstractModifierTest
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->objectManager = new ObjectManager($this);
@@ -325,7 +326,7 @@ protected function setUp()
->willReturn($this->attributeCollectionMock);
$this->productMock->expects($this->any())
->method('getAttributes')
- ->willReturn([$this->attributeMock,]);
+ ->willReturn([$this->attributeMock]);
$this->storeMock = $this->getMockBuilder(StoreInterface::class)
->setMethods(['load', 'getId', 'getConfig', 'getBaseCurrencyCode'])
->getMockForAbstractClass();
@@ -415,7 +416,7 @@ public function testModifyData()
->willReturnSelf();
$this->sortOrderBuilderMock->expects($this->once())->method('setAscendingDirection')
->willReturnSelf();
- $dataObjectMock = $this->createMock(\Magento\Framework\Api\AbstractSimpleObject::class);
+ $dataObjectMock = $this->createMock(AbstractSimpleObject::class);
$this->sortOrderBuilderMock->expects($this->once())->method('create')
->willReturn($dataObjectMock);
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/FactoryTest.php
index 64a6a8b73b6b4..e7ffcf6861473 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/FactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/FactoryTest.php
@@ -3,17 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
-use Magento\Ui\DataProvider\Modifier\ModifierFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Ui\DataProvider\Modifier\ModifierFactory;
use Magento\Ui\DataProvider\Modifier\ModifierInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class FactoryTest
- */
-class FactoryTest extends \PHPUnit\Framework\TestCase
+class FactoryTest extends TestCase
{
/**
* @var ModifierFactory
@@ -26,16 +27,16 @@ class FactoryTest extends \PHPUnit\Framework\TestCase
protected $objectManager;
/**
- * @var ObjectManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var ObjectManager|MockObject
*/
protected $objectManagerMock;
/**
- * @var ModifierInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ModifierInterface|MockObject
*/
protected $dataProviderMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManagerHelper($this);
$this->dataProviderMock = $this->getMockBuilder(ModifierInterface::class)
@@ -45,7 +46,7 @@ protected function setUp()
->getMock();
$this->model = $this->objectManager->getObject(
- \Magento\Ui\DataProvider\Modifier\ModifierFactory::class,
+ ModifierFactory::class,
['objectManager' => $this->objectManagerMock]
);
}
@@ -59,11 +60,9 @@ public function testCreate()
$this->assertInstanceOf(ModifierInterface::class, $this->model->create(ModifierInterface::class));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testCreateWithException()
{
+ $this->expectException('InvalidArgumentException');
$this->objectManagerMock->expects($this->once())
->method('create')
->willReturn(null);
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php
index 9d0e7fc57ffce..81218a14332e5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php
@@ -3,23 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\General;
use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\Eav\Api\Data\AttributeInterface;
+use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Stdlib\ArrayManager;
+use PHPUnit\Framework\MockObject\MockObject;
/**
- * Class GeneralTest
- *
* @method General getModel
*/
class GeneralTest extends AbstractModifierTest
{
/**
- * @var AttributeRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeRepositoryInterface|MockObject
*/
private $attributeRepositoryMock;
@@ -28,7 +30,7 @@ class GeneralTest extends AbstractModifierTest
*/
private $generalModifier;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -87,7 +89,7 @@ public function testModifyMeta()
* @param array $data
* @param int $defaultStatusValue
* @param array $expectedResult
- * @throws \Magento\Framework\Exception\NoSuchEntityException
+ * @throws NoSuchEntityException
* @dataProvider modifyDataDataProvider
*/
public function testModifyDataNewProduct(array $data, int $defaultStatusValue, array $expectedResult)
@@ -115,7 +117,7 @@ public function testModifyDataNewProduct(array $data, int $defaultStatusValue, a
* @param int $defaultStatus
* @param int $statusAttributeValue
* @param array $expectedResult
- * @throws \Magento\Framework\Exception\NoSuchEntityException
+ * @throws NoSuchEntityException
* @dataProvider modifyDataOfExistingProductDataProvider
*/
public function testModifyDataOfExistingProduct(
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ImagesTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ImagesTest.php
index 16bff55900c95..a23800f83db29 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ImagesTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ImagesTest.php
@@ -3,9 +3,11 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
-use Magento\Catalog\Model\Product\Type;
+use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images;
/**
* @method \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images getModel
@@ -17,7 +19,7 @@ class ImagesTest extends AbstractModifierTest
*/
protected function createModel()
{
- return $this->objectManager->getObject(\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::class, [
+ return $this->objectManager->getObject(Images::class, [
'locator' => $this->locatorMock,
]);
}
@@ -32,7 +34,7 @@ public function testModifyData()
public function testModifyMeta()
{
$meta = [
- \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::CODE_IMAGE_MANAGEMENT_GROUP => [
+ Images::CODE_IMAGE_MANAGEMENT_GROUP => [
'children' => [],
'label' => __('Images'),
'sortOrder' => '20',
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/RelatedTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/RelatedTest.php
index 438c6ee13af57..6bdd9010d0a3a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/RelatedTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/RelatedTest.php
@@ -3,21 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Related;
-/**
- * Class RelatedTest
- */
class RelatedTest extends AbstractModifierTest
{
/**
- * @return \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Related
+ * @return Related
*/
protected function createModel()
{
- return $this->objectManager->getObject(\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Related::class, [
+ return $this->objectManager->getObject(Related::class, [
'locator' => $this->locatorMock,
]);
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ScheduleDesignUpdateTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ScheduleDesignUpdateTest.php
index 783c6247b9df3..089785715e2a9 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ScheduleDesignUpdateTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ScheduleDesignUpdateTest.php
@@ -3,13 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\ScheduleDesignUpdate;
-/**
- * Class ScheduleDesignUpdateTest
- */
class ScheduleDesignUpdateTest extends AbstractModifierTest
{
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/SystemTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/SystemTest.php
index 7658916aac3fd..60ee348c6e0ac 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/SystemTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/SystemTest.php
@@ -3,25 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
use Magento\Catalog\Model\Product\Type;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\System;
use Magento\Framework\UrlInterface;
+use PHPUnit\Framework\MockObject\MockObject;
/**
- * Class SystemTest
- *
* @method System getModel
*/
class SystemTest extends AbstractModifierTest
{
/**
- * @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlInterface|MockObject
*/
protected $urlBuilderMock;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/TierPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/TierPriceTest.php
index f12ba0e88fc7a..02f39e71dba56 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/TierPriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/TierPriceTest.php
@@ -3,26 +3,27 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Catalog\Model\Config\Source\ProductPriceOptionsInterface;
+use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\TierPrice;
use Magento\Framework\Stdlib\ArrayManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\TierPrice;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class TierPriceTest.
- */
-class TierPriceTest extends \PHPUnit\Framework\TestCase
+class TierPriceTest extends TestCase
{
/**
- * @var ProductPriceOptionsInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductPriceOptionsInterface|MockObject
*/
private $productPriceOptions;
/**
- * @var ArrayManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var ArrayManager|MockObject
*/
private $arrayManager;
@@ -35,7 +36,7 @@ class TierPriceTest extends \PHPUnit\Framework\TestCase
* Set Up.
* @return void
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->productPriceOptions = $this->createMock(ProductPriceOptionsInterface::class);
$this->arrayManager = $this->createMock(ArrayManager::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WebsitesTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WebsitesTest.php
index 2f8545c56e71e..a01bc59dc65dd 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WebsitesTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WebsitesTest.php
@@ -3,20 +3,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
+use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Websites;
use Magento\Store\Api\GroupRepositoryInterface;
use Magento\Store\Api\StoreRepositoryInterface;
use Magento\Store\Api\WebsiteRepositoryInterface;
use Magento\Store\Model\Group;
+use Magento\Store\Model\ResourceModel\Group\Collection;
use Magento\Store\Model\Store as StoreView;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Store\Model\Website;
+use PHPUnit\Framework\MockObject\MockObject;
/**
- * Class WebsitesTest test the meta data and website data for different websites
- *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class WebsitesTest extends AbstractModifierTest
@@ -29,32 +32,32 @@ class WebsitesTest extends AbstractModifierTest
const SECOND_WEBSITE_ID = 2;
/**
- * @var WebsiteRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var WebsiteRepositoryInterface|MockObject
*/
protected $websiteRepositoryMock;
/**
- * @var GroupRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupRepositoryInterface|MockObject
*/
protected $groupRepositoryMock;
/**
- * @var StoreRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreRepositoryInterface|MockObject
*/
protected $storeRepositoryMock;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
protected $storeManagerMock;
/**
- * @var Website|\PHPUnit_Framework_MockObject_MockObject
+ * @var Website|MockObject
*/
protected $websiteMock;
/**
- * @var Website|\PHPUnit_Framework_MockObject_MockObject
+ * @var Website|MockObject
*/
protected $secondWebsiteMock;
@@ -64,52 +67,52 @@ class WebsitesTest extends AbstractModifierTest
protected $assignedWebsites;
/**
- * @var Group|\PHPUnit_Framework_MockObject_MockObject
+ * @var Group|MockObject
*/
protected $groupMock;
/**
- * @var StoreView|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreView|MockObject
*/
protected $storeViewMock;
/**
* @inheritdoc
*/
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->productMock->expects($this->any())
->method('getId')
->willReturn(self::PRODUCT_ID);
$this->assignedWebsites = [self::SECOND_WEBSITE_ID];
- $this->websiteMock = $this->getMockBuilder(\Magento\Store\Model\Website::class)
+ $this->websiteMock = $this->getMockBuilder(Website::class)
->setMethods(['getId', 'getName'])
->disableOriginalConstructor()
->getMock();
- $this->secondWebsiteMock = $this->getMockBuilder(\Magento\Store\Model\Website::class)
+ $this->secondWebsiteMock = $this->getMockBuilder(Website::class)
->setMethods(['getId', 'getName'])
->disableOriginalConstructor()
->getMock();
- $this->websiteRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\WebsiteRepositoryInterface::class)
+ $this->websiteRepositoryMock = $this->getMockBuilder(WebsiteRepositoryInterface::class)
->setMethods(['getList'])
->getMockForAbstractClass();
$this->websiteRepositoryMock->expects($this->any())
->method('getDefault')
->willReturn($this->websiteMock);
- $this->groupRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\GroupRepositoryInterface::class)
+ $this->groupRepositoryMock = $this->getMockBuilder(GroupRepositoryInterface::class)
->setMethods(['getList'])
->getMockForAbstractClass();
- $this->storeRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\StoreRepositoryInterface::class)
+ $this->storeRepositoryMock = $this->getMockBuilder(StoreRepositoryInterface::class)
->setMethods(['getList'])
->getMockForAbstractClass();
- $this->productMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)
+ $this->productMock = $this->getMockBuilder(ProductInterface::class)
->setMethods(['getId'])
->getMockForAbstractClass();
$this->locatorMock->expects($this->any())
->method('getWebsiteIds')
->willReturn($this->assignedWebsites);
- $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
->setMethods(['isSingleStoreMode', 'getWebsites'])
->getMockForAbstractClass();
$this->storeManagerMock->method('getWebsites')
@@ -117,7 +120,7 @@ protected function setUp()
$this->storeManagerMock->expects($this->any())
->method('isSingleStoreMode')
->willReturn(false);
- $this->groupMock = $this->getMockBuilder(\Magento\Store\Model\ResourceModel\Group\Collection::class)
+ $this->groupMock = $this->getMockBuilder(Collection::class)
->setMethods(['getId', 'getName', 'getWebsiteId'])
->disableOriginalConstructor()
->getMock();
@@ -155,7 +158,7 @@ protected function setUp()
}
/**
- * @return \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Websites
+ * @return Websites
*/
protected function createModel()
{
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/NewCategoryDataProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/NewCategoryDataProviderTest.php
index 2f5525978b3a5..cc6861df85091 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/NewCategoryDataProviderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/NewCategoryDataProviderTest.php
@@ -3,13 +3,16 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
use Magento\Catalog\Ui\DataProvider\Product\Form\NewCategoryDataProvider;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use PHPUnit\Framework\TestCase;
-class NewCategoryDataProviderTest extends \PHPUnit\Framework\TestCase
+class NewCategoryDataProviderTest extends TestCase
{
/**
* @var NewCategoryDataProvider
@@ -26,7 +29,7 @@ class NewCategoryDataProviderTest extends \PHPUnit\Framework\TestCase
*/
protected $collectionFactoryMock;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->collectionFactoryMock = $this->createPartialMock(CollectionFactory::class, ['create']);
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/ProductDataProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/ProductDataProviderTest.php
index 0360901095402..3abd6c9f2e970 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/ProductDataProviderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/ProductDataProviderTest.php
@@ -3,19 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Catalog\Ui\DataProvider\Product\Form\ProductDataProvider;
-use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
use Magento\Catalog\Model\ResourceModel\Product\Collection;
-use Magento\Ui\DataProvider\Modifier\Pool;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use Magento\Catalog\Ui\DataProvider\Product\Form\ProductDataProvider;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Ui\DataProvider\Modifier\ModifierInterface;
+use Magento\Ui\DataProvider\Modifier\Pool;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-/**
- * Class ProductDataProviderTest
- */
-class ProductDataProviderTest extends \PHPUnit\Framework\TestCase
+class ProductDataProviderTest extends TestCase
{
/**
* @var ObjectManager
@@ -23,22 +24,22 @@ class ProductDataProviderTest extends \PHPUnit\Framework\TestCase
protected $objectManager;
/**
- * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
protected $collectionFactoryMock;
/**
- * @var Collection|\PHPUnit_Framework_MockObject_MockObject
+ * @var Collection|MockObject
*/
protected $collectionMock;
/**
- * @var ModifierInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ModifierInterface|MockObject
*/
protected $modifierMockOne;
/**
- * @var Pool|\PHPUnit_Framework_MockObject_MockObject
+ * @var Pool|MockObject
*/
protected $poolMock;
@@ -47,7 +48,7 @@ class ProductDataProviderTest extends \PHPUnit\Framework\TestCase
*/
protected $model;
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
$this->collectionMock = $this->getMockBuilder(Collection::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/AdditionalInfoTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/AdditionalInfoTest.php
index 80147a37f985d..2c7101db1e604 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/AdditionalInfoTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/AdditionalInfoTest.php
@@ -3,19 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Listing\Collector;
use Magento\Catalog\Api\Data\ProductRenderInterface;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\AdditionalInfo;
+use PHPUnit\Framework\TestCase;
-class AdditionalInfoTest extends \PHPUnit\Framework\TestCase
+class AdditionalInfoTest extends TestCase
{
/** @var AdditionalInfo */
private $model;
- public function setUp()
+ public function setUp(): void
{
$this->model = new AdditionalInfo();
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/ImageTest.php
index 009cd690d4cd4..283827513b97d 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/ImageTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/ImageTest.php
@@ -3,38 +3,43 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Listing\Collector;
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Api\Data\ProductRender\ImageInterface;
+use Magento\Catalog\Api\Data\ProductRender\ImageInterfaceFactory;
use Magento\Catalog\Api\Data\ProductRenderInterface;
+use Magento\Catalog\Helper\Image as ImageHelper;
+use Magento\Catalog\Helper\ImageFactory;
use Magento\Catalog\Model\Product;
-use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\Image;
+use Magento\Framework\App\State;
use Magento\Framework\View\DesignInterface;
-use Magento\Store\Model\StoreManagerInterface;
-use Magento\Catalog\Helper\ImageFactory;
-use Magento\Catalog\Api\Data\ProductRender\ImageInterface;
-use Magento\Catalog\Helper\Image as ImageHelper;
use Magento\Framework\View\DesignLoader;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ImageTest extends \PHPUnit\Framework\TestCase
+class ImageTest extends TestCase
{
- /** @var ImageFactory | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var ImageFactory|MockObject */
private $imageFactory;
- /** @var \Magento\Framework\App\State | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var State|MockObject */
private $state;
- /** @var StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var StoreManagerInterface|MockObject */
private $storeManager;
- /** @var DesignInterface | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var DesignInterface|MockObject */
private $design;
- /** @var DesignLoader | \PHPUnit_Framework_MockObject_MockObject*/
+ /** @var DesignLoader|MockObject*/
private $designLoader;
/** @var Image */
@@ -43,23 +48,23 @@ class ImageTest extends \PHPUnit\Framework\TestCase
/** @var array */
private $imageCodes = ['widget_recently_viewed'];
- /** @var \Magento\Catalog\Api\Data\ProductRender\ImageInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ImageInterfaceFactory|MockObject */
private $imageInterfaceFactory;
- public function setUp()
+ public function setUp(): void
{
$this->imageFactory = $this->getMockBuilder(ImageFactory::class)
->disableOriginalConstructor()
->getMock();
$this->imageInterfaceFactory = $this->getMockBuilder(
- \Magento\Catalog\Api\Data\ProductRender\ImageInterfaceFactory::class
+ ImageInterfaceFactory::class
)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
- $this->state = $this->getMockBuilder(\Magento\Framework\App\State::class)
+ $this->state = $this->getMockBuilder(State::class)
->disableOriginalConstructor()
->getMock();
$this->storeManager = $this->createMock(StoreManagerInterface::class);
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/PriceTest.php
index 218c90bc3a691..76065a59a7f61 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/PriceTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/PriceTest.php
@@ -3,51 +3,59 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Listing\Collector;
+use Magento\Catalog\Api\Data\ProductRender\PriceInfoInterface;
+use Magento\Catalog\Api\Data\ProductRender\PriceInfoInterfaceFactory;
use Magento\Catalog\Api\Data\ProductRenderInterface;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Pricing\Price\FinalPrice;
+use Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\Price;
use Magento\Framework\Pricing\Amount\AmountInterface;
-use Magento\Catalog\Api\Data\ProductRender\PriceInfoInterface;
-use Magento\Catalog\Api\Data\ProductRender\PriceInfoInterfaceFactory;
+use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\Pricing\PriceInfo\Base;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class PriceTest extends \PHPUnit\Framework\TestCase
+class PriceTest extends TestCase
{
- /** @var \Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\Price */
+ /** @var Price */
protected $model;
/** @var ObjectManagerHelper */
protected $objectManagerHelper;
- /** @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var PriceCurrencyInterface|MockObject */
protected $priceCurrencyMock;
- /** @var PriceInfoInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var PriceInfoInterfaceFactory|MockObject */
private $priceInfoFactory;
- /** @var PriceInfoInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var PriceInfoInterface|MockObject */
private $priceMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->priceCurrencyMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class)
+ $this->priceCurrencyMock = $this->getMockBuilder(PriceCurrencyInterface::class)
->getMockForAbstractClass();
$this->priceInfoFactory = $this->getMockBuilder(
- \Magento\Catalog\Api\Data\ProductRender\PriceInfoInterfaceFactory::class
+ PriceInfoInterfaceFactory::class
)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
$this->priceMock = $this->getMockBuilder(
- \Magento\Catalog\Api\Data\ProductRender\PriceInfoInterface::class
+ PriceInfoInterface::class
)
->disableOriginalConstructor()
->getMock();
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\Price::class,
+ Price::class,
[
'priceCurrency' => $this->priceCurrencyMock,
'priceInfoFactory' => $this->priceInfoFactory,
@@ -64,7 +72,7 @@ public function testGet()
$productRenderInfoDto->expects($this->exactly(2))
->method('getPriceInfo')
->willReturn([]);
- $priceInfo = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class)
+ $priceInfo = $this->getMockBuilder(Base::class)
->disableOriginalConstructor()
->getMock();
$this->priceInfoFactory->expects($this->once())
@@ -82,7 +90,7 @@ public function testGet()
$this->priceMock->expects($this->once())
->method('setRegularPrice')
->with(10);
- $price = $this->getMockBuilder(\Magento\Catalog\Pricing\Price\FinalPrice::class)
+ $price = $this->getMockBuilder(FinalPrice::class)
->disableOriginalConstructor()
->getMock();
$priceInfo->expects($this->atLeastOnce())
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/UrlTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/UrlTest.php
index 7f0ee3856c275..7b395b293bbe5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/UrlTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/UrlTest.php
@@ -3,51 +3,60 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Listing\Collector;
+use Magento\Catalog\Api\Data\ProductRender\ButtonInterface;
+use Magento\Catalog\Api\Data\ProductRender\ButtonInterfaceFactory;
use Magento\Catalog\Api\Data\ProductRenderInterface;
+use Magento\Catalog\Block\Product\AbstractProduct;
+use Magento\Catalog\Helper\Product\Compare;
use Magento\Catalog\Model\Product;
-use Magento\Catalog\Api\Data\ProductRender\ButtonInterfaceFactory;
-use Magento\Catalog\Api\Data\ProductRender\ButtonInterface;
+use Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\Url;
+use Magento\Framework\App\ActionInterface;
+use Magento\Framework\Data\Helper\PostHelper;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class UrlTest extends \PHPUnit\Framework\TestCase
+class UrlTest extends TestCase
{
- /** @var \Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\Url */
+ /** @var Url */
protected $model;
/** @var ObjectManagerHelper */
protected $objectManagerHelper;
- /** @var \Magento\Catalog\Block\Product\AbstractProduct|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var AbstractProduct|MockObject */
protected $abstractProductMock;
- /** @var \Magento\Catalog\Helper\Product\Compare|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Compare|MockObject */
protected $catalogProductHelperMock;
- /** @var \Magento\Framework\Data\Helper\PostHelper|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var PostHelper|MockObject */
protected $postHelperMock;
- /** @var ButtonInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ButtonInterfaceFactory|MockObject */
private $buttonFactoryMock;
- /** @var ButtonInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ButtonInterface|MockObject */
private $buttonMock;
- protected function setUp()
+ protected function setUp(): void
{
- $this->abstractProductMock = $this->getMockBuilder(\Magento\Catalog\Block\Product\AbstractProduct::class)
+ $this->abstractProductMock = $this->getMockBuilder(AbstractProduct::class)
->disableOriginalConstructor()
->getMock();
- $this->catalogProductHelperMock = $this->getMockBuilder(\Magento\Catalog\Helper\Product\Compare::class)
+ $this->catalogProductHelperMock = $this->getMockBuilder(Compare::class)
->disableOriginalConstructor()
->getMock();
- $this->postHelperMock = $this->getMockBuilder(\Magento\Framework\Data\Helper\PostHelper::class)
+ $this->postHelperMock = $this->getMockBuilder(PostHelper::class)
->disableOriginalConstructor()
->getMock();
$this->buttonFactoryMock = $this->getMockBuilder(
- \Magento\Catalog\Api\Data\ProductRender\ButtonInterfaceFactory::class
+ ButtonInterfaceFactory::class
)
->setMethods(['create'])
->disableOriginalConstructor()
@@ -59,7 +68,7 @@ protected function setUp()
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $this->objectManagerHelper->getObject(
- \Magento\Catalog\Ui\DataProvider\Product\Listing\Collector\Url::class,
+ Url::class,
[
'abstractProduct' => $this->abstractProductMock,
'compare' => $this->catalogProductHelperMock,
@@ -99,7 +108,7 @@ public function testGet()
'some:url',
[
'product' => 1,
- \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => "%uenc%"
+ ActionInterface::PARAM_NAME_URL_ENCODED => "%uenc%"
]
)
->willReturn(['some cart url post data']);
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/ProductCustomOptionsDataProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/ProductCustomOptionsDataProviderTest.php
index 143ef4461173a..33c68b83a91d9 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/ProductCustomOptionsDataProviderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/ProductCustomOptionsDataProviderTest.php
@@ -3,19 +3,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use Magento\Catalog\Ui\DataProvider\Product\ProductCustomOptionsDataProvider;
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use Magento\Catalog\Ui\DataProvider\Product\ProductCustomOptionsDataProvider;
use Magento\Framework\App\RequestInterface;
-use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
use Magento\Framework\DB\Select as DbSelect;
-use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\EntityManager\EntityMetadataInterface;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Ui\DataProvider\Modifier\PoolInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class ProductCustomOptionsDataProviderTest extends \PHPUnit\Framework\TestCase
+class ProductCustomOptionsDataProviderTest extends TestCase
{
/**
* @var ObjectManagerHelper
@@ -28,41 +32,41 @@ class ProductCustomOptionsDataProviderTest extends \PHPUnit\Framework\TestCase
protected $dataProvider;
/**
- * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
protected $collectionFactoryMock;
/**
- * @var RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $requestMock;
/**
- * @var AbstractCollection|\PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractCollection|MockObject
*/
protected $collectionMock;
/**
- * @var DbSelect|\PHPUnit_Framework_MockObject_MockObject
+ * @var DbSelect|MockObject
*/
protected $dbSelectMock;
/**
- * @var MetadataPool|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetadataPool|MockObject
*/
private $metadataPool;
/**
- * @var EntityMetadataInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var EntityMetadataInterface|MockObject
*/
private $entityMetadata;
/**
- * @var PoolInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var PoolInterface|MockObject
*/
private $modifiersPool;
- protected function setUp()
+ protected function setUp(): void
{
$this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/AbstractDataProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/AbstractDataProviderTest.php
index c73f9cb481f48..d367a9ac20391 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/AbstractDataProviderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/AbstractDataProviderTest.php
@@ -3,22 +3,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Related;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductLinkRepositoryInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\ResourceModel\Product\Collection;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
use Magento\Catalog\Ui\DataProvider\Product\Related\AbstractDataProvider;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Catalog\Model\ResourceModel\Product\Collection;
-use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class AbstractDataProviderTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-abstract class AbstractDataProviderTest extends \PHPUnit\Framework\TestCase
+abstract class AbstractDataProviderTest extends TestCase
{
/**
* @var ObjectManager
@@ -26,32 +29,32 @@ abstract class AbstractDataProviderTest extends \PHPUnit\Framework\TestCase
protected $objectManager;
/**
- * @var RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
protected $requestMock;
/**
- * @var ProductRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductRepositoryInterface|MockObject
*/
protected $productRepositoryMock;
/**
- * @var ProductLinkRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductLinkRepositoryInterface|MockObject
*/
protected $productLinkRepositoryMock;
/**
- * @var ProductInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductInterface|MockObject
*/
protected $productMock;
/**
- * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
protected $collectionFactoryMock;
/**
- * @var Collection|\PHPUnit_Framework_MockObject_MockObject
+ * @var Collection|MockObject
*/
protected $collectionMock;
@@ -60,7 +63,7 @@ abstract class AbstractDataProviderTest extends \PHPUnit\Framework\TestCase
*/
abstract protected function getModel();
- protected function setUp()
+ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
$this->requestMock = $this->getMockBuilder(RequestInterface::class)
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/CrossSellDataProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/CrossSellDataProviderTest.php
index 1a4feba224a93..5c207a7f7c90c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/CrossSellDataProviderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/CrossSellDataProviderTest.php
@@ -3,13 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Related;
use Magento\Catalog\Ui\DataProvider\Product\Related\CrossSellDataProvider;
-/**
- * Class CrossSellDataProviderTest
- */
class CrossSellDataProviderTest extends AbstractDataProviderTest
{
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/RelatedDataProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/RelatedDataProviderTest.php
index 7dcaf80426071..441cd84235bbd 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/RelatedDataProviderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/RelatedDataProviderTest.php
@@ -3,13 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Related;
use Magento\Catalog\Ui\DataProvider\Product\Related\RelatedDataProvider;
-/**
- * Class RelatedDataProviderTest
- */
class RelatedDataProviderTest extends AbstractDataProviderTest
{
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/UpSellDataProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/UpSellDataProviderTest.php
index a7507f2744078..6492c927969f5 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/UpSellDataProviderTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/UpSellDataProviderTest.php
@@ -3,13 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Related;
use Magento\Catalog\Ui\DataProvider\Product\Related\UpSellDataProvider;
-/**
- * Class UpSellDataProviderTest
- */
class UpSellDataProviderTest extends AbstractDataProviderTest
{
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/ViewModel/Product/BreadcrumbsTest.php b/app/code/Magento/Catalog/Test/Unit/ViewModel/Product/BreadcrumbsTest.php
index 91bb534fff627..380b27f184749 100644
--- a/app/code/Magento/Catalog/Test/Unit/ViewModel/Product/BreadcrumbsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/ViewModel/Product/BreadcrumbsTest.php
@@ -12,8 +12,8 @@
use Magento\Catalog\ViewModel\Product\Breadcrumbs;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Escaper;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\Serialize\Serializer\JsonHexTag;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Store\Model\ScopeInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
diff --git a/app/code/Magento/Catalog/Test/Unit/ViewModel/Product/Checker/AddToCompareAvailabilityTest.php b/app/code/Magento/Catalog/Test/Unit/ViewModel/Product/Checker/AddToCompareAvailabilityTest.php
index 55bfbe8b4ec71..6719004ac2d00 100644
--- a/app/code/Magento/Catalog/Test/Unit/ViewModel/Product/Checker/AddToCompareAvailabilityTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/ViewModel/Product/Checker/AddToCompareAvailabilityTest.php
@@ -8,17 +8,18 @@
namespace Magento\Catalog\Test\Unit\ViewModel\Product\Checker;
-use Magento\Catalog\ViewModel\Product\Checker\AddToCompareAvailability;
-use Magento\CatalogInventory\Api\StockConfigurationInterface;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Attribute\Source\Status;
+use Magento\Catalog\ViewModel\Product\Checker\AddToCompareAvailability;
+use Magento\CatalogInventory\Api\StockConfigurationInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* Unit test for Magento\Catalog\ViewModel\Product\Checker\AddToCompareAvailability.
*/
-class AddToCompareAvailabilityTest extends \PHPUnit\Framework\TestCase
+class AddToCompareAvailabilityTest extends TestCase
{
/**
@@ -36,7 +37,6 @@ class AddToCompareAvailabilityTest extends \PHPUnit\Framework\TestCase
*/
protected function setUp(): void
{
-
$objectManager = new ObjectManager($this);
$this->stockConfigurationMock =
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php
index a02ea21d51232..72e154a44b694 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php
@@ -1,138 +1,156 @@
-localeDate = $this->createMock(\Magento\Framework\Stdlib\DateTime\Timezone::class);
+ $this->localeDate = $this->createMock(Timezone::class);
- $this->config = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityType']);
- $type = $this->createMock(\Magento\Eav\Model\Entity\Type::class);
+ $this->config = $this->createPartialMock(Config::class, ['getEntityType']);
+ $type = $this->createMock(Type::class);
$this->config->expects($this->once())->method('getEntityType')->willReturn($type);
- $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
+ $this->resource = $this->createMock(ResourceConnection::class);
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class);
- $this->logger = $this->createMock(\Magento\Framework\Logger\Monolog::class);
+ $this->storeManager = $this->createMock(StoreManager::class);
+ $this->logger = $this->createMock(Monolog::class);
$this->collection = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class);
$this->abstractCollection = $this->getMockForAbstractClass(
- \Magento\Eav\Model\Entity\Collection\AbstractCollection::class,
+ AbstractCollection::class,
[],
'',
false,
@@ -177,15 +195,15 @@ protected function setUp()
$this->attributeColFactory = $this->createMock(
\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class
);
- $this->typeFactory = $this->createMock(\Magento\CatalogImportExport\Model\Export\Product\Type\Factory::class);
+ $this->typeFactory = $this->createMock(Factory::class);
- $this->linkTypeProvider = $this->createMock(\Magento\Catalog\Model\Product\LinkTypeProvider::class);
+ $this->linkTypeProvider = $this->createMock(LinkTypeProvider::class);
$this->rowCustomizer = $this->createMock(
- \Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite::class
+ Composite::class
);
- $this->metadataPool = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class);
+ $this->metadataPool = $this->createMock(MetadataPool::class);
- $this->writer = $this->createPartialMock(\Magento\ImportExport\Model\Export\Adapter\AbstractAdapter::class, [
+ $this->writer = $this->createPartialMock(AbstractAdapter::class, [
'setHeaderCols',
'writeRow',
'getContents',
@@ -213,7 +231,7 @@ protected function setUp()
'_getHeaderColumns',
]);
$this->product = $this->createPartialMock(
- \Magento\CatalogImportExport\Model\Export\Product::class,
+ Product::class,
$mockMethods
);
@@ -264,7 +282,7 @@ public function testUpdateDataWithCategoryColumnsNoCategoriesAssigned()
public function testGetHeaderColumns()
{
$product = $this->createPartialMock(
- \Magento\CatalogImportExport\Model\Export\Product::class,
+ Product::class,
['_customHeadersMapping']
);
$headerColumnsValue = ['headerColumns value'];
@@ -355,7 +373,7 @@ public function testExportCurPageEqualToLastBreakInternalCalls()
$this->product->export();
}
- protected function tearDown()
+ protected function tearDown(): void
{
unset($this->object);
}
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/StubProduct.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/StubProduct.php
index 8c19edbe57559..2f7aeea2a0173 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/StubProduct.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/StubProduct.php
@@ -1,11 +1,16 @@
-objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->objectManagerHelper = new ObjectManagerHelper($this);
- $this->childCategory = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $this->childCategory = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->getMock();
$this->childCategory->method('getId')->will($this->returnValue(self::CHILD_CATEGORY_ID));
@@ -59,7 +65,7 @@ protected function setUp()
. self::CHILD_CATEGORY_ID
));
- $this->parentCategory = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
+ $this->parentCategory = $this->getMockBuilder(Category::class)
->disableOriginalConstructor()
->getMock();
$this->parentCategory->method('getId')->will($this->returnValue(self::PARENT_CATEGORY_ID));
@@ -68,7 +74,7 @@ protected function setUp()
$categoryCollection =
$this->objectManagerHelper->getCollectionMock(
- \Magento\Catalog\Model\ResourceModel\Category\Collection::class,
+ Collection::class,
[
self::PARENT_CATEGORY_ID => $this->parentCategory,
self::CHILD_CATEGORY_ID => $this->childCategory,
@@ -102,7 +108,7 @@ protected function setUp()
$categoryFactory->method('create')->will($this->returnValue($this->childCategory));
$this->categoryProcessor =
- new \Magento\CatalogImportExport\Model\Import\Product\CategoryProcessor(
+ new CategoryProcessor(
$categoryColFactory,
$categoryFactory
);
@@ -120,7 +126,7 @@ public function testUpsertCategories()
*/
public function testUpsertCategoriesWithAlreadyExistsException()
{
- $exception = new \Magento\Framework\Exception\AlreadyExistsException();
+ $exception = new AlreadyExistsException();
$categoriesSeparator = '/';
$categoryName = 'Exception Category';
$this->childCategory->method('save')->willThrowException($exception);
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ImageTypeProcessorTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ImageTypeProcessorTest.php
index fccfedd74fad2..9a15f1bc2d633 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ImageTypeProcessorTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ImageTypeProcessorTest.php
@@ -1,4 +1,4 @@
-getMockBuilder(\Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModel::class)
+ $resource = $this->getMockBuilder(ResourceModel::class)
->disableOriginalConstructor()
->setMethods(['getTable', 'getConnection'])
->getMock();
@@ -24,7 +28,7 @@ public function testGetImageTypes()
->method('getTable')
->with('eav_attribute')
->willReturnArgument(0);
- $connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
+ $connection = $this->createMock(AdapterInterface::class);
$resource->expects($this->any())
->method('getConnection')
->willReturn($connection);
@@ -32,7 +36,7 @@ public function testGetImageTypes()
->method('create')
->willReturn($resource);
- $selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ $selectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
$selectMock->expects($this->once())
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/LinkProcessorTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/LinkProcessorTest.php
index 284ef0b783ec8..29471d87be7fc 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/LinkProcessorTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/LinkProcessorTest.php
@@ -1,4 +1,4 @@
-objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->objectManagerHelper = new ObjectManagerHelper($this);
- $this->resourceHelper = $this->createMock(\Magento\ImportExport\Model\ResourceModel\Helper::class);
+ $this->resourceHelper = $this->createMock(Helper::class);
- $this->resource = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Link::class);
+ $this->resource = $this->createMock(Link::class);
$this->resource->method('getMainTable')->willReturn('main_link_table');
$this->linkFactory = $this->createPartialMock(
@@ -73,21 +86,21 @@ protected function setUp()
$this->linkFactory->method('create')->willReturn($this->resource);
$this->skuProcessor = $this->createMock(
- \Magento\CatalogImportExport\Model\Import\Product\SkuProcessor::class
+ SkuProcessor::class
);
- $this->logger = $this->createMock(\Psr\Log\LoggerInterface::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
}
/**
* @dataProvider diConfigDataProvider
* @param $expectedCallCount
* @param $linkToNameId
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
public function testSaveLinks($expectedCallCount, $linkToNameId)
{
$this->linkProcessor =
- new \Magento\CatalogImportExport\Model\Import\Product\LinkProcessor(
+ new LinkProcessor(
$this->linkFactory,
$this->resourceHelper,
$this->skuProcessor,
@@ -95,17 +108,17 @@ public function testSaveLinks($expectedCallCount, $linkToNameId)
$linkToNameId
);
- $importEntity = $this->createMock(\Magento\CatalogImportExport\Model\Import\Product::class);
- $connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
+ $importEntity = $this->createMock(Product::class);
+ $connection = $this->createMock(AdapterInterface::class);
$importEntity->method('getConnection')->willReturn($connection);
- $select = $this->createMock(\Magento\Framework\DB\Select::class);
+ $select = $this->createMock(Select::class);
// expect one call per linkToNameId
$connection->expects($this->exactly($expectedCallCount))->method('select')->willReturn($select);
$select->method('from')->willReturn($select);
- $dataSourceModel = $this->createMock(\Magento\ImportExport\Model\ResourceModel\Import\Data::class);
+ $dataSourceModel = $this->createMock(Data::class);
$this->linkProcessor->saveLinks($importEntity, $dataSourceModel, '_related_');
}
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/SkuProcessorTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/SkuProcessorTest.php
index 24c5b05ab9312..07b5010833162 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/SkuProcessorTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/SkuProcessorTest.php
@@ -1,4 +1,4 @@
-productFactory = $this->createMock(\Magento\Catalog\Model\ProductFactory::class);
$this->skuProcessor = $this->getMockBuilder(
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/TaxClassProcessorTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/TaxClassProcessorTest.php
index 106942bf9b87f..504134ee6e85b 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/TaxClassProcessorTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/TaxClassProcessorTest.php
@@ -1,13 +1,19 @@
-objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->objectManagerHelper = new ObjectManagerHelper($this);
- $taxClass = $this->getMockBuilder(\Magento\Tax\Model\ClassModel::class)
+ $taxClass = $this->getMockBuilder(ClassModel::class)
->disableOriginalConstructor()
->getMock();
$taxClass->method('getClassName')->will($this->returnValue(self::TEST_TAX_CLASS_NAME));
@@ -46,7 +52,7 @@ protected function setUp()
$taxClassCollection =
$this->objectManagerHelper->getCollectionMock(
- \Magento\Tax\Model\ResourceModel\TaxClass\Collection::class,
+ Collection::class,
[$taxClass]
);
@@ -57,7 +63,7 @@ protected function setUp()
$taxClassCollectionFactory->method('create')->will($this->returnValue($taxClassCollection));
- $anotherTaxClass = $this->getMockBuilder(\Magento\Tax\Model\ClassModel::class)
+ $anotherTaxClass = $this->getMockBuilder(ClassModel::class)
->disableOriginalConstructor()
->getMock();
$anotherTaxClass->method('getClassName')->will($this->returnValue(self::TEST_TAX_CLASS_NAME));
@@ -68,14 +74,14 @@ protected function setUp()
$taxClassFactory->method('create')->will($this->returnValue($anotherTaxClass));
$this->taxClassProcessor =
- new \Magento\CatalogImportExport\Model\Import\Product\TaxClassProcessor(
+ new TaxClassProcessor(
$taxClassCollectionFactory,
$taxClassFactory
);
$this->product =
$this->getMockForAbstractClass(
- \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType::class,
+ AbstractType::class,
[],
'',
false
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php
index 371d75bc922f3..6035dc25e52d7 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php
@@ -1,4 +1,4 @@
-entityModel = $this->createMock(\Magento\CatalogImportExport\Model\Import\Product::class);
+ $this->entityModel = $this->createMock(Product::class);
$attrSetColFactory = $this->createPartialMock(
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class,
['create']
);
- $attrSetCollection = $this->createMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class);
+ $attrSetCollection = $this->createMock(Collection::class);
$attrColFactory = $this->createPartialMock(
\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class,
['create']
);
- $attributeSet = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Set::class);
+ $attributeSet = $this->createMock(Set::class);
$attrCollection = $this->createPartialMock(
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::class,
[
@@ -73,7 +85,7 @@ protected function setUp()
]
);
$attribute = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute::class,
+ Attribute::class,
[
'getAttributeCode',
'getId',
@@ -148,15 +160,13 @@ protected function setUp()
['main_table.attribute_id', 'main_table.attribute_code'],
[
[
- 'in' =>
- [
+ 'in' => [
'attribute_id',
'boolean_attribute',
],
],
[
- 'in' =>
- [
+ 'in' => [
'related_tgtr_position_behavior',
'related_tgtr_position_limit',
'upsell_tgtr_position_behavior',
@@ -171,7 +181,7 @@ protected function setUp()
->willReturn([$attribute1, $attribute2, $attribute3]);
$this->connection = $this->createPartialMock(
- \Magento\Framework\DB\Adapter\Pdo\Mysql::class,
+ Mysql::class,
[
'select',
'fetchAll',
@@ -183,7 +193,7 @@ protected function setUp()
]
);
$this->select = $this->createPartialMock(
- \Magento\Framework\DB\Select::class,
+ Select::class,
[
'from',
'where',
@@ -195,7 +205,7 @@ protected function setUp()
$this->select->expects($this->any())->method('where')->will($this->returnSelf());
$this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
$this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
- $connection = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class);
+ $connection = $this->createMock(Mysql::class);
$connection->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
$this->select->expects($this->any())->method('getConnection')->willReturn($connection);
$this->connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
@@ -207,7 +217,7 @@ protected function setUp()
->will($this->returnValue($entityAttributes));
$this->resource = $this->createPartialMock(
- \Magento\Framework\App\ResourceConnection::class,
+ ResourceConnection::class,
[
'getConnection',
'getTableName',
@@ -222,7 +232,7 @@ protected function setUp()
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->simpleType = $this->objectManagerHelper->getObject(
- \Magento\CatalogImportExport\Model\Import\Product\Type\Simple::class,
+ Simple::class,
[
'attrSetColFac' => $attrSetColFactory,
'prodAttrColFac' => $attrColFactory,
@@ -281,7 +291,7 @@ public function testIsRowValidSuccess()
$this->simpleType,
'_attributes',
[
- $rowData[\Magento\CatalogImportExport\Model\Import\Product::COL_ATTR_SET] => [],
+ $rowData[Product::COL_ATTR_SET] => [],
]
);
$this->assertTrue($this->simpleType->isRowValid($rowData, $rowNum));
@@ -297,7 +307,7 @@ public function testIsRowValidError()
$this->entityModel->expects($this->any())->method('getRowScope')->willReturn(1);
$this->entityModel->expects($this->once())->method('addRowError')
->with(
- \Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface::ERROR_VALUE_IS_REQUIRED,
+ RowValidatorInterface::ERROR_VALUE_IS_REQUIRED,
1,
'attr_code'
)
@@ -306,7 +316,7 @@ public function testIsRowValidError()
$this->simpleType,
'_attributes',
[
- $rowData[\Magento\CatalogImportExport\Model\Import\Product::COL_ATTR_SET] => [
+ $rowData[Product::COL_ATTR_SET] => [
'attr_code' => [
'is_required' => true,
],
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php
index f8b14a471fd9c..12993d093b352 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php
@@ -1,17 +1,39 @@
-createPartialMock(\Magento\Catalog\Helper\Data::class, ['__construct']);
+ $catalogDataMock = $this->createPartialMock(Data::class, ['__construct']);
- $scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $scopeConfig = $this->createMock(ScopeConfigInterface::class);
- $timezoneInterface = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
+ $timezoneInterface = $this->createMock(TimezoneInterface::class);
$date = new \DateTime();
$timezoneInterface->expects($this->any())->method('date')->willReturn($date);
- $this->metadataPoolMock = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class);
- $entityMetadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class);
+ $this->metadataPoolMock = $this->createMock(MetadataPool::class);
+ $entityMetadataMock = $this->createMock(EntityMetadata::class);
$this->metadataPoolMock->expects($this->any())
->method('getMetadata')
- ->with(\Magento\Catalog\Api\Data\ProductInterface::class)
+ ->with(ProductInterface::class)
->willReturn($entityMetadataMock);
$entityMetadataMock->expects($this->any())
->method('getLinkField')
@@ -255,7 +277,7 @@ protected function setUp()
\Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory::class
);
$optionValueCollectionMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection::class,
+ Collection::class,
['getIterator', 'addTitleToResult']
);
$optionValueCollectionMock->expects($this->any())->method('getIterator')
@@ -264,9 +286,9 @@ protected function setUp()
->method('create')->willReturn($optionValueCollectionMock);
$modelClassArgs = [
$this->createMock(\Magento\ImportExport\Model\ResourceModel\Import\Data::class),
- $this->createMock(\Magento\Framework\App\ResourceConnection::class),
- $this->createMock(\Magento\ImportExport\Model\ResourceModel\Helper::class),
- $this->createMock(\Magento\Store\Model\StoreManagerInterface::class),
+ $this->createMock(ResourceConnection::class),
+ $this->createMock(Helper::class),
+ $this->createMock(StoreManagerInterface::class),
$this->createMock(\Magento\Catalog\Model\ProductFactory::class),
$this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory::class),
$this->createMock(\Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory::class),
@@ -274,20 +296,20 @@ protected function setUp()
$scopeConfig,
$timezoneInterface,
$this->createMock(
- \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface::class
+ ProcessingErrorAggregatorInterface::class
),
$this->_getModelDependencies($addExpectations, $deleteBehavior, $doubleOptions),
$optionValueCollectionFactoryMock
];
- $modelClassName = \Magento\CatalogImportExport\Model\Import\Product\Option::class;
+ $modelClassName = Option::class;
$this->model = new $modelClassName(...array_values($modelClassArgs));
// Create model mock with rewritten _getMultiRowFormat method to support test data with the old format.
$this->modelMock = $this->getMockBuilder($modelClassName)
->setConstructorArgs($modelClassArgs)
->setMethods(['_getMultiRowFormat'])
->getMock();
- $reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product\Option::class);
+ $reflection = new \ReflectionClass(Option::class);
$reflectionProperty = $reflection->getProperty('metadataPool');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($this->modelMock, $this->metadataPoolMock);
@@ -296,7 +318,7 @@ protected function setUp()
/**
* Unset entity adapter model
*/
- protected function tearDown()
+ protected function tearDown(): void
{
unset($this->model);
unset($this->productEntity);
@@ -402,18 +424,18 @@ protected function _getSourceDataMocks($addExpectations, $doubleOptions)
'id' => $elementIndex,
'entity_id' => $elementIndex,
'product_id' => $elementIndex,
- 'type' => $csvDataRow[\Magento\CatalogImportExport\Model\Import\Product::COL_TYPE],
- 'title' => $csvDataRow[\Magento\CatalogImportExport\Model\Import\Product::COL_NAME]
+ 'type' => $csvDataRow[Product::COL_TYPE],
+ 'title' => $csvDataRow[Product::COL_NAME]
];
}
}
$this->productEntity = $this->createPartialMock(
- \Magento\CatalogImportExport\Model\Import\Product::class,
+ Product::class,
['getErrorAggregator']
);
$this->productEntity->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject());
- $reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product::class);
+ $reflection = new \ReflectionClass(Product::class);
$reflectionProperty = $reflection->getProperty('metadataPool');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($this->productEntity, $this->metadataPoolMock);
@@ -428,18 +450,18 @@ protected function _getSourceDataMocks($addExpectations, $doubleOptions)
);
$fetchStrategy = $this->getMockForAbstractClass(
- \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class,
+ FetchStrategyInterface::class,
['fetchAll']
);
- $logger = $this->createMock(\Psr\Log\LoggerInterface::class);
- $entityFactory = $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class);
+ $logger = $this->createMock(LoggerInterface::class);
+ $entityFactory = $this->createMock(EntityFactory::class);
- $optionCollection = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class)
+ $optionCollection = $this->getMockBuilder(AbstractDb::class)
->setConstructorArgs([$entityFactory, $logger, $fetchStrategy])
->setMethods(['reset', 'addProductToFilter', 'getSelect', 'getNewEmptyItem'])
->getMockForAbstractClass();
- $select = $this->createPartialMock(\Magento\Framework\DB\Select::class, ['join', 'where']);
+ $select = $this->createPartialMock(Select::class, ['join', 'where']);
$select->expects($this->any())->method('join')->will($this->returnSelf());
$select->expects($this->any())->method('where')->will($this->returnSelf());
@@ -490,11 +512,11 @@ protected function _getSourceDataMocks($addExpectations, $doubleOptions)
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
- * @param \Magento\Framework\Data\Collection\AbstractDb $collection
+ * @param AbstractDb $collection
* @param int $pageSize
* @param array $callbacks
*/
- public function iterate(\Magento\Framework\Data\Collection\AbstractDb $collection, $pageSize, array $callbacks)
+ public function iterate(AbstractDb $collection, $pageSize, array $callbacks)
{
foreach ($collection as $option) {
foreach ($callbacks as $callback) {
@@ -506,7 +528,7 @@ public function iterate(\Magento\Framework\Data\Collection\AbstractDb $collectio
/**
* Get new object mock for \Magento\Catalog\Model\Product\Option
*
- * @return \Magento\Catalog\Model\Product\Option|\PHPUnit_Framework_MockObject_MockObject
+ * @return \Magento\Catalog\Model\Product\Option|MockObject
*/
public function getNewOptionMock()
{
@@ -635,7 +657,7 @@ public function testImportDataAppendBehavior()
*/
public function testImportDataDeleteBehavior()
{
- $this->model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE]);
+ $this->model->setParameters(['behavior' => Import::BEHAVIOR_DELETE]);
$this->model->importData();
}
@@ -758,7 +780,7 @@ public function testValidateAmbiguousData(
$this->_testStores = ['admin' => 0];
$this->setUp();
if ($behavior) {
- $this->modelMock->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND]);
+ $this->modelMock->setParameters(['behavior' => Import::BEHAVIOR_APPEND]);
}
$this->_bypassModelMethodGetMultiRowFormat($rowData);
@@ -786,7 +808,7 @@ public function testValidateAmbiguousData(
*/
public function testValidateRowDataForStoreViewCodeField($rowData, $responseData)
{
- $reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product\Option::class);
+ $reflection = new \ReflectionClass(Option::class);
$reflectionMethod = $reflection->getMethod('_parseCustomOptions');
$reflectionMethod->setAccessible(true);
$result = $reflectionMethod->invoke($this->model, $rowData);
@@ -804,8 +826,7 @@ public function validateRowStoreViewCodeFieldDataProvider()
'with_store_view_code' => [
'$rowData' => [
'store_view_code' => '',
- 'custom_options' =>
- 'name=Test Field Title,type=field,required=1;sku=1-text,price=0,price_type=fixed'
+ 'custom_options' => 'name=Test Field Title,type=field,required=1;sku=1-text,price=0,price_type=fixed'
],
'$responseData' => [
'store_view_code' => '',
@@ -826,8 +847,7 @@ public function validateRowStoreViewCodeFieldDataProvider()
],
'without_store_view_code' => [
'$rowData' => [
- 'custom_options' =>
- 'name=Test Field Title,type=field,required=1;sku=1-text,price=0,price_type=fixed'
+ 'custom_options' => 'name=Test Field Title,type=field,required=1;sku=1-text,price=0,price_type=fixed'
],
'$responseData' => [
'custom_options' => [
@@ -863,55 +883,55 @@ public function validateRowDataProvider()
'main_invalid_store' => [
'$rowData' => include __DIR__ . '/_files/row_data_main_invalid_store.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_INVALID_STORE => [1]
+ Option::ERROR_INVALID_STORE => [1]
]
],
'main_incorrect_type' => [
'$rowData' => include __DIR__ . '/_files/row_data_main_incorrect_type.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_INVALID_TYPE => [1]
+ Option::ERROR_INVALID_TYPE => [1]
]
],
'main_no_title' => [
'$rowData' => include __DIR__ . '/_files/row_data_main_no_title.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_EMPTY_TITLE => [1]
+ Option::ERROR_EMPTY_TITLE => [1]
]
],
'main_empty_title' => [
'$rowData' => include __DIR__ . '/_files/row_data_main_empty_title.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_EMPTY_TITLE => [1]
+ Option::ERROR_EMPTY_TITLE => [1]
]
],
'main_invalid_price' => [
'$rowData' => include __DIR__ . '/_files/row_data_main_invalid_price.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_INVALID_PRICE => [1]
+ Option::ERROR_INVALID_PRICE => [1]
]
],
'main_invalid_max_characters' => [
'$rowData' => include __DIR__ . '/_files/row_data_main_invalid_max_characters.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_INVALID_MAX_CHARACTERS => [1]
+ Option::ERROR_INVALID_MAX_CHARACTERS => [1]
]
],
'main_max_characters_less_zero' => [
'$rowData' => include __DIR__ . '/_files/row_data_main_max_characters_less_zero.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_INVALID_MAX_CHARACTERS => [1]
+ Option::ERROR_INVALID_MAX_CHARACTERS => [1]
]
],
'main_invalid_sort_order' => [
'$rowData' => include __DIR__ . '/_files/row_data_main_invalid_sort_order.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_INVALID_SORT_ORDER => [1]
+ Option::ERROR_INVALID_SORT_ORDER => [1]
]
],
'main_sort_order_less_zero' => [
'$rowData' => include __DIR__ . '/_files/row_data_main_sort_order_less_zero.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_INVALID_SORT_ORDER => [1]
+ Option::ERROR_INVALID_SORT_ORDER => [1]
]
],
'secondary_valid' => [
@@ -921,25 +941,25 @@ public function validateRowDataProvider()
'secondary_invalid_store' => [
'$rowData' => include __DIR__ . '/_files/row_data_secondary_invalid_store.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_INVALID_STORE => [1]
+ Option::ERROR_INVALID_STORE => [1]
]
],
'secondary_incorrect_price' => [
'$rowData' => include __DIR__ . '/_files/row_data_secondary_incorrect_price.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_INVALID_ROW_PRICE => [1]
+ Option::ERROR_INVALID_ROW_PRICE => [1]
]
],
'secondary_incorrect_row_sort' => [
'$rowData' => include __DIR__ . '/_files/row_data_secondary_incorrect_row_sort.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_INVALID_ROW_SORT => [1]
+ Option::ERROR_INVALID_ROW_SORT => [1]
]
],
'secondary_row_sort_less_zero' => [
'$rowData' => include __DIR__ . '/_files/row_data_secondary_row_sort_less_zero.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_INVALID_ROW_SORT => [1]
+ Option::ERROR_INVALID_ROW_SORT => [1]
]
]
];
@@ -956,7 +976,7 @@ public function validateAmbiguousDataDataProvider()
'ambiguity_several_input_rows' => [
'$rowData' => include __DIR__ . '/_files/row_data_main_valid.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_AMBIGUOUS_NEW_NAMES => [2, 2]
+ Option::ERROR_AMBIGUOUS_NEW_NAMES => [2, 2]
],
'$behavior' => null,
'$numberOfValidations' => 2
@@ -964,16 +984,16 @@ public function validateAmbiguousDataDataProvider()
'ambiguity_different_type' => [
'$rowData' => include __DIR__ . '/_files/row_data_ambiguity_different_type.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_AMBIGUOUS_TYPES => [1]
+ Option::ERROR_AMBIGUOUS_TYPES => [1]
],
- '$behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND
+ '$behavior' => Import::BEHAVIOR_APPEND
],
'ambiguity_several_db_rows' => [
'$rowData' => include __DIR__ . '/_files/row_data_ambiguity_several_db_rows.php',
'$errors' => [
- \Magento\CatalogImportExport\Model\Import\Product\Option::ERROR_AMBIGUOUS_OLD_NAMES => [1]
+ Option::ERROR_AMBIGUOUS_OLD_NAMES => [1]
],
- '$behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND
+ '$behavior' => Import::BEHAVIOR_APPEND
]
];
}
@@ -995,16 +1015,16 @@ public function testParseRequiredData()
$productModel = $this->createPartialMock(\stdClass::class, ['getProductEntitiesInfo']);
$productModel->expects($this->any())->method('getProductEntitiesInfo')->will($this->returnValue([]));
- /** @var \Magento\CatalogImportExport\Model\Import\Product $productEntityMock */
- $productEntityMock = $this->createMock(\Magento\CatalogImportExport\Model\Import\Product::class);
- $reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product::class);
+ /** @var Product $productEntityMock */
+ $productEntityMock = $this->createMock(Product::class);
+ $reflection = new \ReflectionClass(Product::class);
$reflectionProperty = $reflection->getProperty('metadataPool');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($productEntityMock, $this->metadataPoolMock);
- /** @var \Magento\CatalogImportExport\Model\Import\Product\Option $model */
+ /** @var Option $model */
$model = $this->objectManagerHelper->getObject(
- \Magento\CatalogImportExport\Model\Import\Product\Option::class,
+ Option::class,
[
'data' => [
'data_source_model' => $modelData,
@@ -1018,7 +1038,7 @@ public function testParseRequiredData()
]
]
);
- $reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product\Option::class);
+ $reflection = new \ReflectionClass(Option::class);
$reflectionProperty = $reflection->getProperty('metadataPool');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($model, $this->metadataPoolMock);
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/VirtualTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/VirtualTest.php
index 7f5a856dde758..4ea399fa63f28 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/VirtualTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/VirtualTest.php
@@ -1,4 +1,4 @@
-createPartialMock(
- \Magento\CatalogImportExport\Model\Import\Product\Type\Virtual::class,
+ Virtual::class,
[]
);
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/_files/row_data_ambiguity_different_type.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/_files/row_data_ambiguity_different_type.php
index 5bc9882f3d289..8fd24fb9881d5 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/_files/row_data_ambiguity_different_type.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/_files/row_data_ambiguity_different_type.php
@@ -1,4 +1,4 @@
-userContext = $this->createMock(UserContextInterface::class);
$this->authorization = $this->createMock(AuthorizationInterface::class);
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/LayoutUpdateTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/LayoutUpdateTest.php
index d1e8b879f6a08..0f85c5a7e6f6c 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/LayoutUpdateTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/LayoutUpdateTest.php
@@ -13,8 +13,8 @@
use Magento\Framework\Config\ValidationStateInterface;
use Magento\Framework\View\Model\Layout\Update\Validator;
use Magento\Framework\View\Model\Layout\Update\ValidatorFactory;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Test validation for layout update
@@ -31,7 +31,7 @@ class LayoutUpdateTest extends TestCase
*/
private $layoutValidator;
- protected function setUp()
+ protected function setUp(): void
{
$validatorFactory = $this->createMock(ValidatorFactory::class);
$validationState = $this->createMock(ValidationStateInterface::class);
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/MediaTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/MediaTest.php
index 439ffb99190bc..92f05d039b8ae 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/MediaTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/MediaTest.php
@@ -1,4 +1,4 @@
-validatorMock = $this->getMockBuilder(Validator::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/QuantityTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/QuantityTest.php
index b550102cb1a15..12bc24d621745 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/QuantityTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/QuantityTest.php
@@ -1,4 +1,4 @@
-quantity = new Quantity();
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/SuperProductsSkuTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/SuperProductsSkuTest.php
index 8294f82f35a39..0c2357f3f5998 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/SuperProductsSkuTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/SuperProductsSkuTest.php
@@ -1,4 +1,4 @@
-skuProcessorMock = $this->getMockBuilder(SkuProcessor::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/TierPriceTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/TierPriceTest.php
index bffefce24e1fd..4f30f89742828 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/TierPriceTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/TierPriceTest.php
@@ -1,4 +1,4 @@
-groupRepositoryInterface = $this->createMock(
- \Magento\Customer\Model\ResourceModel\GroupRepository::class
+ GroupRepository::class
);
- $this->searchCriteriaSearch = $this->createMock(\Magento\Framework\Api\SearchCriteria::class);
- $this->searchCriteriaBuilder = $this->createMock(\Magento\Framework\Api\SearchCriteriaBuilder::class);
+ $this->searchCriteriaSearch = $this->createMock(SearchCriteria::class);
+ $this->searchCriteriaBuilder = $this->createMock(SearchCriteriaBuilder::class);
$this->searchCriteriaBuilder->expects($this->any())->method('create')->willReturn($this->searchCriteriaSearch);
$this->storeResolver = $this->createMock(
- \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class
+ StoreResolver::class
);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->tierPrice = $this->objectManagerHelper->getObject(
- \Magento\CatalogImportExport\Model\Import\Product\Validator\TierPrice::class,
+ TierPrice::class,
[
'groupRepository' => $this->groupRepositoryInterface,
'searchCriteriaBuilder' => $this->searchCriteriaBuilder,
@@ -50,13 +60,13 @@ protected function setUp()
/**
* @param $groupId
- * @return \Magento\CatalogImportExport\Model\Import\Product\Validator\TierPrice
+ * @return TierPrice
*/
protected function processInit($groupId)
{
- $searchResult = $this->createMock(\Magento\Customer\Api\Data\GroupSearchResultsInterface::class);
+ $searchResult = $this->createMock(GroupSearchResultsInterface::class);
$this->groupRepositoryInterface->expects($this->once())->method('getList')->willReturn($searchResult);
- $group = $this->createMock(\Magento\Customer\Model\Data\Group::class);
+ $group = $this->createMock(Group::class);
$group->expects($this->once())->method('getId')->willReturn($groupId);
$searchResult->expects($this->once())->method('getItems')->willReturn([$group]);
return $this->tierPrice->init(null);
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/WeightTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/WeightTest.php
index 78174828ae26e..eb0fcf5754e71 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/WeightTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/WeightTest.php
@@ -10,18 +10,16 @@
use Magento\CatalogImportExport\Model\Import\Product;
use Magento\CatalogImportExport\Model\Import\Product\Validator\Weight;
use Magento\ImportExport\Model\Import;
+use PHPUnit\Framework\TestCase;
-/**
- * Class WeightTest
- */
-class WeightTest extends \PHPUnit\Framework\TestCase
+class WeightTest extends TestCase
{
/**
* @var Weight
*/
private $weight;
- protected function setUp()
+ protected function setUp(): void
{
$this->weight = new Weight();
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php
index 64b925955519e..7dcf4aec7ea46 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php
@@ -1,4 +1,4 @@
-createPartialMock(
- \Magento\CatalogImportExport\Model\Import\Product\Type\Simple::class,
+ Simple::class,
['retrieveAttributeFromCache']
);
$entityTypeModel->expects($this->any())->method('retrieveAttributeFromCache')->willReturn([]);
$this->context = $this->createPartialMock(
- \Magento\CatalogImportExport\Model\Import\Product::class,
+ Product::class,
['retrieveProductTypeByName', 'retrieveMessageTemplate', 'getBehavior']
);
$this->context->expects($this->any())->method('retrieveProductTypeByName')->willReturn($entityTypeModel);
$this->context->expects($this->any())->method('retrieveMessageTemplate')->willReturn('error message');
$this->validatorOne = $this->createPartialMock(
- \Magento\CatalogImportExport\Model\Import\Product\Validator\Media::class,
+ Media::class,
['init', 'isValid']
);
$this->validatorTwo = $this->createPartialMock(
- \Magento\CatalogImportExport\Model\Import\Product\Validator\Website::class,
+ Website::class,
['init', 'isValid', 'getMessages']
);
$this->validators = [$this->validatorOne, $this->validatorTwo];
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->validator = $this->objectManagerHelper->getObject(
- \Magento\CatalogImportExport\Model\Import\Product\Validator::class,
+ Validator::class,
['validators' => $this->validators]
);
$this->validator->init($this->context);
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php
index ff724ddc746aa..086d3821c7f01 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php
@@ -1,4 +1,4 @@
-createMock(\Magento\Framework\EntityManager\MetadataPool::class);
- $entityMetadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class);
+ $metadataPoolMock = $this->createMock(MetadataPool::class);
+ $entityMetadataMock = $this->createMock(EntityMetadata::class);
$metadataPoolMock->expects($this->any())
->method('getMetadata')
- ->with(\Magento\Catalog\Api\Data\ProductInterface::class)
+ ->with(ProductInterface::class)
->willReturn($entityMetadataMock);
$entityMetadataMock->expects($this->any())
->method('getLinkField')
@@ -184,7 +225,7 @@ protected function setUp()
/* For parent object construct */
$this->jsonHelper =
- $this->getMockBuilder(\Magento\Framework\Json\Helper\Data::class)
+ $this->getMockBuilder(Data::class)
->disableOriginalConstructor()
->getMock();
$this->importExportData =
@@ -196,34 +237,34 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
$this->config =
- $this->getMockBuilder(\Magento\Eav\Model\Config::class)
+ $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
$this->resource =
- $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class)
+ $this->getMockBuilder(ResourceConnection::class)
->disableOriginalConstructor()
->getMock();
$this->resourceHelper =
- $this->getMockBuilder(\Magento\ImportExport\Model\ResourceModel\Helper::class)
+ $this->getMockBuilder(Helper::class)
->disableOriginalConstructor()
->getMock();
$this->string =
- $this->getMockBuilder(\Magento\Framework\Stdlib\StringUtils::class)
+ $this->getMockBuilder(StringUtils::class)
->disableOriginalConstructor()
->getMock();
/* For object construct */
$this->_eventManager =
- $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class)
+ $this->getMockBuilder(ManagerInterface::class)
->getMock();
$this->stockRegistry =
- $this->getMockBuilder(\Magento\CatalogInventory\Api\StockRegistryInterface::class)
+ $this->getMockBuilder(StockRegistryInterface::class)
->getMock();
$this->stockConfiguration =
- $this->getMockBuilder(\Magento\CatalogInventory\Api\StockConfigurationInterface::class)
+ $this->getMockBuilder(StockConfigurationInterface::class)
->getMock();
$this->stockStateProvider =
- $this->getMockBuilder(\Magento\CatalogInventory\Model\Spi\StockStateProviderInterface::class)
+ $this->getMockBuilder(StockStateProviderInterface::class)
->getMock();
$this->_catalogData =
$this->getMockBuilder(\Magento\Catalog\Helper\Data::class)
@@ -242,7 +283,7 @@ protected function setUp()
['create']
);
$this->_productTypeFactory = $this->createPartialMock(
- \Magento\CatalogImportExport\Model\Import\Product\Type\Factory::class,
+ Factory::class,
['create']
);
$this->_linkFactory = $this->createPartialMock(
@@ -258,32 +299,32 @@ protected function setUp()
['create']
);
$this->_filesystem =
- $this->getMockBuilder(\Magento\Framework\Filesystem::class)
+ $this->getMockBuilder(Filesystem::class)
->disableOriginalConstructor()
->getMock();
$this->_mediaDirectory =
- $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class)
+ $this->getMockBuilder(WriteInterface::class)
->getMock();
$this->_stockResItemFac = $this->createPartialMock(
\Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory::class,
['create']
);
$this->_localeDate =
- $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class)
+ $this->getMockBuilder(TimezoneInterface::class)
->getMock();
$this->dateTime =
- $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime::class)
+ $this->getMockBuilder(DateTime::class)
->disableOriginalConstructor()
->getMock();
$this->indexerRegistry =
- $this->getMockBuilder(\Magento\Framework\Indexer\IndexerRegistry::class)
+ $this->getMockBuilder(IndexerRegistry::class)
->disableOriginalConstructor()
->getMock();
$this->_logger =
- $this->getMockBuilder(\Psr\Log\LoggerInterface::class)
+ $this->getMockBuilder(LoggerInterface::class)
->getMock();
$this->storeResolver =
- $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class)
+ $this->getMockBuilder(StoreResolver::class)
->setMethods(
[
'getStoreCodeToId',
@@ -292,41 +333,41 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
$this->skuProcessor =
- $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\SkuProcessor::class)
+ $this->getMockBuilder(SkuProcessor::class)
->disableOriginalConstructor()
->getMock();
- $reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product\SkuProcessor::class);
+ $reflection = new \ReflectionClass(SkuProcessor::class);
$reflectionProperty = $reflection->getProperty('metadataPool');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($this->skuProcessor, $metadataPoolMock);
$this->categoryProcessor =
- $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\CategoryProcessor::class)
+ $this->getMockBuilder(CategoryProcessor::class)
->disableOriginalConstructor()
->getMock();
$this->validator =
- $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\Validator::class)
+ $this->getMockBuilder(Validator::class)
->setMethods(['isAttributeValid', 'getMessages', 'isValid', 'init'])
->disableOriginalConstructor()
->getMock();
$this->objectRelationProcessor =
- $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class)
+ $this->getMockBuilder(ObjectRelationProcessor::class)
->disableOriginalConstructor()
->getMock();
$this->transactionManager =
- $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface::class)
+ $this->getMockBuilder(TransactionManagerInterface::class)
->getMock();
$this->taxClassProcessor =
- $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\TaxClassProcessor::class)
+ $this->getMockBuilder(TaxClassProcessor::class)
->disableOriginalConstructor()
->getMock();
- $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
+ $this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->productUrl = $this->getMockBuilder(\Magento\Catalog\Model\Product\Url::class)
+ $this->productUrl = $this->getMockBuilder(Url::class)
->disableOriginalConstructor()
->getMock();
@@ -345,7 +386,7 @@ protected function setUp()
->_initSkus()
->_initImagesArrayKeys();
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManager($this);
$this->importProduct = $objectManager->getObject(
Product::class,
@@ -405,7 +446,7 @@ protected function _objectConstructor()
\Magento\CatalogImportExport\Model\Import\Product\OptionFactory::class,
['create']
);
- $this->optionEntity = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\Option::class)
+ $this->optionEntity = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()->getMock();
$this->optionFactory->expects($this->once())->method('create')->willReturn($this->optionEntity);
@@ -423,11 +464,11 @@ protected function _objectConstructor()
*/
protected function _parentObjectConstructor()
{
- $type = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class)->disableOriginalConstructor()->getMock();
+ $type = $this->getMockBuilder(Type::class)->disableOriginalConstructor()->getMock();
$type->expects($this->any())->method('getEntityTypeId')->will($this->returnValue(self::ENTITY_TYPE_ID));
$this->config->expects($this->any())->method('getEntityType')->with(self::ENTITY_TYPE_CODE)->willReturn($type);
- $this->_connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
+ $this->_connection = $this->createMock(AdapterInterface::class);
$this->resource->expects($this->any())->method('getConnection')->willReturn($this->_connection);
return $this;
}
@@ -437,7 +478,7 @@ protected function _parentObjectConstructor()
*/
protected function _initAttributeSets()
{
- $attributeSetOne = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Set::class)
+ $attributeSetOne = $this->getMockBuilder(Set::class)
->disableOriginalConstructor()
->getMock();
$attributeSetOne->expects($this->any())
@@ -446,7 +487,7 @@ protected function _initAttributeSets()
$attributeSetOne->expects($this->any())
->method('getId')
->willReturn('1');
- $attributeSetTwo = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Set::class)
+ $attributeSetTwo = $this->getMockBuilder(Set::class)
->disableOriginalConstructor()
->getMock();
$attributeSetTwo->expects($this->any())
@@ -456,7 +497,7 @@ protected function _initAttributeSets()
->method('getId')
->willReturn('2');
$attributeSetCol = [$attributeSetOne, $attributeSetTwo];
- $collection = $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class)
+ $collection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
$collection->expects($this->once())
@@ -480,7 +521,7 @@ protected function _initTypeModels()
'params' => [],
]];
$productTypeInstance =
- $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType::class)
+ $this->getMockBuilder(AbstractType::class)
->disableOriginalConstructor()->getMock();
$productTypeInstance->expects($this->once())
->method('isSuitable')
@@ -547,12 +588,12 @@ public function testSaveProductAttributes()
$this->_connection->expects($this->once())
->method('insertOnDuplicate')
->with($testTable, $tableData, ['value']);
- $attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $attribute = $this->getMockBuilder(AbstractAttribute::class)
->disableOriginalConstructor()
->setMethods(['getId'])
->getMockForAbstractClass();
$attribute->expects($this->once())->method('getId')->willReturn(1);
- $resource = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModel::class)
+ $resource = $this->getMockBuilder(ResourceModel::class)
->disableOriginalConstructor()
->setMethods(['getAttribute'])
->getMock();
@@ -570,7 +611,7 @@ public function testIsAttributeValidAssertAttrValid($attrParams, $rowData)
{
$attrCode = 'code';
$rowNum = 0;
- $string = $this->getMockBuilder(\Magento\Framework\Stdlib\StringUtils::class)->setMethods(null)->getMock();
+ $string = $this->getMockBuilder(StringUtils::class)->setMethods(null)->getMock();
$this->setPropertyValue($this->importProduct, 'string', $string);
$this->validator->expects($this->once())->method('isAttributeValid')->willReturn(true);
@@ -586,7 +627,7 @@ public function testIsAttributeValidAssertAttrInvalid($attrParams, $rowData)
{
$attrCode = 'code';
$rowNum = 0;
- $string = $this->getMockBuilder(\Magento\Framework\Stdlib\StringUtils::class)->setMethods(null)->getMock();
+ $string = $this->getMockBuilder(StringUtils::class)->setMethods(null)->getMock();
$this->setPropertyValue($this->importProduct, 'string', $string);
$this->validator->expects($this->once())->method('isAttributeValid')->willReturn(false);
@@ -613,7 +654,7 @@ public function testGetMultipleValueSeparatorFromParameters()
$this->importProduct,
'_parameters',
[
- \Magento\ImportExport\Model\Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR => $expectedSeparator,
+ Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR => $expectedSeparator,
]
);
@@ -639,7 +680,7 @@ public function testGetEmptyAttributeValueConstantFromParameters()
$this->importProduct,
'_parameters',
[
- \Magento\ImportExport\Model\Import::FIELD_EMPTY_ATTRIBUTE_VALUE_CONSTANT => $expectedSeparator,
+ Import::FIELD_EMPTY_ATTRIBUTE_VALUE_CONSTANT => $expectedSeparator,
]
);
@@ -663,7 +704,7 @@ public function testDeleteProductsForReplacement()
$importProduct->expects($this->once())->method('setParameters')->with(
[
- 'behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE,
+ 'behavior' => Import::BEHAVIOR_DELETE,
]
);
$importProduct->expects($this->once())->method('_deleteProducts');
@@ -679,12 +720,12 @@ public function testGetMediaGalleryAttributeIdIfNotSetYet()
$this->setPropertyValue($this->importProduct, '_mediaGalleryAttributeId', null);
$expectedId = '100';
- $attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $attribute = $this->getMockBuilder(AbstractAttribute::class)
->disableOriginalConstructor()
->setMethods(['getId'])
->getMockForAbstractClass();
$attribute->expects($this->once())->method('getId')->willReturn($expectedId);
- $resource = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModel::class)
+ $resource = $this->getMockBuilder(ResourceModel::class)
->disableOriginalConstructor()
->setMethods(['getAttribute'])
->getMock();
@@ -750,7 +791,7 @@ public function testValidateRowDeleteBehaviourAddRowErrorCall()
->getMock();
$importProduct->expects($this->exactly(2))->method('getBehavior')
- ->willReturn(\Magento\ImportExport\Model\Import::BEHAVIOR_DELETE);
+ ->willReturn(Import::BEHAVIOR_DELETE);
$importProduct->expects($this->once())->method('getRowScope')
->willReturn(Product::SCOPE_DEFAULT);
$importProduct->expects($this->once())->method('addRowError');
@@ -1000,7 +1041,7 @@ public function testValidateRowValidateExistingProductTypeAddErrorRowCall()
$this->setPropertyValue($importProduct, '_oldSku', $oldSku);
$importProduct->expects($this->once())->method('addRowError')->with(
- \Magento\CatalogImportExport\Model\Import\Product\Validator::ERROR_TYPE_UNSUPPORTED,
+ Validator::ERROR_TYPE_UNSUPPORTED,
$rowNum
);
@@ -1140,7 +1181,7 @@ public function testValidateRowSetAttributeSetCodeIntoRowData()
$this->skuProcessor->expects($this->any())->method('getNewSku')->willReturn($newSku);
$this->setPropertyValue($importProduct, 'skuProcessor', $this->skuProcessor);
- $productType = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType::class)
+ $productType = $this->getMockBuilder(AbstractType::class)
->disableOriginalConstructor()
->getMock();
$productType->expects($this->once())->method('isRowValid')->with($expectedRowData);
@@ -1183,7 +1224,7 @@ public function testValidateValidateOptionEntity()
//suppress validator
$this->_setValidatorMockInImportProduct($importProduct);
- $option = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\Option::class)
+ $option = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->getMock();
$option->expects($this->once())->method('validateRow')->with($rowData, $rowNum);
@@ -1223,7 +1264,7 @@ public function testParseAttributesWithoutWrappedValuesWillReturnsLowercasedAttr
public function testParseAttributesWithWrappedValuesWillReturnsLowercasedAttributeCodes()
{
- $attribute1 = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $attribute1 = $this->getMockBuilder(AbstractAttribute::class)
->disableOriginalConstructor()
->setMethods(['getFrontendInput'])
->getMockForAbstractClass();
@@ -1232,7 +1273,7 @@ public function testParseAttributesWithWrappedValuesWillReturnsLowercasedAttribu
->method('getFrontendInput')
->willReturn('text');
- $attribute2 = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
+ $attribute2 = $this->getMockBuilder(AbstractAttribute::class)
->disableOriginalConstructor()
->setMethods(['getFrontendInput'])
->getMockForAbstractClass();
@@ -1274,7 +1315,7 @@ public function testParseAttributesWithWrappedValuesWillReturnsLowercasedAttribu
public function testFillUploaderObject($isRead, $isWrite, $message)
{
$fileUploaderMock = $this
- ->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Uploader::class)
+ ->getMockBuilder(Uploader::class)
->disableOriginalConstructor()
->getMock();
@@ -1309,7 +1350,7 @@ public function testFillUploaderObject($isRead, $isWrite, $message)
try {
$this->importProduct->getUploader();
$this->assertNotNull($this->getPropertyValue($this->importProduct, '_fileUploader'));
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
+ } catch (LocalizedException $e) {
$this->assertNull($this->getPropertyValue($this->importProduct, '_fileUploader'));
$this->assertEquals($message, $e->getMessage());
}
@@ -1331,7 +1372,7 @@ public function testUploadMediaFiles(string $fileName, bool $throwException)
$this->_logger->expects($this->once())->method('critical')->with($exception);
}
$fileUploaderMock = $this
- ->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Uploader::class)
+ ->getMockBuilder(Uploader::class)
->disableOriginalConstructor()
->getMock();
$fileUploaderMock
@@ -1428,28 +1469,28 @@ public function validateRowValidateNewProductTypeAddRowErrorCallDataProvider()
'$productTypeModelsColType' => 'value',
'$colAttrSet' => null,
'$attrSetNameToIdColAttrSet' => null,
- '$error' => \Magento\CatalogImportExport\Model\Import\Product\Validator::ERROR_INVALID_TYPE
+ '$error' => Validator::ERROR_INVALID_TYPE
],
[
'$colType' => 'value',
'$productTypeModelsColType' => null,
'$colAttrSet' => null,
'$attrSetNameToIdColAttrSet' => null,
- '$error' => \Magento\CatalogImportExport\Model\Import\Product\Validator::ERROR_INVALID_TYPE,
+ '$error' => Validator::ERROR_INVALID_TYPE,
],
[
'$colType' => 'value',
'$productTypeModelsColType' => 'value',
'$colAttrSet' => null,
'$attrSetNameToIdColAttrSet' => 'value',
- '$error' => \Magento\CatalogImportExport\Model\Import\Product\Validator::ERROR_INVALID_ATTR_SET,
+ '$error' => Validator::ERROR_INVALID_ATTR_SET,
],
[
'$colType' => 'value',
'$productTypeModelsColType' => 'value',
'$colAttrSet' => 'value',
'$attrSetNameToIdColAttrSet' => null,
- '$error' => \Magento\CatalogImportExport\Model\Import\Product\Validator::ERROR_INVALID_ATTR_SET,
+ '$error' => Validator::ERROR_INVALID_ATTR_SET,
],
];
}
@@ -1462,15 +1503,15 @@ public function validateRowCheckSpecifiedSkuDataProvider()
return [
[
'$sku' => null,
- '$expectedError' => \Magento\CatalogImportExport\Model\Import\Product\Validator::ERROR_SKU_IS_EMPTY,
+ '$expectedError' => Validator::ERROR_SKU_IS_EMPTY,
],
[
'$sku' => false,
- '$expectedError' => \Magento\CatalogImportExport\Model\Import\Product\Validator::ERROR_ROW_IS_ORPHAN,
+ '$expectedError' => Validator::ERROR_ROW_IS_ORPHAN,
],
[
'$sku' => 'sku',
- '$expectedError' => \Magento\CatalogImportExport\Model\Import\Product\Validator::ERROR_INVALID_STORE,
+ '$expectedError' => Validator::ERROR_INVALID_STORE,
],
];
}
@@ -1761,9 +1802,8 @@ protected function overrideMethod(&$object, $methodName, array $parameters = [])
*
* @see _rewriteGetOptionEntityInImportProduct()
* @see _setValidatorMockInImportProduct()
- * @param Product
- * Param should go with rewritten getOptionEntity method.
- * @return \Magento\CatalogImportExport\Model\Import\Product\Option|MockObject
+ * @param Product Param should go with rewritten getOptionEntity method.
+ * @return Option|MockObject
*/
private function _suppressValidateRowOptionValidatorInvalidRows($importProduct)
{
@@ -1780,7 +1820,7 @@ private function _suppressValidateRowOptionValidatorInvalidRows($importProduct)
* Set validator mock in importProduct, return true for isValid method.
*
* @param Product
- * @return \Magento\CatalogImportExport\Model\Import\Product\Validator|MockObject
+ * @return Validator|MockObject
*/
private function _setValidatorMockInImportProduct($importProduct)
{
@@ -1794,13 +1834,12 @@ private function _setValidatorMockInImportProduct($importProduct)
* Used in group of validateRow method's tests.
* Make getOptionEntity return option mock.
*
- * @param Product
- * Param should go with rewritten getOptionEntity method.
- * @return \Magento\CatalogImportExport\Model\Import\Product\Option|MockObject
+ * @param Product Param should go with rewritten getOptionEntity method.
+ * @return Option|MockObject
*/
private function _rewriteGetOptionEntityInImportProduct($importProduct)
{
- $option = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\Option::class)
+ $option = $this->getMockBuilder(Option::class)
->disableOriginalConstructor()
->getMock();
$importProduct->expects($this->once())->method('getOptionEntity')->willReturn($option);
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php
index f10cf0364c545..aea5bf04e963f 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php
@@ -1,4 +1,4 @@
-coreFileStorageDb = $this->getMockBuilder(\Magento\MediaStorage\Helper\File\Storage\Database::class)
+ $this->coreFileStorageDb = $this->getMockBuilder(Database::class)
->disableOriginalConstructor()
->getMock();
- $this->coreFileStorage = $this->getMockBuilder(\Magento\MediaStorage\Helper\File\Storage::class)
+ $this->coreFileStorage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();
- $this->imageFactory = $this->getMockBuilder(\Magento\Framework\Image\AdapterFactory::class)
+ $this->imageFactory = $this->getMockBuilder(AdapterFactory::class)
->disableOriginalConstructor()
->getMock();
$this->validator = $this->getMockBuilder(
- \Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::class
+ NotProtectedExtension::class
)->disableOriginalConstructor()->getMock();
- $this->readFactory = $this->getMockBuilder(\Magento\Framework\Filesystem\File\ReadFactory::class)
+ $this->readFactory = $this->getMockBuilder(ReadFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
@@ -86,7 +100,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $this->filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class)
+ $this->filesystem = $this->getMockBuilder(Filesystem::class)
->disableOriginalConstructor()
->setMethods(['getDirectoryWrite'])
->getMock();
@@ -94,12 +108,12 @@ protected function setUp()
->method('getDirectoryWrite')
->will($this->returnValue($this->directoryMock));
- $this->random = $this->getMockBuilder(\Magento\Framework\Math\Random::class)
+ $this->random = $this->getMockBuilder(Random::class)
->disableOriginalConstructor()
->setMethods(['getRandomString'])
->getMock();
- $this->uploader = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Uploader::class)
+ $this->uploader = $this->getMockBuilder(Uploader::class)
->setConstructorArgs(
[
$this->coreFileStorageDb,
@@ -122,7 +136,7 @@ protected function setUp()
* @param $expectedHost
* @param $expectedFileName
* @param $checkAllowedExtension
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
public function testMoveFileUrl($fileUrl, $expectedHost, $expectedFileName, $checkAllowedExtension)
{
@@ -144,7 +158,7 @@ public function testMoveFileUrl($fileUrl, $expectedHost, $expectedFileName, $che
->with($tmpDir . '/' . $expectedFileName);
// Create adjusted reader which does not validate path.
- $readMock = $this->getMockBuilder(\Magento\Framework\Filesystem\File\Read::class)
+ $readMock = $this->getMockBuilder(Read::class)
->disableOriginalConstructor()
->setMethods(['readAll'])
->getMock();
@@ -206,13 +220,13 @@ public function testMoveFileName()
*/
public function testMoveFileUrlDrivePool($fileUrl, $expectedHost, $expectedDriverPool, $expectedScheme)
{
- $driverPool = $this->createPartialMock(\Magento\Framework\Filesystem\DriverPool::class, ['getDriver']);
+ $driverPool = $this->createPartialMock(DriverPool::class, ['getDriver']);
$driverMock = $this->createPartialMock($expectedDriverPool, ['readAll', 'isExists']);
$driverMock->expects($this->any())->method('isExists')->willReturn(true);
$driverMock->expects($this->any())->method('readAll')->willReturn(null);
$driverPool->expects($this->any())->method('getDriver')->willReturn($driverMock);
- $readFactory = $this->getMockBuilder(\Magento\Framework\Filesystem\File\ReadFactory::class)
+ $readFactory = $this->getMockBuilder(ReadFactory::class)
->setConstructorArgs(
[
$driverPool,
@@ -225,7 +239,7 @@ public function testMoveFileUrlDrivePool($fileUrl, $expectedHost, $expectedDrive
->with($expectedHost, $expectedScheme)
->willReturn($driverMock);
- $uploaderMock = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Uploader::class)
+ $uploaderMock = $this->getMockBuilder(Uploader::class)
->setConstructorArgs(
[
$this->coreFileStorageDb,
@@ -251,14 +265,14 @@ public function moveFileUrlDriverPoolDataProvider()
[
'$fileUrl' => 'http://test_uploader_file',
'$expectedHost' => 'test_uploader_file',
- '$expectedDriverPool' => \Magento\Framework\Filesystem\Driver\Http::class,
- '$expectedScheme' => \Magento\Framework\Filesystem\DriverPool::HTTP,
+ '$expectedDriverPool' => Http::class,
+ '$expectedScheme' => DriverPool::HTTP,
],
[
'$fileUrl' => 'https://!:^&`;file',
'$expectedHost' => '!:^&`;file',
- '$expectedDriverPool' => \Magento\Framework\Filesystem\Driver\Https::class,
- '$expectedScheme' => \Magento\Framework\Filesystem\DriverPool::HTTPS,
+ '$expectedDriverPool' => Https::class,
+ '$expectedScheme' => DriverPool::HTTPS,
],
];
}
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Flat/Plugin/ImportTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Flat/Plugin/ImportTest.php
index 1d2a12f863a6d..4e80e1b7cecf8 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Flat/Plugin/ImportTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Flat/Plugin/ImportTest.php
@@ -1,42 +1,47 @@
-processorMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Flat\Processor::class)
+ $this->processorMock = $this->getMockBuilder(Processor::class)
->disableOriginalConstructor()
->setMethods(['markIndexerAsInvalid', 'isIndexerScheduled'])
->getMock();
- $this->flatStateMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Flat\State::class)
+ $this->flatStateMock = $this->getMockBuilder(State::class)
->disableOriginalConstructor()
->setMethods(['isFlatEnabled'])
->getMock();
@@ -46,7 +51,7 @@ protected function setUp()
->getMock();
$this->model = (new ObjectManager($this))->getObject(
- \Magento\CatalogImportExport\Model\Indexer\Product\Flat\Plugin\Import::class,
+ Import::class,
[
'productFlatIndexerProcessor' => $this->processorMock,
'flatState' => $this->flatStateMock
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php
index 74aac0c264bdf..790c94e55813e 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php
@@ -1,47 +1,55 @@
-_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->_objectManager = new ObjectManager($this);
$this->_indexerMock = $this->createPartialMock(
- \Magento\Indexer\Model\Indexer::class,
+ Indexer::class,
['getId', 'invalidate', 'getPriceIndexer', 'isScheduled']
);
$this->indexerRegistryMock = $this->createPartialMock(
- \Magento\Framework\Indexer\IndexerRegistry::class,
+ IndexerRegistry::class,
['get']
);
$this->_model = $this->_objectManager->getObject(
- \Magento\CatalogImportExport\Model\Indexer\Product\Price\Plugin\Import::class,
+ Import::class,
['indexerRegistry' => $this->indexerRegistryMock]
);
}
@@ -54,7 +62,7 @@ public function testAfterImportSource()
$this->_indexerMock->expects($this->once())->method('invalidate');
$this->indexerRegistryMock->expects($this->any())
->method('get')
- ->with(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID)
+ ->with(Processor::INDEXER_ID)
->will($this->returnValue($this->_indexerMock));
$this->_indexerMock->expects($this->any())
->method('isScheduled')
diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Stock/Plugin/ImportTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Stock/Plugin/ImportTest.php
index 9de2d5cd00837..fbcbb34d2b3ee 100644
--- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Stock/Plugin/ImportTest.php
+++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Stock/Plugin/ImportTest.php
@@ -1,11 +1,15 @@
-createPartialMock(
- \Magento\CatalogInventory\Model\Indexer\Stock\Processor::class,
+ Processor::class,
['markIndexerAsInvalid', 'isIndexerScheduled']
);
- $subjectMock = $this->createMock(\Magento\ImportExport\Model\Import::class);
+ $subjectMock = $this->createMock(Import::class);
$processorMock->expects($this->any())->method('markIndexerAsInvalid');
$processorMock->expects($this->any())->method('isIndexerScheduled')->willReturn(false);
diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php
index 659f7346faba4..7ba617485a797 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php
+++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php
@@ -10,7 +10,7 @@
class CustomOptionsTest extends AbstractModifierTest
{
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->arrayManagerMock->expects($this->any())
diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionDuringMediaAssetInitializationTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionDuringMediaAssetInitializationTest.php
index f62649348acea..3fd4044a021c2 100644
--- a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionDuringMediaAssetInitializationTest.php
+++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionDuringMediaAssetInitializationTest.php
@@ -7,7 +7,6 @@
namespace Magento\MediaGallery\Test\Unit\Model\Asset\Command;
-use Laminas\Db\Adapter\Driver\Pdo\Statement;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Select;
diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php
index 6f82d2f2a5cb3..e0060b65f070f 100644
--- a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php
+++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php
@@ -7,16 +7,16 @@
namespace Magento\MediaGallery\Test\Unit\Model\Asset\Command;
-use Magento\MediaGallery\Model\Asset\Command\Save;
-use Magento\MediaGalleryApi\Api\Data\AssetInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Adapter\Pdo\Mysql;
use Magento\Framework\Exception\CouldNotSaveException;
+use Magento\Framework\Reflection\DataObjectProcessor;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\MediaGallery\Model\Asset\Command\Save;
+use Magento\MediaGalleryApi\Api\Data\AssetInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
-use Magento\Framework\Reflection\DataObjectProcessor;
use Psr\Log\LoggerInterface;
/**
diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php
index 37fdf71722030..ec4174f88bfc5 100644
--- a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php
+++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php
@@ -56,7 +56,7 @@ protected function setUp(): void
/**
* Posive test for the main case
*
- * @dataProvider casesProvider()
+ * @dataProvider casesProvider
* @param array $databaseQueryResult
* @param int $expectedNumberOfFoundKeywords
*/
@@ -80,31 +80,17 @@ public function testFind(array $databaseQueryResult, int $expectedNumberOfFoundK
public function casesProvider(): array
{
return [
- 'not_found' => [
- [],
- 0
- ],
+ 'not_found' => [[],0],
'find_one_keyword' => [
- [
- [
- 'id' => 1,
- 'keyword' => 'keywordRawData'
- ]
- ],
- 1
+ 'result' => [['id' => 1, 'keyword' => 'keywordRawData']],
+ 'expectedCount' => 1
],
'find_several_keywords' => [
- [
- [
- 'id' => 1,
- 'keyword' => 'keywordRawData'
- ],
- [
- 'id' => 2,
- 'keyword' => 'keywordRawData2'
- ]
+ 'results' => [
+ ['id' => 1, 'keyword'=> 'keywordRawData'],
+ ['id' => 2, 'keyword' => 'keywordRawData']
],
- 2
+ 'expectedCount' => 2
],
];
}