Skip to content

Commit 9d5aa22

Browse files
ENGCOM-7632: Upgrade PHPUnit and fix failing / warnings in tests #28599
- Merge Pull Request #28599 from lbajsarowicz/magento2:feature/failed-patch-information - Merged commits: 1. 415291b 2. fd7cecb 3. 246dd8c 4. 8911d03 5. 7a108aa 6. 17ae2d9 7. f8f53e4 8. d1d6610 9. 8671601
2 parents a360c06 + 8671601 commit 9d5aa22

File tree

4 files changed

+65
-71
lines changed

4 files changed

+65
-71
lines changed

app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
namespace Magento\CatalogImportExport\Test\Unit\Model\Export;
99

1010
use Magento\Catalog\Model\Product\LinkTypeProvider;
11+
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
1112
use Magento\CatalogImportExport\Model\Export\Product;
1213
use Magento\CatalogImportExport\Model\Export\Product\Type\Factory;
1314
use Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite;
1415
use Magento\Eav\Model\Config;
1516
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
1617
use Magento\Eav\Model\Entity\Type;
18+
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory as AttributeSetCollectionFactory;
1719
use Magento\Framework\App\ResourceConnection;
1820
use Magento\Framework\EntityManager\MetadataPool;
1921
use Magento\Framework\Logger\Monolog;
@@ -83,7 +85,7 @@ class ProductTest extends TestCase
8385
protected $attrSetColFactory;
8486

8587
/**
86-
* @var \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory|MockObject
88+
* @var CategoryCollectionFactory|MockObject
8789
*/
8890
protected $categoryColFactory;
8991

@@ -174,15 +176,14 @@ protected function setUp(): void
174176
->onlyMethods(['create'])
175177
->getMock();
176178

177-
$this->attrSetColFactory = $this->getMockBuilder(
178-
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class
179-
)->addMethods(['setEntityTypeFilter'])
179+
$this->attrSetColFactory = $this->getMockBuilder(AttributeSetCollectionFactory::class)
180+
->disableOriginalConstructor()
181+
->addMethods(['setEntityTypeFilter'])
180182
->onlyMethods(['create'])
181183
->getMock();
182184

183-
$this->categoryColFactory = $this->getMockBuilder(
184-
\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class
185-
)->addMethods(['addNameToResult'])
185+
$this->categoryColFactory = $this->getMockBuilder(CategoryCollectionFactory::class)
186+
->disableOriginalConstructor()->addMethods(['addNameToResult'])
186187
->onlyMethods(['create'])
187188
->getMock();
188189

app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testExecuteBadType()
4646
->with(
4747
$this->equalTo(['urn:magento:framework:Module/etc/module.xsd' => $fixtureXmlFile]),
4848
$this->equalTo('test')
49-
)->willReturn(null);
49+
);
5050

5151
$formats = ['phpstorm' => $phpstormFormatMock];
5252
$readFactory = $this->createMock(ReadFactory::class);

