Skip to content

Commit

Permalink
#27500 Fix static checks
Browse files Browse the repository at this point in the history
  • Loading branch information
lbajsarowicz committed Apr 12, 2020
1 parent 5d2fd3d commit a09b56d
Show file tree
Hide file tree
Showing 26 changed files with 60 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;

Expand Down Expand Up @@ -91,10 +92,10 @@ 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(Option::class)
->will($this->returnValue($optionsBlock));
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Catalog/Test/Unit/Block/NavigationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class NavigationTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AbstractProductTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ToolbarTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
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;
Expand Down Expand Up @@ -70,7 +71,7 @@ public function testGetOptionHtml()
\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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Magento\Catalog\Helper\Data;
use Magento\Catalog\Helper\Image;
use Magento\Catalog\Model\CategoryFactory;
use Magento\catalog\Model\Product;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Category\Collection;
use Magento\Catalog\Model\ResourceModel\Category\Tree;
use Magento\Customer\Model\Session;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,18 @@ public function testExecute($categoryId, $storeId, $parentId)
$postData['store_id'] = $storeId;
}
/**
* @var Redirect
* |\PHPUnit_Framework_MockObject_MockObject $resultRedirectMock
* @var Redirect|MockObject $resultRedirectMock
*/
$resultRedirectMock = $this->createMock(Redirect::class);
/**
* @var Messages
* |\PHPUnit_Framework_MockObject_MockObject $blockMock
* @var Messages|MockObject $blockMock
*/
$blockMock = $this->createPartialMock(
Messages::class,
['setMessages', 'getGroupedHtml']
);
/**
* @var \Magento\Catalog\Model\Category
* |\PHPUnit_Framework_MockObject_MockObject $categoryMock
* @var \Magento\Catalog\Model\Category|MockObject $categoryMock
*/
$categoryMock = $this->createPartialMock(Category::class, [
'setStoreId',
Expand All @@ -204,8 +201,7 @@ 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(Category::class, [
'setStoreId',
Expand All @@ -222,23 +218,19 @@ public function testExecute($categoryId, $storeId, $parentId)
'getId'
]);
/**
* @var Session
* |\PHPUnit_Framework_MockObject_MockObject $sessionMock
* @var Session|MockObject $sessionMock
*/
$sessionMock = $this->createMock(Session::class);
/**
* @var Registry
* |\PHPUnit_Framework_MockObject_MockObject $registryMock
* @var Registry|MockObject $registryMock
*/
$registryMock = $this->createPartialMock(Registry::class, ['register']);
/**
* @var Config
* |\PHPUnit_Framework_MockObject_MockObject $wysiwygConfigMock
* @var Config|MockObject $wysiwygConfigMock
*/
$wysiwygConfigMock = $this->createPartialMock(Config::class, ['setStoreId']);
/**
* @var StoreManagerInterface
* |\PHPUnit_Framework_MockObject_MockObject $storeManagerMock
* @var StoreManagerInterface|MockObject $storeManagerMock
*/
$storeManagerMock = $this->getMockForAbstractClass(
StoreManagerInterface::class,
Expand All @@ -250,8 +242,7 @@ public function testExecute($categoryId, $storeId, $parentId)
['getStore', 'getRootCategoryId']
);
/**
* @var Layout
* |\PHPUnit_Framework_MockObject_MockObject $layoutMock
* @var Layout|MockObject $layoutMock
*/
$layoutMock = $this->getMockForAbstractClass(
Layout::class,
Expand All @@ -263,13 +254,11 @@ public function testExecute($categoryId, $storeId, $parentId)
['getMessagesBlock']
);
/**
* @var Json
* |\PHPUnit_Framework_MockObject_MockObject $resultJsonMock
* @var Json|MockObject $resultJsonMock
*/
$resultJsonMock = $this->createPartialMock(Config::class, ['setData']);
/**
* @var Collection
* |\PHPUnit_Framework_MockObject_MockObject $messagesMock
* @var Collection|MockObject $messagesMock
*/
$messagesMock = $this->createMock(Collection::class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ protected function initContext(array $additionalParams = [], array $objectManage
$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(Http::class)->setMethods(
['getParam', 'getPost', 'getFullActionName', 'getPostValue']
)->disableOriginalConstructor()->getMock();
Expand Down Expand Up @@ -112,7 +109,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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ class ProductFrontendActionSectionTest extends TestCase
/** @var MockObject */
protected $synchronizerMock;

/** @var \SafeReflectionClass|MockObject */
protected $safeReflectionClassMock;

/** @var Config|MockObject */
private $appConfigMock;

Expand All @@ -36,9 +33,6 @@ protected function setUp(): void
->getMockBuilder(Synchronizer::class)
->disableOriginalConstructor()
->getMock();
$this->safeReflectionClassMock = $this->getMockBuilder(\SafeReflectionClass::class)
->disableOriginalConstructor()
->getMock();
$this->appConfigMock = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ImageTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class TreeTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CategoryLinkManagementTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CategoryManagementTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class CustomOptionProcessorTest extends TestCase
protected $extensionFactory;

/**
* @var CustomOptionFactory
* |\PHPUnit_Framework_MockObject_MockObject
* @var CustomOptionFactory|MockObject
*/
protected $customOptionFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CategoryTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@

class EavTest extends TestCase
{
/**
* @var Eav
*/
protected $_model;

/**
* @var Row|MockObject
*/
Expand All @@ -41,6 +36,10 @@ class EavTest extends TestCase
* @var CacheContext|MockObject
*/
protected $cacheContextMock;
/**
* @var Eav
*/
private $model;

protected function setUp(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ActionTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class ImageEntryConverterTest extends TestCase
protected $mediaGalleryEntryMock;

/**
* @var DataObjectHelper
* |\PHPUnit_Framework_MockObject_MockObject
* @var DataObjectHelper|MockObject
*/
protected $dataObjectHelperMock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
class TierpriceTest extends TestCase
{
/**
* @var Tierprice
* |\PHPUnit_Framework_MockObject_MockObject
* @var Tierprice|MockObject
*/
private $productAttributeBackendTierprice;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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 TestCase
Expand All @@ -20,8 +21,7 @@ class LayoutTest extends TestCase
/** @var ObjectManagerHelper */
protected $objectManagerHelper;

/** @var BuilderInterface
* |\PHPUnit_Framework_MockObject_MockObject */
/** @var BuilderInterface|MockObject */
protected $pageLayoutBuilder;

protected function setUp(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

/**
* Unit test for catalog product Media Gallery attribute processor.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ProcessorTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function setUp(): void
{
$this->productRepositoryMock = $this->createMock(ProductRepository::class);
$this->optionResourceMock = $this->createMock(Option::class);
$this->converterMock = $this->createMock(Converter::class);
$converterMock = $this->createMock(Converter::class);
$this->optionMock = $this->createMock(\Magento\Catalog\Model\Product\Option::class);
$this->productMock = $this->createMock(Product::class);
$optionFactory = $this->createPartialMock(OptionFactory::class, ['create']);
Expand All @@ -78,7 +78,7 @@ protected function setUp(): void
$this->optionRepository = new Repository(
$this->productRepositoryMock,
$this->optionResourceMock,
$this->converterMock,
$converterMock,
$this->optionCollectionFactory,
$optionFactory,
$metadataPool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class BasePriceStorageTest extends TestCase
private $storeRepository;

/**
* @var InvalidSkuProcessor
* |\PHPUnit_Framework_MockObject_MockObject
* @var InvalidSkuProcessor|MockObject
*/
private $invalidSkuProcessor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class CostStorageTest extends TestCase
private $storeRepository;

/**
* @var InvalidSkuProcessor
* |\PHPUnit_Framework_MockObject_MockObject
* @var InvalidSkuProcessor|MockObject
*/
private $invalidSkuProcessor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class SpecialPriceStorageTest extends TestCase
private $storeRepository;

/**
* @var InvalidSkuProcessor
* |\PHPUnit_Framework_MockObject_MockObject
* @var InvalidSkuProcessor|MockObject
*/
private $invalidSkuProcessor;

Expand Down
Loading

0 comments on commit a09b56d

Please sign in to comment.