Skip to content

Commit a788eaf

Browse files
committed
withConsecutive method deprecation fix 1
applies for withConsecutive() followed by willReturnOnConsecutiveCalls() occurrences
1 parent 988ae69 commit a788eaf

File tree

13 files changed

+305
-136
lines changed

13 files changed

+305
-136
lines changed

src/Test/Unit/App/Logger/Formatter/ErrorFormatterFactoryTest.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,17 @@ public function testCreate()
4444
{
4545
$this->containerMock->expects($this->exactly(2))
4646
->method('get')
47-
->withConsecutive(
48-
[ErrorInfo::class],
49-
[ReaderInterface::class]
50-
)
51-
->willReturnOnConsecutiveCalls(
52-
$this->createMock(ErrorInfo::class),
53-
$this->getMockForAbstractClass(ReaderInterface::class)
54-
);
47+
->willReturnCallback(function (...$args) {
48+
static $series = [
49+
[[ErrorInfo::class], $this->createMock(ErrorInfo::class)],
50+
[[ReaderInterface::class], $this->getMockForAbstractClass(ReaderInterface::class)],
51+
];
52+
53+
[$expectedArgs, $return] = array_shift($series);
54+
$this->assertSame($expectedArgs, $args);
55+
56+
return $return;
57+
});
5558

5659
$errorFormatter = $this->errorFormatterFactory->create();
5760
$this->assertInstanceOf(JsonErrorFormatter::class, $errorFormatter);

src/Test/Unit/Command/ConfigValidateTest.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ public function testExecuteError()
8181
->willReturn($errorMock);
8282
$this->outputMock->expects($this->exactly(2))
8383
->method('writeln')
84-
->withConsecutive(
85-
['Error message'],
86-
['Error suggestion']
87-
);
84+
->willReturnCallback(function (string $axis) {
85+
static $series = [
86+
'Error message',
87+
'Error suggestion',
88+
];
8889

90+
$this->assertSame(array_shift($series), $axis);
91+
});
8992
$this->assertEquals(
9093
Cli::FAILURE,
9194
$this->command->execute($this->inputMock, $this->outputMock)
@@ -99,11 +102,14 @@ public function testExecuteWithException()
99102
->willThrowException(new ValidatorException('some error'));
100103
$this->outputMock->expects($this->exactly(2))
101104
->method('writeln')
102-
->withConsecutive(
103-
['Command execution failed:'],
104-
['some error']
105-
);
105+
->willReturnCallback(function (string $axis) {
106+
static $series = [
107+
'Command execution failed:',
108+
'some error',
109+
];
106110

111+
$this->assertSame(array_shift($series), $axis);
112+
});
107113
$this->assertEquals(
108114
Cli::FAILURE,
109115
$this->command->execute($this->inputMock, $this->outputMock)

src/Test/Unit/Command/DbDumpTest.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,14 @@ public function testExecuteWithConfirmation()
7878
->willReturn(true);
7979
$this->loggerMock->expects($this->exactly(2))
8080
->method('info')
81-
->withConsecutive(
82-
['Starting backup.'],
83-
['Backup completed.']
84-
);
81+
->willReturnCallback(function (string $axis) {
82+
static $series = [
83+
'Starting backup.',
84+
'Backup completed.',
85+
];
86+
87+
$this->assertSame(array_shift($series), $axis);
88+
});
8589
$this->dumpProcessorMock->expects($this->once())
8690
->method('execute')
8791
->with(false, []);
@@ -130,10 +134,14 @@ public function testExecuteWithRemovingDefiners(array $options)
130134
->willReturn(true);
131135
$this->loggerMock->expects($this->exactly(2))
132136
->method('info')
133-
->withConsecutive(
134-
['Starting backup.'],
135-
['Backup completed.']
136-
);
137+
->willReturnCallback(function (string $axis) {
138+
static $series = [
139+
'Starting backup.',
140+
'Backup completed.',
141+
];
142+
143+
$this->assertSame(array_shift($series), $axis);
144+
});
137145
$this->dumpProcessorMock->expects($this->once())
138146
->method('execute')
139147
->with(true, []);
@@ -197,10 +205,14 @@ public function testExecuteWithDatabases()
197205
->willReturn(true);
198206
$this->loggerMock->expects($this->exactly(2))
199207
->method('info')
200-
->withConsecutive(
201-
['Starting backup.'],
202-
['Backup completed.']
203-
);
208+
->willReturnCallback(function (string $axis) {
209+
static $series = [
210+
'Starting backup.',
211+
'Backup completed.',
212+
];
213+
214+
$this->assertSame(array_shift($series), $axis);
215+
});
204216
$this->dumpProcessorMock->expects($this->once())
205217
->method('execute')
206218
->with(false, ['main', 'sales', 'quote']);

src/Test/Unit/Command/Wizard/MasterSlaveTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Console\Input\InputInterface;
1616
use Symfony\Component\Console\Output\OutputInterface;
17+
use Symfony\Component\ExpressionLanguage\ParsedExpression;
1718

1819
/**
1920
* @inheritdoc
@@ -74,6 +75,11 @@ public function testExecuteWithErrors()
7475
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
7576
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
7677

78+
$series = [
79+
[$outputMock, 'MySQL slave connection is not configured'],
80+
[$outputMock, 'Redis slave connection is not configured']
81+
];
82+
7783
$this->deployConfigMock->expects($this->exactly(2))
7884
->method('get')
7985
->willReturnMap([
@@ -82,10 +88,10 @@ public function testExecuteWithErrors()
8288
]);
8389
$this->outputFormatterMock->expects($this->exactly(2))
8490
->method('writeItem')
85-
->withConsecutive(
86-
[$outputMock, 'MySQL slave connection is not configured'],
87-
[$outputMock, 'Redis slave connection is not configured']
88-
);
91+
->willReturnCallback(function (...$args) use (&$series) {
92+
$expectedArgs = array_shift($series);
93+
$this->assertSame($expectedArgs, $args);
94+
});
8995
$this->outputFormatterMock->expects($this->once())
9096
->method('writeResult')
9197
->with($outputMock, false, 'Slave connections are not configured');

src/Test/Unit/Config/AmqpTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,18 @@ public function testGetConfig(
7777
int $countCallGetConfig,
7878
array $expectedQueueConfig
7979
): void {
80+
$series = [
81+
[[DeployInterface::VAR_QUEUE_CONFIGURATION], $customQueueConfig],
82+
[[DeployInterface::VAR_CONSUMERS_WAIT_FOR_MAX_MESSAGES], $consumersWaitMaxMessages],
83+
];
8084
$this->stageConfigMock->expects($this->exactly($countCallGetConfig))
8185
->method('get')
82-
->withConsecutive(
83-
[DeployInterface::VAR_QUEUE_CONFIGURATION],
84-
[DeployInterface::VAR_CONSUMERS_WAIT_FOR_MAX_MESSAGES]
85-
)
86-
->willReturnOnConsecutiveCalls($customQueueConfig, $consumersWaitMaxMessages);
86+
->willReturnCallback(function (...$args) use (&$series) {
87+
[$expectedArgs, $return] = array_shift($series);
88+
$this->assertSame($expectedArgs, $args);
89+
90+
return $return;
91+
});
8792
$this->rabbitMq->expects($this->once())
8893
->method('getConfiguration')
8994
->willReturn($amqpServiceConfig);

src/Test/Unit/Config/Validator/Build/ComposerFileTest.php

Lines changed: 69 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,18 @@ protected function setUp(): void
7272
*/
7373
public function testValidateCorrectComposerJson(): void
7474
{
75+
$series = [
76+
[['2.3'], true],
77+
[['2.4.3'], false],
78+
];
7579
$this->magentoVersionMock->expects($this->exactly(2))
7680
->method('isGreaterOrEqual')
77-
->withConsecutive(['2.3'], ['2.4.3'])
78-
->willReturnOnConsecutiveCalls(true, false);
81+
->willReturnCallback(function (...$args) use (&$series) {
82+
[$expectedArgs, $return] = array_shift($series);
83+
$this->assertSame($expectedArgs, $args);
84+
85+
return $return;
86+
});
7987
$this->fileListMock->expects($this->once())
8088
->method('getMagentoComposer')
8189
->willReturn(__DIR__ . '/_files/correct_composer_2.3.json');
@@ -90,10 +98,18 @@ public function testValidateCorrectComposerJson(): void
9098
*/
9199
public function testValidateCorrectLaminasComposerJson(): void
92100
{
101+
$series = [
102+
[['2.3'], true],
103+
[['2.4.3'], false],
104+
];
93105
$this->magentoVersionMock->expects($this->exactly(2))
94106
->method('isGreaterOrEqual')
95-
->withConsecutive(['2.3'], ['2.4.3'])
96-
->willReturnOnConsecutiveCalls(true, false);
107+
->willReturnCallback(function (...$args) use (&$series) {
108+
[$expectedArgs, $return] = array_shift($series);
109+
$this->assertSame($expectedArgs, $args);
110+
111+
return $return;
112+
});
97113
$this->fileListMock->expects($this->once())
98114
->method('getMagentoComposer')
99115
->willReturn(__DIR__ . '/_files/correct_composer_2.3_2.json');
@@ -108,10 +124,18 @@ public function testValidateCorrectLaminasComposerJson(): void
108124
*/
109125
public function testValidateCorrectAutoload243ComposerJson(): void
110126
{
127+
$series = [
128+
[['2.3'], true],
129+
[['2.4.3'], false],
130+
];
111131
$this->magentoVersionMock->expects($this->exactly(2))
112132
->method('isGreaterOrEqual')
113-
->withConsecutive(['2.3'], ['2.4.3'])
114-
->willReturnOnConsecutiveCalls(true, false);
133+
->willReturnCallback(function (...$args) use (&$series) {
134+
[$expectedArgs, $return] = array_shift($series);
135+
$this->assertSame($expectedArgs, $args);
136+
137+
return $return;
138+
});
115139
$this->fileListMock->expects($this->once())
116140
->method('getMagentoComposer')
117141
->willReturn(__DIR__ . '/_files/correct_composer_2.3_2.json');
@@ -126,10 +150,18 @@ public function testValidateCorrectAutoload243ComposerJson(): void
126150
*/
127151
public function testValidateWrongComposerJson(): void
128152
{
153+
$series = [
154+
[['2.3'], true],
155+
[['2.4.3'], false],
156+
];
129157
$this->magentoVersionMock->expects($this->exactly(2))
130158
->method('isGreaterOrEqual')
131-
->withConsecutive(['2.3'], ['2.4.3'])
132-
->willReturnOnConsecutiveCalls(true, false);
159+
->willReturnCallback(function (...$args) use (&$series) {
160+
[$expectedArgs, $return] = array_shift($series);
161+
$this->assertSame($expectedArgs, $args);
162+
163+
return $return;
164+
});
133165
$this->fileListMock->expects($this->once())
134166
->method('getMagentoComposer')
135167
->willReturn(__DIR__ . '/_files/wrong_composer_2.3.json');
@@ -155,10 +187,17 @@ public function testValidateWrongComposerJson(): void
155187
*/
156188
public function testValidateMagentoLower23(): void
157189
{
190+
$series = [
191+
[['2.3'], false],
192+
];
158193
$this->magentoVersionMock->expects($this->exactly(1))
159194
->method('isGreaterOrEqual')
160-
->withConsecutive(['2.3'])
161-
->willReturnOnConsecutiveCalls(false);
195+
->willReturnCallback(function (...$args) use (&$series) {
196+
[$expectedArgs, $return] = array_shift($series);
197+
$this->assertSame($expectedArgs, $args);
198+
199+
return $return;
200+
});
162201
$this->fileListMock->expects($this->never())
163202
->method('getMagentoComposer');
164203
$this->resultFactoryMock->expects($this->once())
@@ -172,10 +211,18 @@ public function testValidateMagentoLower23(): void
172211
*/
173212
public function testValidateMagentoHigherEqual243(): void
174213
{
214+
$series = [
215+
[['2.3'], true],
216+
[['2.4.3'], true],
217+
];
175218
$this->magentoVersionMock->expects($this->exactly(2))
176219
->method('isGreaterOrEqual')
177-
->withConsecutive(['2.3'], ['2.4.3'])
178-
->willReturnOnConsecutiveCalls(true, true);
220+
->willReturnCallback(function (...$args) use (&$series) {
221+
[$expectedArgs, $return] = array_shift($series);
222+
$this->assertSame($expectedArgs, $args);
223+
224+
return $return;
225+
});
179226
$this->fileListMock->expects($this->never())
180227
->method('getMagentoComposer');
181228
$this->resultFactoryMock->expects($this->once())
@@ -189,10 +236,18 @@ public function testValidateMagentoHigherEqual243(): void
189236
*/
190237
public function testValidateComposerFileNotExists(): void
191238
{
239+
$series = [
240+
[['2.3'], true],
241+
[['2.4.3'], false],
242+
];
192243
$this->magentoVersionMock->expects($this->exactly(2))
193244
->method('isGreaterOrEqual')
194-
->withConsecutive(['2.3'], ['2.4.3'])
195-
->willReturnOnConsecutiveCalls(true, false);
245+
->willReturnCallback(function (...$args) use (&$series) {
246+
[$expectedArgs, $return] = array_shift($series);
247+
$this->assertSame($expectedArgs, $args);
248+
249+
return $return;
250+
});
196251
$this->fileListMock->expects($this->once())
197252
->method('getMagentoComposer')
198253
->willReturn(__DIR__ . '/_files/file_not_exists.json');

src/Test/Unit/Config/Validator/Build/ConfigFileStructureTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ protected function setUp(): void
6363
*/
6464
public function testRun(): void
6565
{
66+
$series = [
67+
[[['scopes/websites/key' => 'value'], 'scopes/websites', false], ['scopes/websites/key' => 'value']],
68+
[[['scopes/websites/key' => 'value'], 'scopes/stores', false], []],
69+
];
6670
$this->configResolverMock->expects($this->once())
6771
->method('getPath')
6872
->willReturn('magento_root/app/etc/config.php');
@@ -71,14 +75,12 @@ public function testRun(): void
7175
->willReturn(['scopes/websites/key' => 'value']);
7276
$this->arrayManagerMock->expects($this->exactly(2))
7377
->method('filter')
74-
->withConsecutive(
75-
[['scopes/websites/key' => 'value'], 'scopes/websites', false],
76-
[['scopes/websites/key' => 'value'], 'scopes/stores', false]
77-
)
78-
->willReturnOnConsecutiveCalls(
79-
['scopes/websites/key' => 'value'],
80-
[]
81-
);
78+
->willReturnCallback(function (...$args) use (&$series) {
79+
[$expectedArgs, $return] = array_shift($series);
80+
$this->assertSame($expectedArgs, $args);
81+
82+
return $return;
83+
});
8284
$this->resultFactoryMock->expects($this->once())
8385
->method('create')
8486
->with(ResultInterface::SUCCESS)

0 commit comments

Comments
 (0)