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 bf1d3772b92a0..1ad82497119ba 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php @@ -8,12 +8,14 @@ namespace Magento\CatalogImportExport\Test\Unit\Model\Export; use Magento\Catalog\Model\Product\LinkTypeProvider; +use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory; use Magento\CatalogImportExport\Model\Export\Product; use Magento\CatalogImportExport\Model\Export\Product\Type\Factory; use Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite; use Magento\Eav\Model\Config; use Magento\Eav\Model\Entity\Collection\AbstractCollection; use Magento\Eav\Model\Entity\Type; +use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory as AttributeSetCollectionFactory; use Magento\Framework\App\ResourceConnection; use Magento\Framework\EntityManager\MetadataPool; use Magento\Framework\Logger\Monolog; @@ -83,7 +85,7 @@ class ProductTest extends TestCase protected $attrSetColFactory; /** - * @var \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory|MockObject + * @var CategoryCollectionFactory|MockObject */ protected $categoryColFactory; @@ -174,15 +176,14 @@ protected function setUp(): void ->onlyMethods(['create']) ->getMock(); - $this->attrSetColFactory = $this->getMockBuilder( - \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class - )->addMethods(['setEntityTypeFilter']) + $this->attrSetColFactory = $this->getMockBuilder(AttributeSetCollectionFactory::class) + ->disableOriginalConstructor() + ->addMethods(['setEntityTypeFilter']) ->onlyMethods(['create']) ->getMock(); - $this->categoryColFactory = $this->getMockBuilder( - \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class - )->addMethods(['addNameToResult']) + $this->categoryColFactory = $this->getMockBuilder(CategoryCollectionFactory::class) + ->disableOriginalConstructor()->addMethods(['addNameToResult']) ->onlyMethods(['create']) ->getMock(); diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php index a9e42cd01f2d5..152bdfef376fb 100644 --- a/app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php @@ -46,7 +46,7 @@ public function testExecuteBadType() ->with( $this->equalTo(['urn:magento:framework:Module/etc/module.xsd' => $fixtureXmlFile]), $this->equalTo('test') - )->willReturn(null); + ); $formats = ['phpstorm' => $phpstormFormatMock]; $readFactory = $this->createMock(ReadFactory::class); diff --git a/app/code/Magento/ProductVideo/Test/Unit/Model/Product/Attribute/Media/ExternalVideoEntryConverterTest.php b/app/code/Magento/ProductVideo/Test/Unit/Model/Product/Attribute/Media/ExternalVideoEntryConverterTest.php index 3ca043e205e87..a921bff76c8d6 100644 --- a/app/code/Magento/ProductVideo/Test/Unit/Model/Product/Attribute/Media/ExternalVideoEntryConverterTest.php +++ b/app/code/Magento/ProductVideo/Test/Unit/Model/Product/Attribute/Media/ExternalVideoEntryConverterTest.php @@ -1,4 +1,5 @@ mediaGalleryEntryFactoryMock = - $this->createPartialMock( - ProductAttributeMediaGalleryEntryInterfaceFactory::class, - ['create'] - ); + $this->mediaGalleryEntryFactoryMock = $this->createPartialMock( + ProductAttributeMediaGalleryEntryInterfaceFactory::class, + ['create'] + ); $this->mediaGalleryEntryMock = - $this->createPartialMock(ProductAttributeMediaGalleryEntryInterface::class, [ - 'getId', - 'setId', - 'getMediaType', - 'setMediaType', - 'getLabel', - 'setLabel', - 'getPosition', - 'setPosition', - 'isDisabled', - 'setDisabled', - 'getTypes', - 'setTypes', - 'getFile', - 'setFile', - 'getContent', - 'setContent', - 'getExtensionAttributes', - 'setExtensionAttributes' - ]); + $this->createPartialMock( + ProductAttributeMediaGalleryEntryInterface::class, + [ + 'getId', + 'setId', + 'getMediaType', + 'setMediaType', + 'getLabel', + 'setLabel', + 'getPosition', + 'setPosition', + 'isDisabled', + 'setDisabled', + 'getTypes', + 'setTypes', + 'getFile', + 'setFile', + 'getContent', + 'setContent', + 'getExtensionAttributes', + 'setExtensionAttributes' + ] + ); $this->mediaGalleryEntryFactoryMock->expects($this->any())->method('create')->willReturn( $this->mediaGalleryEntryMock @@ -110,7 +105,8 @@ protected function setUp(): void ); $this->mediaGalleryEntryExtensionMock = $this->getMockBuilder(ProductAttributeMediaGalleryEntryExtension::class) - ->addMethods(['getVideoProvider', 'setVideoContent', 'getVideoContent']) + ->addMethods(['getVideoProvider']) + ->onlyMethods(['setVideoContent', 'getVideoContent']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php index 3cc586096d4a0..426fa6183fec2 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php @@ -32,22 +32,16 @@ */ class SubtotalTest extends TestCase { - /** - * @var ObjectManager - */ + /** @var ObjectManager */ protected $objectManager; - /** - * @var Subtotal - */ + /** @var Subtotal */ protected $subtotalModel; /** @var MockObject */ protected $stockItemMock; - /** - * @var MockObject - */ + /** @var MockObject */ protected $stockRegistry; protected function setUp(): void @@ -57,14 +51,15 @@ protected function setUp(): void Subtotal::class ); - $this->stockRegistry = $this->createPartialMock( - StockRegistry::class, - ['getStockItem'] - ); - $this->stockItemMock = $this->createPartialMock( - \Magento\CatalogInventory\Model\Stock\Item::class, - ['getIsInStock', '__wakeup'] - ); + $this->stockRegistry = $this->getMockBuilder(StockRegistry::class) + ->disableOriginalConstructor() + ->addMethods(['__wakeup']) + ->onlyMethods(['getStockItem']) + ->getMock(); + $this->stockItemMock = $this->getMockBuilder(\Magento\CatalogInventory\Model\Stock\Item::class) + ->disableOriginalConstructor() + ->onlyMethods(['getIsInStock', '__wakeup']) + ->getMock(); } /** @@ -188,7 +183,9 @@ public function testFetch() $quoteMock = $this->createMock(Quote::class); $totalMock = $this->getMockBuilder(Total::class) ->addMethods(['getSubtotal']) - ->getMockForAbstractClass(); + ->disableOriginalConstructor() + ->getMock(); + $totalMock->expects($this->once())->method('getSubtotal')->willReturn(100); $this->assertEquals($expectedResult, $this->subtotalModel->fetch($quoteMock, $totalMock));