Skip to content

Commit 3e514a0

Browse files
committed
Merge remote-tracking branch 'origin/AC-10634-ce' into AC-10821
2 parents fffba20 + c9aef73 commit 3e514a0

File tree

25 files changed

+149
-126
lines changed

25 files changed

+149
-126
lines changed

app/code/Magento/Catalog/Test/Unit/Model/Config/Source/CategoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function setUp(): void
4040
->getMock();
4141

4242
$this->category = $this->getMockBuilder(Category::class)
43-
->setMethods(['getName', 'getId'])
43+
->addMethods(['getName', 'getId'])
4444
->disableOriginalConstructor()
4545
->getMock();
4646

@@ -49,7 +49,7 @@ protected function setUp(): void
4949
*/
5050
$categoryCollectionFactory =
5151
$this->getMockBuilder(CollectionFactory::class)
52-
->setMethods(['create'])
52+
->onlyMethods(['create'])
5353
->disableOriginalConstructor()
5454
->getMock();
5555
$categoryCollectionFactory->expects($this->any())->method('create')->willReturn(

app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionProcessorTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,32 +72,33 @@ class CustomOptionProcessorTest extends TestCase
7272
protected function setUp(): void
7373
{
7474
$this->objectFactory = $this->getMockBuilder(Factory::class)
75-
->setMethods(['create'])
75+
->onlyMethods(['create'])
7676
->disableOriginalConstructor()
7777
->getMock();
7878
$this->productOptionFactory = $this->getMockBuilder(ProductOptionFactory::class)
79-
->setMethods(['create'])
79+
->onlyMethods(['create'])
8080
->disableOriginalConstructor()
8181
->getMock();
8282
$this->extensionFactory = $this->getMockBuilder(ProductOptionExtensionFactory::class)
83-
->setMethods(['create'])
83+
->onlyMethods(['create'])
8484
->disableOriginalConstructor()
8585
->getMock();
8686
$this->customOptionFactory = $this->getMockBuilder(
8787
CustomOptionFactory::class
8888
)
89-
->setMethods(['create'])
89+
->onlyMethods(['create'])
9090
->disableOriginalConstructor()
9191
->getMock();
9292
$this->cartItem = $this->getMockBuilder(CartItemInterface::class)
9393
->disableOriginalConstructor()
94-
->setMethods(['getOptionByCode', 'getProductOption', 'setProductOption'])
94+
->addMethods(['getOptionByCode'])
95+
->onlyMethods(['getProductOption', 'setProductOption'])
9596
->getMockForAbstractClass();
9697
$this->extensibleAttribute = $this->getMockBuilder(
9798
ProductOptionExtensionInterface::class
9899
)
99100
->disableOriginalConstructor()
100-
->setMethods(['setCustomOptions', 'getCustomOptions'])
101+
->addMethods(['setCustomOptions', 'getCustomOptions'])
101102
->getMockForAbstractClass();
102103
$this->productOption = $this->getMockBuilder(ProductOption::class)
103104
->disableOriginalConstructor()
@@ -109,7 +110,7 @@ protected function setUp(): void
109110
->disableOriginalConstructor()
110111
->getMock();
111112
$this->serializer = $this->getMockBuilder(Json::class)
112-
->setMethods(['unserialize'])
113+
->onlyMethods(['unserialize'])
113114
->getMockForAbstractClass();
114115

115116
$this->processor = new CustomOptionProcessor(

app/code/Magento/Catalog/Test/Unit/Model/CustomOptions/CustomOptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function setUp(): void
7272
->getMock();
7373

7474
$this->extensionMock = $this->getMockBuilder(CustomOptionExtensionInterface::class)
75-
->setMethods(['getFileInfo'])
75+
->addMethods(['getFileInfo'])
7676
->getMockForAbstractClass();
7777

7878
$this->extensionAttributesFactoryMock->expects(self::any())

app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Plugin/StoreViewTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ protected function setUp(): void
4646

4747
$this->objectMock = $this->getMockBuilder(AbstractModel::class)
4848
->disableOriginalConstructor()
49-
->setMethods(['getId', 'dataHasChangedFor', 'getIsActive'])
49+
->addMethods(['getIsActive'])
50+
->onlyMethods(['getId', 'dataHasChangedFor'])
5051
->getMock();
5152

5253
$this->storeViewPlugin = new StoreView($this->eavProcessorMock);
@@ -85,7 +86,7 @@ public function testAfterSave(array $data): void
8586
/**
8687
* @return array
8788
*/
88-
public function beforeSaveDataProvider(): array
89+
public static function beforeSaveDataProvider(): array
8990
{
9091
return [
9192
[

app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,26 @@ protected function setUp(): void
4848
{
4949
$this->productCollection = $this->getMockBuilder(Collection::class)
5050
->disableOriginalConstructor()
51-
->setMethods(['getMaxPrice'])
51+
->onlyMethods(['getMaxPrice'])
5252
->getMock();
5353
$this->layer = $this->getMockBuilder(Layer::class)
5454
->disableOriginalConstructor()
55-
->setMethods(['getProductCollection'])
55+
->onlyMethods(['getProductCollection'])
5656
->getMock();
5757
$this->layer->expects($this->any())
5858
->method('getProductCollection')
5959
->willReturn($this->productCollection);
6060
$this->coreRegistry = $this->getMockBuilder(Registry::class)
6161
->disableOriginalConstructor()
62-
->setMethods(['registry'])
62+
->onlyMethods(['registry'])
6363
->getMock();
6464
$this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
6565
->disableOriginalConstructor()
66-
->setMethods(['getValue'])
66+
->onlyMethods(['getValue'])
6767
->getMockForAbstractClass();
6868
$this->resource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Layer\Filter\Price::class)
6969
->disableOriginalConstructor()
70-
->setMethods(['getCount'])
70+
->onlyMethods(['getCount'])
7171
->getMock();
7272
$objectManagerHelper = new ObjectManagerHelper($this);
7373
$this->target = $objectManagerHelper->getObject(
@@ -117,7 +117,7 @@ public function testGetPriceRangeWithRangeInFilter()
117117
/** @var Category|MockObject $category */
118118
$category = $this->getMockBuilder(Category::class)
119119
->disableOriginalConstructor()
120-
->setMethods(['getFilterPriceRange'])
120+
->addMethods(['getFilterPriceRange'])
121121
->getMock();
122122
$priceRange = 10;
123123
$category->expects($this->once())
@@ -135,7 +135,7 @@ public function testGetPriceRangeWithRangeCalculation()
135135
/** @var Category|MockObject $category */
136136
$category = $this->getMockBuilder(Category::class)
137137
->disableOriginalConstructor()
138-
->setMethods(['getFilterPriceRange'])
138+
->addMethods(['getFilterPriceRange'])
139139
->getMock();
140140
$priceRange = 0;
141141
$category->expects($this->once())
@@ -174,7 +174,7 @@ public function testValidateFilter($filter, $expectedResult)
174174
/**
175175
* @return array
176176
*/
177-
public function validateFilterDataProvider()
177+
public static function validateFilterDataProvider()
178178
{
179179
return [
180180
['filter' => '0-10', 'result' => ['0', '10']],

app/code/Magento/Catalog/Test/Unit/Model/Plugin/QuoteItemProductOptionTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ protected function setUp(): void
6060
->getMock();
6161
$this->quoteItemMock = $this->getMockBuilder(AbstractQuoteItem::class)
6262
->disableOriginalConstructor()
63-
->setMethods(['getOptions', 'getProduct'])
63+
->addMethods(['getOptions'])
64+
->onlyMethods(['getProduct'])
6465
->getMockForAbstractClass();
6566
$this->quoteItemOptionMock = $this->getMockBuilder(QuoteItemOption::class)
6667
->disableOriginalConstructor()
67-
->setMethods(['getCode'])
68+
->addMethods(['getCode'])
6869
->getMock();
6970
$this->productMock = $this->getMockBuilder(Product::class)
7071
->disableOriginalConstructor()

app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/TierpriceTest.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ protected function setUp(): void
6565
->disableOriginalConstructor()
6666
->getMock();
6767
$this->attribute = $this->getMockBuilder(AbstractAttribute::class)
68-
->setMethods(['getName', 'isScopeGlobal'])
68+
->addMethods(['isScopeGlobal'])
69+
->onlyMethods(['getName'])
6970
->disableOriginalConstructor()
7071
->getMockForAbstractClass();
7172
$this->localeFormat = $this->getMockBuilder(FormatInterface::class)
@@ -119,7 +120,10 @@ public function testValidate()
119120
$this->attribute->expects($this->atLeastOnce())->method('getName')->willReturn($attributeName);
120121
$object->expects($this->atLeastOnce())->method('getData')->with($attributeName)->willReturn($tierPrices);
121122
$this->localeFormat->expects($this->atLeastOnce())
122-
->method('getNumber')->withConsecutive([15], [20])->willReturnArgument(0);
123+
->method('getNumber')
124+
->willReturnCallback(fn($param) => match ([$param]) {
125+
[15], [20] => 0
126+
});
123127
$this->storeManager->expects($this->once())->method('getWebsites')->willReturn([]);
124128
$this->assertTrue($this->tierprice->validate($object));
125129
}
@@ -209,15 +213,21 @@ public function testSetPriceData()
209213
$object->expects($this->once())->method('getStoreId')->willReturn(null);
210214
$this->attribute->expects($this->atLeastOnce())->method('getName')->willReturn($attributeName);
211215
$object->expects($this->atLeastOnce())->method('setData')
212-
->withConsecutive(
213-
[$attributeName, $finalTierPrices],
214-
[$attributeName . '_changed', 0]
215-
)->willReturnSelf();
216+
->willReturnCallback(function ($arg1, $arg2) use ($attributeName, $finalTierPrices, $object) {
217+
if ($arg1 == $attributeName && $arg2 == $finalTierPrices) {
218+
return $object;
219+
} elseif ($arg1 == $attributeName . '_changed' && $arg2 == 0) {
220+
return $object;
221+
}
222+
});
216223
$object->expects($this->atLeastOnce())->method('setOrigData')
217-
->withConsecutive(
218-
[$attributeName, $finalTierPrices],
219-
[$attributeName . '_changed', 0]
220-
)->willReturnSelf();
224+
->willReturnCallback(function ($arg1, $arg2) use ($attributeName, $finalTierPrices, $object) {
225+
if ($arg1 == $attributeName && $arg2 == $finalTierPrices) {
226+
return $object;
227+
} elseif ($arg1 == $attributeName . '_changed' && $arg2 == 0) {
228+
return $object;
229+
}
230+
});
221231
$this->tierprice->setPriceData($object, $tierPrices);
222232
}
223233
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function testValidate($value)
150150
['getAttributeCode', 'getIsRequired', 'isValueEmpty', 'getIsUnique', 'getEntity']
151151
);
152152
$attributeEntity = $this->getMockBuilder(AbstractResource::class)
153-
->setMethods(['checkAttributeUniqueValue'])
153+
->addMethods(['checkAttributeUniqueValue'])
154154
->getMockForAbstractClass();
155155

156156
$attribute->expects($this->any())->method('getAttributeCode')->willReturn($attributeCode);
@@ -172,7 +172,7 @@ public function testValidate($value)
172172
/**
173173
* @return array
174174
*/
175-
public function validateDataProvider()
175+
public static function validateDataProvider()
176176
{
177177
return [
178178
[true],
@@ -206,7 +206,7 @@ public function testClearMediaAttribute($setDataExpectsCalls, $setDataArgument,
206206
/**
207207
* @return array
208208
*/
209-
public function clearMediaAttributeDataProvider()
209+
public static function clearMediaAttributeDataProvider()
210210
{
211211
return [
212212
[

app/code/Magento/Catalog/Test/Unit/Model/Product/Initialization/Helper/ProductLinksTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function setUp(): void
4040
private function getMockedProduct()
4141
{
4242
$mockBuilder = $this->getMockBuilder(Product::class)
43-
->setMethods(
43+
->addMethods(
4444
[
4545
'getRelatedReadonly',
4646
'getUpsellReadonly',

app/code/Magento/Catalog/Test/Unit/Model/Product/Link/ConverterTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public function testConvertLinksToGroupedArray()
3333
$linkType = 'associated';
3434
$linkMock = $this->getMockBuilder(ProductLinkInterface::class)
3535
->disableOriginalConstructor()
36-
->setMethods(['getData', 'getLinkType', 'getLinkedProductSku', 'getExtensionAttributes'])
36+
->addMethods(['getData'])
37+
->onlyMethods(['getLinkType', 'getLinkedProductSku', 'getExtensionAttributes'])
3738
->getMockForAbstractClass();
3839
$basicData = [$linkMock];
3940
$linkedProductMock = $this->getMockBuilder(Product::class)
@@ -45,7 +46,7 @@ public function testConvertLinksToGroupedArray()
4546
$linksAsArray = [$linkType => [$infoFinal]];
4647

4748
$typeMock = $this->getMockBuilder(AbstractType::class)
48-
->setMethods(['getAssociatedProducts'])
49+
->onlyMethods(['getAssociatedProducts'])
4950
->disableOriginalConstructor()
5051
->getMockForAbstractClass();
5152

@@ -78,7 +79,7 @@ public function testConvertLinksToGroupedArray()
7879
->method('getId')
7980
->willReturn($linkedProductId);
8081
$attributeMock = $this->getMockBuilder(ExtensionAttributesInterface::class)
81-
->setMethods(['__toArray'])
82+
->addMethods(['__toArray'])
8283
->getMockForAbstractClass();
8384
$linkMock->expects($this->once())
8485
->method('getExtensionAttributes')

0 commit comments

Comments
 (0)