Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -83,7 +85,7 @@ class ProductTest extends TestCase
protected $attrSetColFactory;

/**
* @var \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory|MockObject
* @var CategoryCollectionFactory|MockObject
*/
protected $categoryColFactory;

Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
Expand Down Expand Up @@ -26,34 +27,26 @@
*/
class ExternalVideoEntryConverterTest extends TestCase
{
/**
* @var MockObject|ProductAttributeMediaGalleryEntryInterfaceFactory
*/
protected $mediaGalleryEntryFactoryMock;
/** @var MockObject|ProductAttributeMediaGalleryEntryInterfaceFactory */
private $mediaGalleryEntryFactoryMock;

/**
* @var MockObject|ProductAttributeMediaGalleryEntryInterface
*/
protected $mediaGalleryEntryMock;
/** @var MockObject|ProductAttributeMediaGalleryEntryInterface */
private $mediaGalleryEntryMock;

/** @var MockObject|DataObjectHelper */
protected $dataObjectHelperMock;
private $dataObjectHelperMock;

/** @var MockObject|VideoContentInterfaceFactory */
protected $videoEntryFactoryMock;
private $videoEntryFactoryMock;

/** @var MockObject|VideoContentInterface */
protected $videoEntryMock;
private $videoEntryMock;

/**
* @var MockObject|ProductAttributeMediaGalleryEntryExtensionFactory
*/
protected $mediaGalleryEntryExtensionFactoryMock;
/** @var MockObject|ProductAttributeMediaGalleryEntryExtensionFactory */
private $mediaGalleryEntryExtensionFactoryMock;

/**
* @var MockObject|ProductAttributeMediaGalleryEntryExtensionFactory
*/
protected $mediaGalleryEntryExtensionMock;
/** @var MockObject|ProductAttributeMediaGalleryEntryExtension */
private $mediaGalleryEntryExtensionMock;

/**
* @var ObjectManager|ExternalVideoEntryConverter
Expand All @@ -62,33 +55,35 @@ class ExternalVideoEntryConverterTest extends TestCase

protected function setUp(): void
{
$this->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
Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
}

/**
Expand Down Expand Up @@ -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));
Expand Down