Skip to content

Commit a7e0f6a

Browse files
committed
Merge remote-tracking branch 'karyna/refactor-phpcs-reported-files-that-were-false-positive' into platform-health
2 parents 332819c + a25e103 commit a7e0f6a

File tree

146 files changed

+862
-944
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+862
-944
lines changed

app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function testRecreateWithExpression(
198198
->willReturn($this->selectMock);
199199
$withArgs = [];
200200

201-
foreach (array_keys($selectParts) as $key => $partName) {
201+
foreach (array_keys($selectParts) as $partName) {
202202
$withArgs[] = [$partName, $expectedParts[$partName]];
203203
}
204204
$this->selectMock

app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,7 @@ protected function setUp(): void
195195
$args = ['context' => $contextMock];
196196

197197
$testHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
198-
$this->controller = $testHelper->getObject(
199-
Save::class,
200-
$args
201-
);
198+
$this->controller = $testHelper->getObject(Save::class, $args);
202199
}
203200

204201
/**

app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,8 +1383,7 @@ public function testPrepareForCartAdvancedAllRequiredOption(): void
13831383
'getBundleOption',
13841384
'getBundleOptionsData'
13851385
]
1386-
)
1387-
->disableOriginalConstructor()
1386+
)->disableOriginalConstructor()
13881387
->getMock();
13891388
/* @var \PHPUnit\Framework\MockObject\MockObject|\Magento\Catalog\Model\Product\Option $option */
13901389
$option = $this->getMockBuilder(Option::class)
@@ -1405,8 +1404,7 @@ public function testPrepareForCartAdvancedAllRequiredOption(): void
14051404
'hasData',
14061405
'getData'
14071406
]
1408-
)
1409-
->addMethods(['getHasOptions', 'setCartQty', 'getSkipCheckRequiredOption'])
1407+
)->addMethods(['getHasOptions', 'setCartQty', 'getSkipCheckRequiredOption'])
14101408
->disableOriginalConstructor()
14111409
->getMock();
14121410
/** @var MockObject|Type $productType */
@@ -1419,7 +1417,6 @@ public function testPrepareForCartAdvancedAllRequiredOption(): void
14191417
->onlyMethods(['getItems'])
14201418
->disableOriginalConstructor()
14211419
->getMock();
1422-
14231420
$this->parentClass($group, $option, $buyRequest, $product);
14241421

14251422
$product->expects($this->any())
@@ -1444,7 +1441,6 @@ function ($key) use ($optionCollection) {
14441441
$resultValue = [0 => 5];
14451442
break;
14461443
}
1447-
14481444
return $resultValue;
14491445
}
14501446
);
@@ -1456,8 +1452,7 @@ function ($key) use ($optionCollection) {
14561452
$buyRequest->expects($this->once())
14571453
->method('getBundleOption')
14581454
->willReturn([3 => 5]);
1459-
$option
1460-
->method('getId')
1455+
$option->method('getId')
14611456
->willReturnOnConsecutiveCalls(3);
14621457
$option->expects($this->once())
14631458
->method('getRequired')

app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundlePanelTest.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,20 @@ public function testModifyMeta(string $shipmentTypePath, string $dataScope): voi
135135
->willReturn([]);
136136
$this->arrayManagerMock->method('set')
137137
->willReturn([]);
138+
139+
$metaArgument = [
140+
$shipmentTypePath . BundlePanel::META_CONFIG_PATH,
141+
[],
142+
[
143+
'dataScope' => $dataScope,
144+
'validation' => [
145+
'required-entry' => false
146+
]
147+
]
148+
];
138149
$this->arrayManagerMock
139150
->method('merge')
140-
->withConsecutive(
141-
[], [], [], [], [], [], [], [], [], [], [], [],
142-
[
143-
$shipmentTypePath . BundlePanel::META_CONFIG_PATH,
144-
[],
145-
[
146-
'dataScope' => $dataScope,
147-
'validation' => [
148-
'required-entry' => false
149-
]
150-
]
151-
]
152-
153-
);
151+
->withConsecutive([], [], [], [], [], [], [], [], [], [], [], [], $metaArgument);
154152
$this->bundlePanelModel->modifyMeta($sourceMeta);
155153
}
156154

app/code/Magento/BundleImportExport/Test/Unit/Model/Import/Product/Type/BundleTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ protected function setUp(): void
158158
'delete',
159159
'quoteInto',
160160
'fetchAssoc'
161-
])
161+
]
162+
)
162163
->disableOriginalConstructor()
163164
->getMock();
164165
$this->select = $this->createMock(Select::class);

app/code/Magento/CacheInvalidate/Test/Unit/Model/PurgeCacheTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public function testSendPurgeRequest(array $hosts): void
9191
$connectWithArgs = $writeWithArgs = [];
9292

9393
foreach ($uris as $uri) {
94-
$withArgs[] = [$uri->getHost(), $uri->getPort()];
9594
$writeWithArgs[] = ['PURGE', $uri, '1.1', ['X-Magento-Tags-Pattern' => 'tags', 'Host' => $uri->getHost()]];
9695
}
9796
$this->socketAdapterMock

app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/SaveHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
class SaveHandlerTest extends TestCase
3030
{
3131
/**
32-
* Magento\Framework\TestFramework\Unit\Helper\ObjectManager
32+
* @var ObjectManager
3333
*/
3434
private $objectManager;
3535

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class CategoryTest extends TestCase
7676

7777
/**
7878
* @inheritDoc
79+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
7980
*/
8081
protected function setUp(): void
8182
{
@@ -105,8 +106,7 @@ protected function setUp(): void
105106
'getChildrenCategories',
106107
'getIsActive'
107108
]
108-
)
109-
->getMock();
109+
)->getMock();
110110

