Skip to content

Commit fd22437

Browse files
committed
withConsecutive method deprecation fix 2
1 parent a788eaf commit fd22437

23 files changed

+348
-170
lines changed

src/Test/Unit/Step/Build/BackupDataTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@ public function testExecute()
5656
{
5757
$this->loggerMock->expects($this->exactly(2))
5858
->method('notice')
59-
->withConsecutive(
60-
['Copying data to the ./init directory'],
61-
['End of copying data to the ./init directory']
62-
);
59+
// withConsecutive() alternative.
60+
->willReturnCallback(function (string $axis) {
61+
static $series = [
62+
'Copying data to the ./init directory',
63+
'End of copying data to the ./init directory'
64+
];
65+
$this->assertSame(array_shift($series), $axis);
66+
});
6367
$this->stepMock->expects($this->once())
6468
->method('execute');
6569

src/Test/Unit/Step/Build/CompileDiTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@ public function testExecute()
7676
->willReturn('-vvv');
7777
$this->loggerMock->expects($this->exactly(2))
7878
->method('notice')
79-
->withConsecutive(
80-
['Running DI compilation'],
81-
['End of running DI compilation']
82-
);
79+
// withConsecutive() alternative.
80+
->willReturnCallback(function (string $axis) {
81+
static $series = [
82+
'Running DI compilation',
83+
'End of running DI compilation'
84+
];
85+
$this->assertSame(array_shift($series), $axis);
86+
});
8387
$this->magentoShellMock->expects($this->once())
8488
->method('execute')
8589
->with('setup:di:compile', ['-vvv']);

src/Test/Unit/Step/Build/RefreshModulesTest.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,15 @@ public function testExecute()
5757
{
5858
$this->loggerMock->expects($this->exactly(2))
5959
->method('notice')
60-
->withConsecutive(
61-
['Reconciling installed modules with shared config.'],
62-
['End of reconciling modules.']
63-
);
60+
// withConsecutive() alternative.
61+
->willReturnCallback(function ($args) {
62+
static $series = [
63+
'Reconciling installed modules with shared config.',
64+
'End of reconciling modules.'
65+
];
66+
$expectedArgs = array_shift($series);
67+
$this->assertSame($expectedArgs, $args);
68+
});
6469
$this->loggerMock->expects($this->once())
6570
->method('info')
6671
->with('The following modules have been enabled:' . PHP_EOL . 'module1' . PHP_EOL . 'module2');
@@ -75,10 +80,15 @@ public function testExecuteNoModulesChanged()
7580
{
7681
$this->loggerMock->expects($this->exactly(2))
7782
->method('notice')
78-
->withConsecutive(
79-
['Reconciling installed modules with shared config.'],
80-
['End of reconciling modules.']
81-
);
83+
// withConsecutive() alternative.
84+
->willReturnCallback(function ($args) {
85+
static $series = [
86+
'Reconciling installed modules with shared config.',
87+
'End of reconciling modules.'
88+
];
89+
$expectedArgs = array_shift($series);
90+
$this->assertSame($expectedArgs, $args);
91+
});
8292
$this->loggerMock->expects($this->once())
8393
->method('info')
8494
->with('No modules were changed.');

src/Test/Unit/Step/Build/RunBalerTest.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,16 @@ public function testValidatorFails(): void
114114
));
115115
$this->loggerMock->expects($this->exactly(3))
116116
->method('warning')
117-
->withConsecutive(
118-
['Baler validation failed'],
119-
[" - Maybe baler isn't installed"],
120-
[' - Maybe config is wrong']
121-
);
117+
// withConsecutive() alternative.
118+
->willReturnCallback(function ($args) {
119+
static $series = [
120+
'Baler validation failed',
121+
" - Maybe baler isn't installed",
122+
' - Maybe config is wrong'
123+
];
124+
$expectedArgs = array_shift($series);
125+
$this->assertSame($expectedArgs, $args);
126+
});
122127

123128
$this->step->execute();
124129
}
@@ -135,7 +140,15 @@ public function testRunBaler(): void
135140
->willReturn(new Result\Success());
136141
$this->loggerMock->expects($this->exactly(2))
137142
->method('info')
138-
->withConsecutive(['Running Baler JS bundler.'], ['Baler JS bundling complete.']);
143+
// withConsecutive() alternative.
144+
->willReturnCallback(function ($args) {
145+
static $series = [
146+
'Running Baler JS bundler.',
147+
'Baler JS bundling complete.'
148+
];
149+
$expectedArgs = array_shift($series);
150+
$this->assertSame($expectedArgs, $args);
151+
});
139152
$this->shellMock->expects($this->once())
140153
->method('execute')
141154
->with('baler');

