Skip to content

Commit a00d609

Browse files
committed
Fix Symfony Console 8.0 compatibility
The add() method was removed in Symfony Console 8.0 in favor of addCommand(). Update all test files to use the new method name.
1 parent 1f940d3 commit a00d609

8 files changed

Lines changed: 70 additions & 70 deletions

File tree

tests/Phinx/Console/Command/BreakpointTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function setUp(): void
8181
public function testExecute($testMethod, $commandLine, $version = null, $noVersionParameter = false)
8282
{
8383
$application = new PhinxApplication();
84-
$application->add(new Breakpoint());
84+
$application->addCommand(new Breakpoint());
8585

8686
/** @var Breakpoint $command */
8787
$command = $application->find('breakpoint');
@@ -160,7 +160,7 @@ public function provideBreakpointTests()
160160
public function testRemoveAllAndTargetThrowsException()
161161
{
162162
$application = new PhinxApplication();
163-
$application->add(new Breakpoint());
163+
$application->addCommand(new Breakpoint());
164164

165165
/** @var Breakpoint $command */
166166
$command = $application->find('breakpoint');
@@ -197,7 +197,7 @@ public function testRemoveAllAndTargetThrowsException()
197197
public function testRemoveAllSetUnsetCombinedThrowsException($commandLine)
198198
{
199199
$application = new PhinxApplication();
200-
$application->add(new Breakpoint());
200+
$application->addCommand(new Breakpoint());
201201

202202
/** @var Breakpoint $command */
203203
$command = $application->find('breakpoint');
@@ -249,7 +249,7 @@ public function provideCombinedParametersToCauseException()
249249
public function testExecuteWithEnvironmentOption()
250250
{
251251
$application = new PhinxApplication();
252-
$application->add(new Breakpoint());
252+
$application->addCommand(new Breakpoint());
253253

254254
/** @var Breakpoint $command */
255255
$command = $application->find('breakpoint');
@@ -277,7 +277,7 @@ public function testExecuteWithEnvironmentOption()
277277
public function testExecuteWithInvalidEnvironmentOption()
278278
{
279279
$application = new PhinxApplication();
280-
$application->add(new Breakpoint());
280+
$application->addCommand(new Breakpoint());
281281

282282
/** @var Breakpoint $command */
283283
$command = $application->find('breakpoint');

tests/Phinx/Console/Command/CreateTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function setUp(): void
7676
public function testCreateMigrationDefault(): void
7777
{
7878
$application = new PhinxApplication();
79-
$application->add(new Create());
79+
$application->addCommand(new Create());
8080

8181
/** @var Create $command */
8282
$command = $application->find('create');
@@ -110,7 +110,7 @@ public function testCreateMigrationDefault(): void
110110
public function testCreateMigrationWithName(): void
111111
{
112112
$application = new PhinxApplication();
113-
$application->add(new Create());
113+
$application->addCommand(new Create());
114114

115115
/** @var Create $command */
116116
$command = $application->find('create');
@@ -139,7 +139,7 @@ public function testCreateMigrationWithName(): void
139139
public function testExecuteWithDuplicateMigrationNames()
140140
{
141141
$application = new PhinxApplication();
142-
$application->add(new Create());
142+
$application->addCommand(new Create());
143143

144144
/** @var Create $command */
145145
$command = $application->find('create');
@@ -166,7 +166,7 @@ public function testExecuteWithDuplicateMigrationNames()
166166
public function testExecuteWithDuplicateMigrationNamesWithNamespace()
167167
{
168168
$application = new PhinxApplication();
169-
$application->add(new Create());
169+
$application->addCommand(new Create());
170170

171171
/** @var Create $command */
172172
$command = $application->find('create');
@@ -200,7 +200,7 @@ public function testExecuteWithDuplicateMigrationNamesWithNamespace()
200200
public function testSupplyingBothClassAndTemplateAtCommandLineThrowsException()
201201
{
202202
$application = new PhinxApplication();
203-
$application->add(new Create());
203+
$application->addCommand(new Create());
204204

205205
/** @var Create $command $command */
206206
$command = $application->find('create');
@@ -225,7 +225,7 @@ public function testSupplyingBothClassAndTemplateAtCommandLineThrowsException()
225225
public function testSupplyingBothClassAndTemplateInConfigThrowsException()
226226
{
227227
$application = new PhinxApplication();
228-
$application->add(new Create());
228+
$application->addCommand(new Create());
229229

230230
/** @var Create $command $command */
231231
$command = $application->find('create');
@@ -292,7 +292,7 @@ public function provideFailingTemplateGenerator()
292292
public function testTemplateGeneratorsWithoutCorrectInterfaceThrowsException(array $config, array $commandLine, $exceptionMessage)
293293
{
294294
$application = new PhinxApplication();
295-
$application->add(new Create());
295+
$application->addCommand(new Create());
296296

297297
/** @var Create $command $command */
298298
$command = $application->find('create');
@@ -360,7 +360,7 @@ public function provideNullTemplateGenerator()
360360
public function testNullTemplateGeneratorsDoNotFail(array $config, array $commandLine)
361361
{
362362
$application = new PhinxApplication();
363-
$application->add(new Create());
363+
$application->addCommand(new Create());
364364

365365
/** @var Create $command $command */
366366
$command = $application->find('create');
@@ -424,7 +424,7 @@ public function provideSimpleTemplateGenerator()
424424
public function testSimpleTemplateGeneratorsIsCorrectlyPopulated(array $config, array $commandLine)
425425
{
426426
$application = new PhinxApplication();
427-
$application->add(new Create());
427+
$application->addCommand(new Create());
428428

429429
/** @var Create $command $command */
430430
$command = $application->find('create');
@@ -461,7 +461,7 @@ public function testSimpleTemplateGeneratorsIsCorrectlyPopulated(array $config,
461461
public function testCreateMigrationWithChangeStyleInConfig(): void
462462
{
463463
$application = new PhinxApplication();
464-
$application->add(new Create());
464+
$application->addCommand(new Create());
465465

466466
/** @var Create $command */
467467
$command = $application->find('create');
@@ -497,7 +497,7 @@ public function testCreateMigrationWithChangeStyleInConfig(): void
497497
public function testCreateMigrationWithChangeStyleAsFlag(): void
498498
{
499499
$application = new PhinxApplication();
500-
$application->add(new Create());
500+
$application->addCommand(new Create());
501501

502502
/** @var Create $command */
503503
$command = $application->find('create');
@@ -531,7 +531,7 @@ public function testCreateMigrationWithChangeStyleAsFlag(): void
531531
public function testCreateMigrationWithUpDownStyleAsFlag(): void
532532
{
533533
$application = new PhinxApplication();
534-
$application->add(new Create());
534+
$application->addCommand(new Create());
535535

536536
/** @var Create $command */
537537
$command = $application->find('create');
@@ -565,7 +565,7 @@ public function testCreateMigrationWithUpDownStyleAsFlag(): void
565565
public function testCreateMigrationWithExistingTimestamp(): void
566566
{
567567
$application = new PhinxApplication();
568-
$application->add(new Create());
568+
$application->addCommand(new Create());
569569

570570
/** @var Create $command */
571571
$command = $application->find('create');
@@ -592,7 +592,7 @@ public function testCreateMigrationWithExistingTimestamp(): void
592592
public function testCreateMigrationWithInvalidStyleFlagThrows(): void
593593
{
594594
$application = new PhinxApplication();
595-
$application->add(new Create());
595+
$application->addCommand(new Create());
596596

597597
/** @var Create $command */
598598
$command = $application->find('create');
@@ -617,7 +617,7 @@ public function testCreateMigrationWithInvalidStyleFlagThrows(): void
617617
public function testCreateWithKeywordNameThrows(): void
618618
{
619619
$application = new PhinxApplication();
620-
$application->add(new Create());
620+
$application->addCommand(new Create());
621621

622622
/** @var Create $command */
623623
$command = $application->find('create');

tests/Phinx/Console/Command/InitTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function setUp(): void
2525
protected function writeConfig($configName = '')
2626
{
2727
$application = new PhinxApplication();
28-
$application->add(new Init());
28+
$application->addCommand(new Init());
2929
$command = $application->find('init');
3030
$commandTester = new CommandTester($command);
3131
$fullPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $configName;
@@ -100,7 +100,7 @@ public function testConfigurationOption($configPath): void
100100
try {
101101
chdir(sys_get_temp_dir());
102102
$application = new PhinxApplication();
103-
$application->add(new Init());
103+
$application->addCommand(new Init());
104104
$command = $application->find('init');
105105
$commandTester = new CommandTester($command);
106106

@@ -134,7 +134,7 @@ public function testDefaults()
134134
chdir(sys_get_temp_dir());
135135

136136
$application = new PhinxApplication();
137-
$application->add(new Init());
137+
$application->addCommand(new Init());
138138

139139
$command = $application->find('init');
140140

@@ -163,7 +163,7 @@ public function testYamlFormat()
163163
chdir(sys_get_temp_dir());
164164

165165
$application = new PhinxApplication();
166-
$application->add(new Init());
166+
$application->addCommand(new Init());
167167

168168
$command = $application->find('init');
169169

@@ -188,7 +188,7 @@ public function testThrowsExceptionWhenConfigFilePresent()
188188
{
189189
touch(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'phinx.php');
190190
$application = new PhinxApplication();
191-
$application->add(new Init());
191+
$application->addCommand(new Init());
192192

193193
$command = $application->find('init');
194194

@@ -209,7 +209,7 @@ public function testThrowsExceptionWhenConfigFilePresent()
209209
public function testThrowsExceptionWhenInvalidDir()
210210
{
211211
$application = new PhinxApplication();
212-
$application->add(new Init());
212+
$application->addCommand(new Init());
213213

214214
$command = $application->find('init');
215215

@@ -230,7 +230,7 @@ public function testThrowsExceptionWhenInvalidDir()
230230
public function testThrowsExceptionWhenInvalidFormat()
231231
{
232232
$application = new PhinxApplication();
233-
$application->add(new Init());
233+
$application->addCommand(new Init());
234234

235235
$command = $application->find('init');
236236

tests/Phinx/Console/Command/MigrateTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function setUp(): void
5454
public function testExecute()
5555
{
5656
$application = new PhinxApplication();
57-
$application->add(new Migrate());
57+
$application->addCommand(new Migrate());
5858

5959
/** @var Migrate $command */
6060
$command = $application->find('migrate');
@@ -82,7 +82,7 @@ public function testExecute()
8282
public function testExecuteWithDsn()
8383
{
8484
$application = new PhinxApplication();
85-
$application->add(new Migrate());
85+
$application->addCommand(new Migrate());
8686

8787
/** @var Migrate $command */
8888
$command = $application->find('migrate');
@@ -123,7 +123,7 @@ public function testExecuteWithDsn()
123123
public function testExecuteWithEnvironmentOption()
124124
{
125125
$application = new PhinxApplication();
126-
$application->add(new Migrate());
126+
$application->addCommand(new Migrate());
127127

128128
/** @var Migrate $command */
129129
$command = $application->find('migrate');
@@ -149,7 +149,7 @@ public function testExecuteWithEnvironmentOption()
149149
public function testExecuteWithInvalidEnvironmentOption()
150150
{
151151
$application = new PhinxApplication();
152-
$application->add(new Migrate());
152+
$application->addCommand(new Migrate());
153153

154154
/** @var Migrate $command */
155155
$command = $application->find('migrate');
@@ -176,7 +176,7 @@ public function testExecuteWithInvalidEnvironmentOption()
176176
public function testDatabaseNameSpecified()
177177
{
178178
$application = new PhinxApplication();
179-
$application->add(new Migrate());
179+
$application->addCommand(new Migrate());
180180

181181
/** @var Migrate $command */
182182
$command = $application->find('migrate');
@@ -202,7 +202,7 @@ public function testDatabaseNameSpecified()
202202
public function testFakeMigrate()
203203
{
204204
$application = new PhinxApplication();
205-
$application->add(new Migrate());
205+
$application->addCommand(new Migrate());
206206

207207
/** @var Migrate $command */
208208
$command = $application->find('migrate');
@@ -230,7 +230,7 @@ public function testMigrateExecutionOrder()
230230
$this->config['version_order'] = Config::VERSION_ORDER_EXECUTION_TIME;
231231

232232
$application = new PhinxApplication();
233-
$application->add(new Migrate());
233+
$application->addCommand(new Migrate());
234234

235235
/** @var Migrate $command */
236236
$command = $application->find('migrate');
@@ -272,7 +272,7 @@ public function testMigrateMemorySqlite()
272272
]);
273273

274274
$application = new PhinxApplication();
275-
$application->add(new Migrate());
275+
$application->addCommand(new Migrate());
276276

277277
/** @var Migrate $command */
278278
$command = $application->find('migrate');
@@ -303,7 +303,7 @@ public function testMigrateMemorySqlite()
303303
public function testExecuteWithDate(): void
304304
{
305305
$application = new PhinxApplication();
306-
$application->add(new Migrate());
306+
$application->addCommand(new Migrate());
307307

308308
/** @var Migrate $command */
309309
$command = $application->find('migrate');
@@ -335,7 +335,7 @@ public function testExecuteWithDate(): void
335335
public function testExecuteWithCount(): void
336336
{
337337
$application = new PhinxApplication();
338-
$application->add(new Migrate());
338+
$application->addCommand(new Migrate());
339339

340340
/** @var Migrate $command */
341341
$command = $application->find('migrate');
@@ -369,7 +369,7 @@ public function testExecuteWithError(): void
369369
$exception = new RuntimeException('oops');
370370

371371
$application = new PhinxApplication();
372-
$application->add(new Migrate());
372+
$application->addCommand(new Migrate());
373373

374374
/** @var Migrate $command */
375375
$command = $application->find('migrate');

0 commit comments

Comments
 (0)