Skip to content

Commit 808e6eb

Browse files
committed
Merge remote-tracking branch 'origin/AC-10718-ce' into AC-10821
2 parents ed3370f + 0aa76db commit 808e6eb

File tree

91 files changed

+912
-584
lines changed

Some content is hidden

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

91 files changed

+912
-584
lines changed

app/code/Magento/AdvancedSearch/Test/Unit/Model/Client/ClientResolverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public function testCreate(): void
6868

6969
$this->objectManager->expects($this->exactly(2))->method('create')
7070
->willReturnCallback(function ($className) use ($factoryMock, $clientOptionsMock) {
71-
if ($className === 'engineFactoryClass') {
71+
if ($className == 'engineFactoryClass') {
7272
return $factoryMock;
73-
} elseif ($className === 'engineOptionClass') {
73+
} elseif ($className == 'engineOptionClass') {
7474
return $clientOptionsMock;
7575
}
7676
});

app/code/Magento/Analytics/Test/Unit/Model/ReportWriterTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,14 @@ public function testWrite(array $configData, array $fileData, array $expectedFil
135135
$errorStreamMock
136136
->expects($this->exactly(2))
137137
->method('writeCsv')
138-
->willReturnCallback(function ($arg) {
139-
return null;
138+
->willReturnCallback(function (...$args) use ($expectedFileData) {
139+
static $index = 0;
140+
$expectedArgs = [
141+
[array_keys($expectedFileData[0])],
142+
[$expectedFileData[0]]
143+
];
144+
$index++;
145+
return $args === $expectedArgs[$index - 1] ? null : null;
140146
});
141147

142148
$errorStreamMock->expects($this->once())->method('unlock');

app/code/Magento/AsynchronousOperations/Test/Unit/Model/BulkManagementTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,14 @@ public function testScheduleBulk(): void
147147
$operation->expects($this->exactly(2))->method('getTopicName')
148148
->willReturnOnConsecutiveCalls($topicNames[0], $topicNames[1]);
149149
$this->publisher->expects($this->exactly(2))->method('publish')
150-
->willReturnCallback(function ($arg1, $arg2) use ($topicNames, $operation) {
151-
if (in_array($arg1, $topicNames)) {
150+
->willReturnCallback(function (...$args) use ($topicNames, $operation) {
151+
static $index = 0;
152+
$expectedArgs = [
153+
[$topicNames[0], [$operation]],
154+
[$topicNames[1], [$operation]]
155+
];
156+
$index++;
157+
if ($args === $expectedArgs[$index - 1]) {
152158
return null;
153159
}
154160
});

app/code/Magento/Authorization/Test/Unit/Model/Acl/Loader/RoleTest.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,15 @@ public function testPopulateAclAddsRolesAndTheirChildren(): void
155155
$aclMock = $this->createMock(Acl::class);
156156
$aclMock
157157
->method('addRole')
158-
->willReturnCallback(function ($arg1, $arg2) {
159-
if ($arg2 === null || $arg2 === '1') {
160-
return null;
161-
}
158+
->willReturnCallback(function (...$args) {
159+
static $index = 0;
160+
$expectedArgs = [
161+
[$this->anything(), null],
162+
[$this->anything(), '1']
163+
];
164+
$returnValue = null;
165+
$index++;
166+
return $args === $expectedArgs[$index - 1] ? $returnValue : null;
162167
});
163168

164169
$this->model->populateAcl($aclMock);

app/code/Magento/Authorization/Test/Unit/Model/Acl/Loader/RuleTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static function ($value) {
9494
* Test populating acl rule from cache.
9595
*
9696
* @return void
97+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
9798
*/
9899
public function testPopulateAclFromCache(): void
99100
{
@@ -117,21 +118,20 @@ public function testPopulateAclFromCache(): void
117118
$aclMock->method('hasResource')->willReturn(true);
118119
$aclMock
119120
->method('allow')
120-
->willReturnCallback(function ($arg1, $arg2) {
121-
if ($arg2 === null) {
121+
->willReturnCallback(function ($arg1, $arg2, $arg3) {
122+
if ($arg1 == '1' && $arg2 === null && $arg3 === null) {
122123
return null;
123-
} elseif ($arg2 === 'Magento_Backend::all') {
124+
} elseif ($arg1 == '1' && $arg2 == 'Magento_Backend::all' && $arg3 === null) {
124125
return null;
125-
} elseif ($arg2 === '1') {
126+
} elseif ($arg1 == '2' && $arg2 == 1 && $arg3 === null) {
126127
return null;
127-
;
128128
}
129129
});
130130

131131
$aclMock
132132
->method('deny')
133133
->willReturnCallback(function ($arg1, $arg2, $arg3) {
134-
if ($arg1 === '3' && $arg2 == 1 && is_null($arg3)) {
134+
if ($arg1 == '3' && $arg2 == 1 && is_null($arg3)) {
135135
return null;
136136
}
137137
});

app/code/Magento/Backend/Test/Unit/Model/Menu/BuilderTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,14 @@ public function testGetResultBuildsTreeStructure(): void
8585

8686
$this->menuMock
8787
->method('add')
88-
->willReturnCallback(function ($arg1, $arg2, $arg3) {
89-
if ($arg3 == 2 || $arg3 == 4) {
88+
->willReturnCallback(function (...$args) {
89+
static $index = 0;
90+
$expectedArgs = [
91+
[$this->isInstanceOf(Item::class), null, 2],
92+
[$this->isInstanceOf(Item::class), null, 4]
93+
];
94+
$index++;
95+
if ($args === $expectedArgs[$index - 1]) {
9096
return null;
9197
}
9298
});

app/code/Magento/Backup/Test/Unit/Controller/Adminhtml/Index/RollbackTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ public function testExecute(): void
279279
$this->objectManagerMock
280280
->method('create')
281281
->willReturnCallback(function ($arg1, $arg2) {
282-
if ($arg1 == Db::class) {
282+
if ($arg1 == Db::class && empty($arg2)) {
283283
return $this->backupResourceModelMock;
284-
} elseif ($arg1 == Backup::class) {
284+
} elseif ($arg1 == Backup::class && empty($arg2)) {
285285
return $this->backupModelMock;
286286
}
287287
});

app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,6 @@ public function testGetJsonConfigFixedPriceBundle(): void
268268
->getMock();
269269
$this->product
270270
->method('getLowestPrice')
271-
// ->withConsecutive(
272-
// [$this->product, $baseAmount],
273-
// [$this->product, $basePriceValue]
274-
// )
275-
// ->willReturnOnConsecutiveCalls(999, 888);
276271
->willReturnCallback(function ($arg1, $arg2) use ($baseAmount, $basePriceValue) {
277272
if ($arg1 == $this->product && $arg2==$baseAmount) {
278273
return 999;
@@ -284,7 +279,6 @@ public function testGetJsonConfigFixedPriceBundle(): void
284279
->method('create')
285280
->willReturn($bundleProductPrice);
286281
$options = [$this->createOption($optionId, 'Title `1', $selections)];
287-
288282
$finalPriceMock = $this->getPriceMock(
289283
[
290284
'getPriceWithoutOption' => new DataObject(
@@ -317,7 +311,6 @@ public function testGetJsonConfigFixedPriceBundle(): void
317311
RegularPrice::PRICE_CODE => $regularPriceMock
318312
];
319313
$priceInfo = $this->getPriceInfoMock($prices);
320-
321314
$this->product->expects($this->once())
322315
->method('hasPreconfiguredValues')
323316
->willReturn(true);

app/code/Magento/Bundle/Test/Unit/Helper/Catalog/Product/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public function testGetOptions($includingTax, $displayCartPriceBoth): void
286286
->method('getTaxPrice')
287287
->willReturnCallback(
288288
function ($product, $amount, $includingTax) {
289-
if ($includingTax || !$includingTax) {
289+
if ($product && $amount == 15.00 && ($includingTax || !$includingTax)) {
290290
return 15.00;
291291
}
292292
}

app/code/Magento/Bundle/Test/Unit/Model/ResourceModel/Indexer/PriceTest.php

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,33 @@ public function testCalculateDynamicBundleSelectionPrice(): void
177177
//@codingStandardsIgnoreEnd
178178
$this->connectionMock->expects($this->exactly(3))
179179
->method('getCheckSql')
180-
->withConsecutive(
181-
[
182-
'i.special_price > 0 AND i.special_price < 100',
183-
'ROUND(' . $price . ' * (i.special_price / 100), 4)',
184-
$price
185-
],
186-
[
187-
'i.tier_percent IS NOT NULL',
188-
'ROUND((1 - i.tier_percent / 100) * ' . $price . ', 4)',
189-
'NULL'
190-
],
191-
["bo.type = 'select' OR bo.type = 'radio'", '0', '1']
192-
);
180+
->willReturnCallback(function ($arg1, $arg2, $arg3) use ($price) {
181+
static $callCount = 0;
182+
$callCount++;
183+
switch ($callCount) {
184+
case 1:
185+
if ($arg1 === 'i.special_price > 0 AND i.special_price < 100' &&
186+
$arg2 === 'ROUND(' . $price . ' * (i.special_price / 100), 4)' &&
187+
$arg3 === $price) {
188+
return null;
189+
}
190+
break;
191+
case 2:
192+
if ($arg1 === 'i.tier_percent IS NOT NULL' &&
193+
$arg2 === 'ROUND((1 - i.tier_percent / 100) * ' . $price . ', 4)' &&
194+
$arg3 === 'NULL') {
195+
return null;
196+
}
197+
break;
198+
case 3:
199+
if ($arg1 === "bo.type = 'select' OR bo.type = 'radio'" &&
200+
$arg2 === '0' &&
201+
$arg3 === '1') {
202+
return null;
203+
}
204+
break;
205+
}
206+
});
193207

194208
$select = $this->createMock(\Magento\Framework\DB\Select::class);
195209
$select->expects($this->once())->method('from')->willReturn($select);

0 commit comments

Comments
 (0)