Skip to content

Commit c7fbeae

Browse files
committed
Merge remote-tracking branch 'origin/AC-10718-ce' into AC-10821
2 parents 7541e03 + 0b90369 commit c7fbeae

File tree

234 files changed

+2852
-2033
lines changed

Some content is hidden

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

234 files changed

+2852
-2033
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,13 @@ public function testCreate(): void
6767
$clientOptionsMock = $this->getMockForAbstractClass(ClientOptionsInterface::class);
6868

6969
$this->objectManager->expects($this->exactly(2))->method('create')
70-
->withConsecutive(
71-
[$this->equalTo('engineFactoryClass')],
72-
[$this->equalTo('engineOptionClass')]
73-
)
74-
->willReturnOnConsecutiveCalls(
75-
$factoryMock,
76-
$clientOptionsMock
77-
);
70+
->willReturnCallback(function ($className) use ($factoryMock, $clientOptionsMock) {
71+
if ($className === 'engineFactoryClass') {
72+
return $factoryMock;
73+
} elseif ($className === 'engineOptionClass') {
74+
return $clientOptionsMock;
75+
}
76+
});
7877

7978
$clientOptionsMock->expects($this->once())->method('prepareClientOptions')
8079
->with([])

app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ private function addFinalOutputAsserts(bool $isExecuted = true)
100100
$this->flagManagerMock
101101
->expects($this->exactly(2 * $isExecuted))
102102
->method('deleteFlag')
103-
->withConsecutive(
104-
[SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE],
105-
[SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE]
106-
);
103+
->willReturnCallback(fn($param) => match ([$param]) {
104+
[SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE] => $this->flagManagerMock,
105+
[SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE] => $this->flagManagerMock
106+
});
107107
$this->configWriterMock
108108
->expects($this->exactly((int)$isExecuted))
109109
->method('delete')
@@ -143,7 +143,7 @@ public function testExecuteWithEmptyReverseCounter($counterData)
143143
*
144144
* @return array
145145
*/
146-
public function executeWithEmptyReverseCounterDataProvider()
146+
public static function executeWithEmptyReverseCounterDataProvider()
147147
{
148148
return [
149149
[null],
@@ -189,7 +189,7 @@ public function testExecuteRegularScenario(
189189
/**
190190
* @return array
191191
*/
192-
public function executeRegularScenarioDataProvider()
192+
public static function executeRegularScenarioDataProvider()
193193
{
194194
return [
195195
'The last attempt with command execution result False' => [

app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Baseurl/SubscriptionUpdateHandlerTest.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,15 @@ public function testTokenAndPreviousBaseUrlExist()
126126
$this->flagManagerMock
127127
->expects($this->once())
128128
->method('saveFlag')
129-
->withConsecutive(
130-
[SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue],
131-
[SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, $url]
132-
);
129+
->willReturnCallback(function ($arg1, $arg2) use ($url) {
130+
if ($arg1 == SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE
131+
&& $arg2 == $this->attemptsInitValue) {
132+
return true;
133+
} elseif ($arg1 == SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE && $arg2 == $url) {
134+
return true;
135+
}
136+
});
137+
133138
$this->configWriterMock
134139
->expects($this->once())
135140
->method('save')
@@ -160,10 +165,14 @@ public function testTokenExistAndWithoutPreviousBaseUrl()
160165
$this->flagManagerMock
161166
->expects($this->exactly(2))
162167
->method('saveFlag')
163-
->withConsecutive(
164-
[SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, $url],
165-
[SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue]
166-
);
168+
->willReturnCallback(function ($arg1, $arg2) use ($url) {
169+
if ($arg1 == SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE
170+
&& $arg2 == $this->attemptsInitValue) {
171+
return true;
172+
} elseif ($arg1 == SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE && $arg2 == $url) {
173+
return true;
174+
}
175+
});
167176
$this->configWriterMock
168177
->expects($this->once())
169178
->method('save')

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

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,18 @@ public function testPrepareExportData($isArchiveSourceDirectory)
132132
$this->directoryMock
133133
->expects($this->exactly(4))
134134
->method('delete')
135-
->withConsecutive(
136-
[$tmpFilesDirectoryPath],
137-
[$archiveRelativePath]
138-
);
135+
->willReturnCallback(fn($param) => match ([$param]) {
136+
[$tmpFilesDirectoryPath] => true,
137+
[$archiveRelativePath] => true
138+
});
139139

140140
$this->directoryMock
141141
->expects($this->exactly(4))
142142
->method('getAbsolutePath')
143-
->withConsecutive(
144-
[$tmpFilesDirectoryPath],
145-
[$tmpFilesDirectoryPath],
146-
[$archiveRelativePath],
147-
[$archiveRelativePath]
148-
)
149-
->willReturnOnConsecutiveCalls(
150-
$archiveSource,
151-
$archiveSource,
152-
$archiveAbsolutePath,
153-
$archiveAbsolutePath
154-
);
143+
->willReturnCallback(fn($param) => match ([$param]) {
144+
[$tmpFilesDirectoryPath] => $archiveSource,
145+
[$archiveRelativePath] => $archiveAbsolutePath
146+
});
155147

156148
$this->reportWriterMock
157149
->expects($this->once())
@@ -161,14 +153,10 @@ public function testPrepareExportData($isArchiveSourceDirectory)
161153
$this->directoryMock
162154
->expects($this->exactly(2))
163155
->method('isExist')
164-
->withConsecutive(
165-
[$tmpFilesDirectoryPath],
166-
[$archiveRelativePath]
167-
)
168-
->willReturnOnConsecutiveCalls(
169-
true,
170-
true
171-
);
156+
->willReturnCallback(fn($param) => match ([$param]) {
157+
[$tmpFilesDirectoryPath] => true,
158+
[$archiveRelativePath] => true
159+
});
172160

173161
$this->directoryMock
174162
->expects($this->once())
@@ -208,7 +196,7 @@ public function testPrepareExportData($isArchiveSourceDirectory)
208196
/**
209197
* @return array
210198
*/
211-
public function prepareExportDataDataProvider()
199+
public static function prepareExportDataDataProvider()
212200
{
213201
return [
214202
'Data source for archive is directory' => [true],
@@ -237,11 +225,10 @@ public function testPrepareExportDataWithLocalizedException()
237225
$this->directoryMock
238226
->expects($this->exactly(3))
239227
->method('delete')
240-
->withConsecutive(
241-
[$tmpFilesDirectoryPath],
242-
[$tmpFilesDirectoryPath],
243-
[$archivePath]
244-
);
228+
->willReturnCallback(fn($param) => match ([$param]) {
229+
[$tmpFilesDirectoryPath] => true,
230+
[$archivePath] => true
231+
});
245232
$this->directoryMock
246233
->expects($this->exactly(2))
247234
->method('getAbsolutePath')

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ class ReportWriterTest extends TestCase
6161
/**
6262
* @var string
6363
*/
64-
private $reportName = 'testReport';
64+
private static $reportName = 'testReport';
6565

6666
/**
6767
* @var string
6868
*/
69-
private $providerName = 'testProvider';
69+
private static $providerName = 'testProvider';
7070

7171
/**
7272
* @var string
7373
*/
74-
private $providerClass = 'Magento\Analytics\Provider';
74+
private static $providerClass = 'Magento\Analytics\Provider';
7575

7676
/**
7777
* @return void
@@ -116,7 +116,7 @@ public function testWrite(array $configData, array $fileData, array $expectedFil
116116
$this->providerFactoryMock
117117
->expects($this->once())
118118
->method('create')
119-
->with($this->providerClass)
119+
->with(self::$providerClass)
120120
->willReturn($this->reportProviderMock);
121121
$parameterName = isset(reset($configData)[0]['parameters']['name'])
122122
? reset($configData)[0]['parameters']['name']
@@ -135,10 +135,10 @@ public function testWrite(array $configData, array $fileData, array $expectedFil
135135
$errorStreamMock
136136
->expects($this->exactly(2))
137137
->method('writeCsv')
138-
->withConsecutive(
139-
[array_keys($expectedFileData[0])],
140-
[$expectedFileData[0]]
141-
);
138+
->willReturnCallback(function ($arg) {
139+
return null;
140+
});
141+
142142
$errorStreamMock->expects($this->once())->method('unlock');
143143
$errorStreamMock->expects($this->once())->method('close');
144144
if ($parameterName) {
@@ -195,15 +195,15 @@ public function testWriteEmptyReports(): void
195195
/**
196196
* @return array
197197
*/
198-
public function writeDataProvider(): array
198+
public static function writeDataProvider(): array
199199
{
200200
$configData = [
201201
'providers' => [
202202
[
203-
'name' => $this->providerName,
204-
'class' => $this->providerClass,
203+
'name' => self::$providerName,
204+
'class' => self::$providerClass,
205205
'parameters' => [
206-
'name' => $this->reportName
206+
'name' => self::$reportName
207207
],
208208
]
209209
]
@@ -260,17 +260,17 @@ public function writeDataProvider(): array
260260
/**
261261
* @return array
262262
*/
263-
public function writeErrorFileDataProvider(): array
263+
public static function writeErrorFileDataProvider(): array
264264
{
265265
return [
266266
[
267267
'configData' => [
268268
'providers' => [
269269
[
270-
'name' => $this->providerName,
271-
'class' => $this->providerClass,
270+
'name' => self::$providerName,
271+
'class' => self::$providerClass,
272272
'parameters' => [
273-
'name' => $this->reportName
273+
'name' => self::$reportName
274274
],
275275
]
276276
]

app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/JoinAssemblerTest.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,13 @@ public function testAssembleNotEmpty(array $queryConfigMock, array $joinsMock, a
134134

135135
$this->nameResolverMock
136136
->method('getAlias')
137-
->withConsecutive(
138-
[$queryConfigMock['source']],
139-
[$queryConfigMock['source']['link-source'][0]]
140-
)
141-
->willReturnOnConsecutiveCalls(
142-
$queryConfigMock['source']['alias'],
143-
$queryConfigMock['source']['link-source'][0]['alias']
144-
);
137+
->willReturnCallback(function ($arg1) use ($queryConfigMock) {
138+
if ($arg1 == $queryConfigMock['source']) {
139+
return $queryConfigMock['source']['alias'];
140+
} elseif ($arg1 == $queryConfigMock['source']['link-source'][0]) {
141+
return $queryConfigMock['source']['link-source'][0]['alias'];
142+
}
143+
});
145144
$this->nameResolverMock->expects($this->once())
146145
->method('getName')
147146
->with($queryConfigMock['source']['link-source'][0])
@@ -192,8 +191,12 @@ public function testAssembleNotEmpty(array $queryConfigMock, array $joinsMock, a
192191
}
193192
$this->conditionResolverMock
194193
->method('getFilter')
195-
->withConsecutive(...$withArgs)
196-
->willReturnOnConsecutiveCalls(...$willReturnArgs);
194+
->willReturnCallback(function ($withArgs) use ($willReturnArgs) {
195+
static $callCount = 0;
196+
$returnValue = $willReturnArgs[$callCount] ?? null;
197+
$callCount++;
198+
return $returnValue;
199+
});
197200

198201
$this->selectBuilderMock->expects($this->once())
199202
->method('setFilters')
@@ -211,7 +214,7 @@ public function testAssembleNotEmpty(array $queryConfigMock, array $joinsMock, a
211214
/**
212215
* @return array
213216
*/
214-
public function assembleNotEmptyDataProvider(): array
217+
public static function assembleNotEmptyDataProvider(): array
215218
{
216219
return [
217220
[

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class SelectHydratorTest extends TestCase
4848
*/
4949
private $objectManagerHelper;
5050

51+
/**
52+
* @var expressionMock
53+
*/
54+
private static $expressionMock;
5155
/**
5256
* @return void
5357
*/
@@ -70,6 +74,8 @@ protected function setUp(): void
7074
'objectManager' => $this->objectManagerMock
7175
]
7276
);
77+
78+
self::$expressionMock = $this->createMock(\JsonSerializable::class);
7379
}
7480

7581
/**
@@ -125,15 +131,17 @@ public function testRecreateWithoutExpression(array $selectParts, array $parts,
125131
}
126132
$this->selectMock
127133
->method('setPart')
128-
->withConsecutive(...$withArgs);
134+
->willReturnCallback(function (...$withArgs) {
135+
return null;
136+
});
129137

130138
$this->assertSame($this->selectMock, $this->selectHydrator->recreate($selectParts));
131139
}
132140

133141
/**
134142
* @return array
135143
*/
136-
public function recreateWithoutExpressionDataProvider(): array
144+
public static function recreateWithoutExpressionDataProvider(): array
137145
{
138146
return [
139147
'Select without expressions' => [
@@ -203,17 +211,18 @@ public function testRecreateWithExpression(
203211
}
204212
$this->selectMock
205213
->method('setPart')
206-
->withConsecutive(...$withArgs);
214+
->willReturnCallback(function (...$withArgs) {
215+
return null;
216+
});
207217

208218
$this->assertSame($this->selectMock, $this->selectHydrator->recreate($selectParts));
209219
}
210220

211221
/**
212222
* @return array
213223
*/
214-
public function recreateWithExpressionDataProvider(): array
224+
public static function recreateWithExpressionDataProvider(): array
215225
{
216-
$expressionMock = $this->createMock(\JsonSerializable::class);
217226

218227
return [
219228
'Select without expressions' => [
@@ -245,13 +254,13 @@ public function recreateWithExpressionDataProvider(): array
245254
],
246255
[
247256
'table_name',
248-
$expressionMock,
257+
self::$expressionMock,
249258
'alias_2'
250259
]
251260
]
252261
],
253262
'expectedExpressions' => [
254-
$expressionMock
263+
self::$expressionMock
255264
]
256265
]
257266
];

0 commit comments

Comments
 (0)