111111
$this->dataProvider
112112
->method('getCategory')
@@ -153,8 +153,7 @@ protected function setUp(): void
153153
'setValue',
154154
'setCount'
155155
]
156-
)
157-
->getMock();
156+
)->getMock();
158157
$filterItem->expects($this->any())
159158
->method($this->anything())->willReturnSelf();
160159
$this->filterItemFactory->expects($this->any())
@@ -192,12 +191,23 @@ protected function setUp(): void
192191
public function testApplyWithEmptyRequest($requestValue, $idValue): void
193192
{
194193
$requestField = 'test_request_var';
194+
$idField = 'id';
195195

196196
$this->target->setRequestVar($requestField);
197197

198198
$this->request
199199
->method('getParam')
200-
->with($requestField);
200+
->with($requestField)
201+
->willReturnCallback(
202+
function ($field) use ($requestField, $idField, $requestValue, $idValue) {
203+
switch ($field) {
204+
case $requestField:
205+
return $requestValue;
206+
case $idField:
207+
return $idValue;
208+
}
209+
}
210+
);
201211

202212
$result = $this->target->apply($this->request);
203213
$this->assertSame($this->target, $result);

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,17 @@ public function testApplyWithEmptyRequest($requestValue, $idValue): void
203203

204204
$this->request
205205
->method('getParam')
206-
->with($requestField);
206+
->with($requestField)
207+
->willReturnCallback(
208+
function ($field) use ($requestField, $idField, $requestValue, $idValue) {
209+
switch ($field) {
210+
case $requestField:
211+
return $requestValue;
212+
case $idField:
213+
return $idValue;
214+
}
215+
}
216+
);
207217

208218
$result = $this->target->apply($this->request);
209219
$this->assertSame($this->target, $result);

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/RepositoryTest.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ protected function setUp(): void
9090
}
9191

9292
/**
93-
* @return void
94-
*/
93+
* @return void
94+
*/
9595
public function testGetList(): void
9696
{
9797
$productSku = 'simple_product';
@@ -106,17 +106,17 @@ public function testGetList(): void
106106
}
107107

108108
/**
109-
* @return void
110-
*/
109+
* @return void
110+
*/
111111
public function testDelete(): void
112112
{
113113
$this->optionResourceMock->expects($this->once())->method('delete')->with($this->optionMock);
114114
$this->assertTrue($this->optionRepository->delete($this->optionMock));
115115
}
116116

117117
/**
118-
* @return void
119-
*/
118+
* @return void
119+
*/
120120
public function testGetNonExistingOption(): void
121121
{
122122
$this->expectException('Magento\Framework\Exception\NoSuchEntityException');
@@ -136,8 +136,8 @@ public function testGetNonExistingOption(): void
136136
}
137137

138138
/**
139-
* @return void
140-
*/
139+
* @return void
140+
*/
141141
public function testGet(): void
142142
{
143143
$optionId = 1;
@@ -155,8 +155,8 @@ public function testGet(): void
155155
}
156156

157157
/**
158-
* @return void
159-
*/
158+
* @return void
159+
*/
160160
public function testDeleteByIdentifierNonExistingOption(): void
161161
{
162162
$this->expectException('Magento\Framework\Exception\NoSuchEntityException');
@@ -177,8 +177,8 @@ public function testDeleteByIdentifierNonExistingOption(): void
177177
}
178178

179179
/**
180-
* @return void
181-
*/
180+
* @return void
181+
*/
182182
public function testDeleteByIdentifier(): void
183183
{
184184
$optionId = 1;
@@ -200,8 +200,8 @@ public function testDeleteByIdentifier(): void
200200
}
201201

202202
/**
203-
* @return void
204-
*/
203+
* @return void
204+
*/
205205
public function testDeleteByIdentifierWhenCannotRemoveOption(): void
206206
{
207207
$this->expectException('Magento\Framework\Exception\CouldNotSaveException');
@@ -228,8 +228,8 @@ public function testDeleteByIdentifierWhenCannotRemoveOption(): void
228228
}
229229

230230
/**
231-
* @return void
232-
*/
231+
* @return void
232+
*/
233233
public function testSaveCouldNotSaveException(): void
234234
{
235235
$this->expectException('Magento\Framework\Exception\CouldNotSaveException');
@@ -239,8 +239,8 @@ public function testSaveCouldNotSaveException(): void
239239
}
240240

241241
/**
242-
* @return void
243-
*/
242+
* @return void
243+
*/
244244
public function testSaveNoSuchEntityException(): void
245245
{
246246
$this->expectException('Magento\Framework\Exception\NoSuchEntityException');
@@ -261,8 +261,8 @@ public function testSaveNoSuchEntityException(): void
261261
}
262262

263263
/**
264-
* @return void
265-
*/
264+
* @return void
265+
*/
266266
public function testSave(): void
267267
{
268268
$productSku = 'simple_product';
@@ -307,8 +307,8 @@ public function testSave(): void
307307
}
308308

309309
/**
310-
* @return void
311-
*/
310+
* @return void
311+
*/
312312
public function testSaveWhenOptionTypeWasChanged(): void
313313
{
314314
$productSku = 'simple_product';

app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ class PriceTest extends TestCase
6868
*/
6969
protected $websiteMock;
7070

71+
/**
72+
* @var ProductTierPriceExtensionFactory|MockObject
73+
*/
7174
private $tierPriceExtensionFactoryMock;
7275

7376
/**

app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public function testGetCompositeTypes(): void
137137
public function testGetTypesByPriority(): void
138138
{
139139
$expected = [];
140+
$options = [];
140141
foreach ($this->_productTypes as $typeId => $type) {
141142
$type['label'] = __($type['label']);
142143
$options[$typeId] = $type;

0 commit comments

Comments
 (0)