app/code/Magento/ProductVideo/Test/Unit/Model/Product/Attribute/Media/ExternalVideoEntryConverterTest.php

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
@@ -26,34 +27,26 @@
2627
*/
2728
class ExternalVideoEntryConverterTest extends TestCase
2829
{
29-
/**
30-
* @var MockObject|ProductAttributeMediaGalleryEntryInterfaceFactory
31-
*/
32-
protected $mediaGalleryEntryFactoryMock;
30+
/** @var MockObject|ProductAttributeMediaGalleryEntryInterfaceFactory */
31+
private $mediaGalleryEntryFactoryMock;
3332

34-
/**
35-
* @var MockObject|ProductAttributeMediaGalleryEntryInterface
36-
*/
37-
protected $mediaGalleryEntryMock;
33+
/** @var MockObject|ProductAttributeMediaGalleryEntryInterface */
34+
private $mediaGalleryEntryMock;
3835

3936
/** @var MockObject|DataObjectHelper */
40-
protected $dataObjectHelperMock;
37+
private $dataObjectHelperMock;
4138

4239
/** @var MockObject|VideoContentInterfaceFactory */
43-
protected $videoEntryFactoryMock;
40+
private $videoEntryFactoryMock;
4441

4542
/** @var MockObject|VideoContentInterface */
46-
protected $videoEntryMock;
43+
private $videoEntryMock;
4744

48-
/**
49-
* @var MockObject|ProductAttributeMediaGalleryEntryExtensionFactory
50-
*/
51-
protected $mediaGalleryEntryExtensionFactoryMock;
45+
/** @var MockObject|ProductAttributeMediaGalleryEntryExtensionFactory */
46+
private $mediaGalleryEntryExtensionFactoryMock;
5247

53-
/**
54-
* @var MockObject|ProductAttributeMediaGalleryEntryExtensionFactory
55-
*/
56-
protected $mediaGalleryEntryExtensionMock;
48+
/** @var MockObject|ProductAttributeMediaGalleryEntryExtension */
49+
private $mediaGalleryEntryExtensionMock;
5750

5851
/**
5952
* @var ObjectManager|ExternalVideoEntryConverter
@@ -62,33 +55,35 @@ class ExternalVideoEntryConverterTest extends TestCase
6255

6356
protected function setUp(): void
6457
{
65-
$this->mediaGalleryEntryFactoryMock =
66-
$this->createPartialMock(
67-
ProductAttributeMediaGalleryEntryInterfaceFactory::class,
68-
['create']
69-
);
58+
$this->mediaGalleryEntryFactoryMock = $this->createPartialMock(
59+
ProductAttributeMediaGalleryEntryInterfaceFactory::class,
60+
['create']
61+
);
7062

7163
$this->mediaGalleryEntryMock =
72-
$this->createPartialMock(ProductAttributeMediaGalleryEntryInterface::class, [
73-
'getId',
74-
'setId',
75-
'getMediaType',
76-
'setMediaType',
77-
'getLabel',
78-
'setLabel',
79-
'getPosition',
80-
'setPosition',
81-
'isDisabled',
82-
'setDisabled',
83-
'getTypes',
84-
'setTypes',
85-
'getFile',
86-
'setFile',
87-
'getContent',
88-
'setContent',
89-
'getExtensionAttributes',
90-
'setExtensionAttributes'
91-
]);
64+
$this->createPartialMock(
65+
ProductAttributeMediaGalleryEntryInterface::class,
66+
[
67+
'getId',
68+
'setId',
69+
'getMediaType',
70+
'setMediaType',
71+
'getLabel',
72+
'setLabel',
73+
'getPosition',
74+
'setPosition',
75+
'isDisabled',
76+
'setDisabled',
77+
'getTypes',
78+
'setTypes',
79+
'getFile',
80+
'setFile',
81+
'getContent',
82+
'setContent',
83+
'getExtensionAttributes',
84+
'setExtensionAttributes'
85+
]
86+
);
9287

9388
$this->mediaGalleryEntryFactoryMock->expects($this->any())->method('create')->willReturn(
9489
$this->mediaGalleryEntryMock
@@ -110,7 +105,8 @@ protected function setUp(): void
110105
);
111106

112107
$this->mediaGalleryEntryExtensionMock = $this->getMockBuilder(ProductAttributeMediaGalleryEntryExtension::class)
113-
->addMethods(['getVideoProvider', 'setVideoContent', 'getVideoContent'])
108+
->addMethods(['getVideoProvider'])
109+
->onlyMethods(['setVideoContent', 'getVideoContent'])
114110
->disableOriginalConstructor()
115111
->getMock();
116112

app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,16 @@
3232
*/
3333
class SubtotalTest extends TestCase
3434
{
35-
/**
36-
* @var ObjectManager
37-
*/
35+
/** @var ObjectManager */
3836
protected $objectManager;
3937

40-
/**
41-
* @var Subtotal
42-
*/
38+
/** @var Subtotal */
4339
protected $subtotalModel;
4440

4541
/** @var MockObject */
4642
protected $stockItemMock;
4743

48-
/**
49-
* @var MockObject
50-
*/
44+
/** @var MockObject */
5145
protected $stockRegistry;
5246

5347
protected function setUp(): void
@@ -57,14 +51,15 @@ protected function setUp(): void
5751
Subtotal::class
5852
);
5953

60-
$this->stockRegistry = $this->createPartialMock(
61-
StockRegistry::class,
62-
['getStockItem']
63-
);
64-
$this->stockItemMock = $this->createPartialMock(
65-
\Magento\CatalogInventory\Model\Stock\Item::class,
66-
['getIsInStock', '__wakeup']
67-
);
54+
$this->stockRegistry = $this->getMockBuilder(StockRegistry::class)
55+
->disableOriginalConstructor()
56+
->addMethods(['__wakeup'])
57+
->onlyMethods(['getStockItem'])
58+
->getMock();
59+
$this->stockItemMock = $this->getMockBuilder(\Magento\CatalogInventory\Model\Stock\Item::class)
60+
->disableOriginalConstructor()
61+
->onlyMethods(['getIsInStock', '__wakeup'])
62+
->getMock();
6863
}
6964

7065
/**
@@ -188,7 +183,9 @@ public function testFetch()
188183
$quoteMock = $this->createMock(Quote::class);
189184
$totalMock = $this->getMockBuilder(Total::class)
190185
->addMethods(['getSubtotal'])
191-
->getMockForAbstractClass();
186+
->disableOriginalConstructor()
187+
->getMock();
188+
192189
$totalMock->expects($this->once())->method('getSubtotal')->willReturn(100);
193190

194191
$this->assertEquals($expectedResult, $this->subtotalModel->fetch($quoteMock, $totalMock));

0 commit comments

Comments
 (0)