src/Test/Unit/Step/Deploy/DeployStaticContent/GenerateTest.php

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,15 @@ public function testExecute(): void
102102
->with('magento_root/pub/static/deployed_version.txt')
103103
->willReturn(true);
104104
$this->loggerMock->method('info')
105-
->withConsecutive(
106-
['Extracting locales'],
107-
['Generating static content']
108-
);
105+
// withConsecutive() alternative.
106+
->willReturnCallback(function ($args) {
107+
static $series = [
108+
'Extracting locales',
109+
'Generating static content'
110+
];
111+
$expectedArgs = array_shift($series);
112+
$this->assertSame($expectedArgs, $args);
113+
});
109114
$this->commandFactoryMock->expects($this->once())
110115
->method('matrix')
111116
->willReturn([
@@ -138,10 +143,15 @@ public function testExecuteWithLocales(): void
138143
->with('magento_root/pub/static/deployed_version.txt')
139144
->willReturn(true);
140145
$this->loggerMock->method('info')
141-
->withConsecutive(
142-
['Extracting locales'],
143-
['Generating static content for locales: en_GB']
144-
);
146+
// withConsecutive() alternative.
147+
->willReturnCallback(function ($args) {
148+
static $series = [
149+
'Extracting locales',
150+
'Generating static content for locales: en_GB'
151+
];
152+
$expectedArgs = array_shift($series);
153+
$this->assertSame($expectedArgs, $args);
154+
});
145155
$this->commandFactoryMock->expects($this->once())
146156
->method('matrix')
147157
->willReturn([
@@ -175,10 +185,15 @@ public function testExecuteWitError(): void
175185
->with('magento_root/pub/static/deployed_version.txt')
176186
->willReturn(true);
177187
$this->loggerMock->method('notice')
178-
->withConsecutive(
179-
['Extracting locales'],
180-
['Generating static content for locales: en_GB fr_FR']
181-
);
188+
// withConsecutive() alternative.
189+
->willReturnCallback(function ($args) {
190+
static $series = [
191+
'Extracting locales',
192+
'Generating static content for locales: en_GB fr_FR'
193+
];
194+
$expectedArgs = array_shift($series);
195+
$this->assertSame($expectedArgs, $args);
196+
});
182197
$this->commandFactoryMock->expects($this->once())
183198
->method('matrix')
184199
->willReturn([

src/Test/Unit/Step/Deploy/DeployStaticContentTest.php

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,15 @@ public function testExecuteOnRemoteInDeploy()
104104
->willReturn(false);
105105
$this->loggerMock->expects($this->exactly(2))
106106
->method('notice')
107-
->withConsecutive(
108-
['Generating fresh static content'],
109-
['End of generating fresh static content']
110-
);
107+
// withConsecutive() alternative.
108+
->willReturnCallback(function ($args) {
109+
static $series = [
110+
'Generating fresh static content',
111+
'End of generating fresh static content'
112+
];
113+
$expectedArgs = array_shift($series);
114+
$this->assertSame($expectedArgs, $args);
115+
});
111116
$this->stageConfigMock->method('get')
112117
->willReturnMap([
113118
[DeployInterface::VAR_CLEAN_STATIC_FILES, true],
@@ -136,10 +141,15 @@ public function testExecuteOnRemoteWithoutCleaning()
136141
->willReturn(false);
137142
$this->loggerMock->expects($this->exactly(2))
138143
->method('notice')
139-
->withConsecutive(
140-
['Generating fresh static content'],
141-
['End of generating fresh static content']
142-
);
144+
// withConsecutive() alternative.
145+
->willReturnCallback(function ($args) {
146+
static $series = [
147+
'Generating fresh static content',
148+
'End of generating fresh static content'
149+
];
150+
$expectedArgs = array_shift($series);
151+
$this->assertSame($expectedArgs, $args);
152+
});
143153
$this->stageConfigMock->expects($this->any())
144154
->method('get')
145155
->willReturnMap([
@@ -184,9 +194,14 @@ public function testExecuteScdOnDemandInProduction()
184194
->willReturn(true);
185195
$this->loggerMock->expects($this->once())
186196
->method('notice')
187-
->withConsecutive(
188-
['Skipping static content deploy. SCD on demand is enabled.']
189-
);
197+
// withConsecutive() alternative.
198+
->willReturnCallback(function ($args) {
199+
static $series = [
200+
'Skipping static content deploy. SCD on demand is enabled.'
201+
];
202+
$expectedArgs = array_shift($series);
203+
$this->assertSame($expectedArgs, $args);
204+
});
190205
$this->flagManagerMock->expects($this->never())
191206
->method('exists');
192207
$this->staticContentCleanerMock->expects($this->once())

src/Test/Unit/Step/Deploy/InstallUpdate/ConfigUpdate/DbConnectionTest.php

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,15 @@ public function testExecuteWithSlaveWithoutSplitConfigs()
275275
]);
276276
$this->loggerMock->expects($this->exactly(2))
277277
->method('info')
278-
->withConsecutive(
279-
['Updating env.php DB connection configuration.'],
280-
['Set DB slave connection for default connection.']
281-
);
278+
// withConsecutive() alternative.
279+
->willReturnCallback(function ($args) {
280+
static $series = [
281+
'Updating env.php DB connection configuration.',
282+
'Set DB slave connection for default connection.'
283+
];
284+
$expectedArgs = array_shift($series);
285+
$this->assertSame($expectedArgs, $args);
286+
});
282287
$this->configReaderMock->expects($this->once())
283288
->method('read')
284289
->willReturn([
@@ -292,11 +297,11 @@ public function testExecuteWithSlaveWithoutSplitConfigs()
292297
->method('warning');
293298
$this->stageConfigMock->expects($this->exactly(2))
294299
->method('get')
295-
->withConsecutive(
296-
[DeployInterface::VAR_MYSQL_USE_SLAVE_CONNECTION],
297-
[DeployInterface::VAR_DATABASE_CONFIGURATION]
298-
)
299-
->willReturnOnConsecutiveCalls(true, []);
300+
// withConsecutive() alternative.
301+
->willReturnCallback(fn($param) => match ([$param]) {
302+
[DeployInterface::VAR_MYSQL_USE_SLAVE_CONNECTION] => true,
303+
[DeployInterface::VAR_DATABASE_CONFIGURATION] => []
304+
});
300305
$this->envConnectionDataMock->expects($this->once())
301306
->method('getHost')
302307
->willReturn('host');
@@ -350,11 +355,11 @@ public function testExecuteWithNotCompatibleDatabaseConfigForSlaveConnection()
350355
->willReturn($resourceConfig);
351356
$this->stageConfigMock->expects($this->exactly(2))
352357
->method('get')
353-
->withConsecutive(
354-
[DeployInterface::VAR_MYSQL_USE_SLAVE_CONNECTION],
355-
[DeployInterface::VAR_DATABASE_CONFIGURATION]
356-
)
357-
->willReturnOnConsecutiveCalls(true, []);
358+
// withConsecutive() alternative.
359+
->willReturnCallback(fn($param) => match ([$param]) {
360+
[DeployInterface::VAR_MYSQL_USE_SLAVE_CONNECTION] => true,
361+
[DeployInterface::VAR_DATABASE_CONFIGURATION] => []
362+
});
358363
$this->envConnectionDataMock->expects($this->once())
359364
->method('getHost')
360365
->willReturn('host');
@@ -401,11 +406,11 @@ public function testExecuteSetSlaveConnectionHadNoEffect()
401406
->method('warning');
402407
$this->stageConfigMock->expects($this->exactly(2))
403408
->method('get')
404-
->withConsecutive(
405-
[DeployInterface::VAR_MYSQL_USE_SLAVE_CONNECTION],
406-
[DeployInterface::VAR_DATABASE_CONFIGURATION]
407-
)
408-
->willReturnOnConsecutiveCalls(true, []);
409+
// withConsecutive() alternative.
410+
->willReturnCallback(fn($param) => match ([$param]) {
411+
[DeployInterface::VAR_MYSQL_USE_SLAVE_CONNECTION] => true,
412+
[DeployInterface::VAR_DATABASE_CONFIGURATION] => []
413+
});
409414
$this->envConnectionDataMock->expects($this->once())
410415
->method('getHost')
411416
->willReturn('host');

src/Test/Unit/Step/Deploy/InstallUpdate/ConfigUpdate/SearchEngineTest.php

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,15 @@ public function testExecute(
120120
->willReturn('mysql');
121121
$this->loggerMock->expects($this->exactly(2))
122122
->method('info')
123-
->withConsecutive(
124-
['Updating search engine configuration.'],
125-
['Set search engine to: mysql']
126-
);
123+
// withConsecutive() alternative.
124+
->willReturnCallback(function ($args) {
125+
static $series = [
126+
'Updating search engine configuration.',
127+
'Set search engine to: mysql'
128+
];
129+
$expectedArgs = array_shift($series);
130+
$this->assertSame($expectedArgs, $args);
131+
});
127132
$this->magentoVersionMock->expects($this->once())
128133
->method('satisfies')
129134
->with('2.1.*')
@@ -304,10 +309,15 @@ public function testExecuteWithException()
304309
->willReturn('mysql');
305310
$this->loggerMock->expects($this->exactly(2))
306311
->method('info')
307-
->withConsecutive(
308-
['Updating search engine configuration.'],
309-
['Set search engine to: mysql']
310-
);
312+
// withConsecutive() alternative.
313+
->willReturnCallback(function ($args) {
314+
static $series = [
315+
'Updating search engine configuration.',
316+
'Set search engine to: mysql'
317+
];
318+
$expectedArgs = array_shift($series);
319+
$this->assertSame($expectedArgs, $args);
320+
});
311321
$this->magentoVersionMock->expects($this->once())
312322
->method('satisfies')
313323
->with('2.1.*')
@@ -341,10 +351,15 @@ public function testExecuteWithPackageException()
341351
->willReturn('mysql');
342352
$this->loggerMock->expects($this->exactly(2))
343353
->method('info')
344-
->withConsecutive(
345-
['Updating search engine configuration.'],
346-
['Set search engine to: mysql']
347-
);
354+
// withConsecutive() alternative.
355+
->willReturnCallback(function ($args) {
356+
static $series = [
357+
'Updating search engine configuration.',
358+
'Set search engine to: mysql'
359+
];
360+
$expectedArgs = array_shift($series);
361+
$this->assertSame($expectedArgs, $args);
362+
});
348363
$this->magentoVersionMock->expects($this->once())
349364
->method('satisfies')
350365
->with('2.1.*')

0 commit comments

Comments
 (0)