Skip to content

Commit b7d251a

Browse files
Fix up short name to work with seeding. (#868)
* Fix up short name to work with seeding. * Update src/Util/SchemaTrait.php Co-authored-by: Jamison Bryant <jamison@bryant.ai>
1 parent 5701645 commit b7d251a

11 files changed

Lines changed: 82 additions & 21 deletions

File tree

src/Db/Adapter/AbstractAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ public function executeActions(TableMetadata $table, array $actions): void
14261426

14271427
default:
14281428
throw new InvalidArgumentException(
1429-
sprintf("Don't know how to execute action: '%s'", get_class($action)),
1429+
sprintf("Don't know how to execute action `%s`", get_class($action)),
14301430
);
14311431
}
14321432
}

src/Db/Adapter/AdapterFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function registerAdapter(string $name, Closure|string $class)
7575
!($class instanceof Closure || is_subclass_of($class, AdapterInterface::class))
7676
) {
7777
throw new RuntimeException(sprintf(
78-
'Adapter class "%s" must implement Migrations\\Db\\Adapter\\AdapterInterface',
78+
'Adapter class `%s` must implement `Migrations\\Db\\Adapter\\AdapterInterface`',
7979
$class,
8080
));
8181
}
@@ -119,7 +119,7 @@ public function registerWrapper(string $name, string $class)
119119
{
120120
if (!is_subclass_of($class, WrapperInterface::class)) {
121121
throw new RuntimeException(sprintf(
122-
'Wrapper class "%s" must implement Migrations\\Db\\Adapter\\WrapperInterface',
122+
'Wrapper class `%s` must implement `Migrations\\Db\\Adapter\\WrapperInterface`',
123123
$class,
124124
));
125125
}

src/Db/Adapter/MysqlAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ protected function getDropIndexByColumnsInstructions(string $tableName, $columns
643643
}
644644

645645
throw new InvalidArgumentException(sprintf(
646-
"The specified index on columns '%s' does not exist",
646+
'The specified index on columns `%s` does not exist',
647647
implode(',', $columns),
648648
));
649649
}
@@ -667,7 +667,7 @@ protected function getDropIndexByNameInstructions(string $tableName, $indexName)
667667
}
668668

669669
throw new InvalidArgumentException(sprintf(
670-
"The specified index name '%s' does not exist",
670+
'The specified index name `%s` does not exist',
671671
$indexName,
672672
));
673673
}

src/Db/Adapter/PostgresAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ protected function getDropIndexByColumnsInstructions(string $tableName, $columns
709709
}
710710

711711
throw new InvalidArgumentException(sprintf(
712-
"The specified index on columns '%s' does not exist",
712+
'The specified index on columns `%s` does not exist',
713713
implode(',', $columns),
714714
));
715715
}

src/Db/Adapter/SqlserverAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ protected function getDropIndexByColumnsInstructions(string $tableName, $columns
702702
}
703703

704704
throw new InvalidArgumentException(sprintf(
705-
"The specified index on columns '%s' does not exist",
705+
'The specified index on columns `%s` does not exist',
706706
implode(',', $columns),
707707
));
708708
}
@@ -730,7 +730,7 @@ protected function getDropIndexByNameInstructions(string $tableName, string $ind
730730
}
731731

732732
throw new InvalidArgumentException(sprintf(
733-
"The specified index name '%s' does not exist",
733+
'The specified index name `%s` does not exist',
734734
$indexName,
735735
));
736736
}

src/Migration/Manager.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -669,10 +669,13 @@ public function seed(?string $seed = null): void
669669
}
670670
} else {
671671
// run only one seeder
672-
if (array_key_exists($seed, $seeds)) {
672+
if (array_key_exists($seed . 'Seed', $seeds)) {
673+
$seed = $seed . 'Seed';
674+
$this->executeSeed($seeds[$seed]);
675+
} elseif (array_key_exists($seed, $seeds)) {
673676
$this->executeSeed($seeds[$seed]);
674677
} else {
675-
throw new InvalidArgumentException(sprintf('The seed class "%s" does not exist', $seed));
678+
throw new InvalidArgumentException(sprintf('The seed `%s` does not exist', $seed));
676679
}
677680
}
678681
}
@@ -825,7 +828,7 @@ function ($phpFile) {
825828
ini_set('display_errors', $orig_display_errors_setting);
826829
if (!class_exists($class)) {
827830
throw new InvalidArgumentException(sprintf(
828-
'Could not find class "%s" in file "%s"',
831+
'Could not find class `%s` in file `%s`',
829832
$class,
830833
$filePath,
831834
));
@@ -953,7 +956,7 @@ public function getSeeds(): array
953956
require_once $filePath;
954957
if (!class_exists($class)) {
955958
throw new InvalidArgumentException(sprintf(
956-
'Could not find class "%s" in file "%s"',
959+
'Could not find class `%s` in file `%s`',
957960
$class,
958961
$filePath,
959962
));

src/Util/SchemaTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ protected function _getSchema(InputInterface $input, OutputInterface $output): ?
3939

4040
if (!method_exists($connection, 'getSchemaCollection')) {
4141
$msg = sprintf(
42-
'The "%s" connection is not compatible with orm caching, ' .
43-
'as it does not implement a "getSchemaCollection()" method.',
42+
'The `%s` connection is not compatible with ORM caching, ' .
43+
'as it does not implement a `getSchemaCollection()` method.',
4444
$connectionName,
4545
);
4646
$output->writeln('<error>' . $msg . '</error>');

tests/TestCase/Command/SeedCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function testBeforeSeederAbort(): void
112112
public function testSeederUnknown(): void
113113
{
114114
$this->expectException(InvalidArgumentException::class);
115-
$this->expectExceptionMessage('The seed class "NotThere" does not exist');
115+
$this->expectExceptionMessage('The seed `NotThere` does not exist');
116116
$this->exec('migrations seed -c test --seed NotThere');
117117
}
118118

@@ -170,7 +170,7 @@ public function testSeederMultipleNotFound(): void
170170
$this->createTables();
171171

172172
$this->expectException(InvalidArgumentException::class);
173-
$this->expectExceptionMessage('The seed class "NotThere" does not exist');
173+
$this->expectExceptionMessage('The seed `NotThere` does not exist');
174174
$this->exec('migrations seed -c test --seed NumbersSeed --seed NotThere');
175175
}
176176

@@ -197,7 +197,7 @@ public function testSeederSourceNotFound(): void
197197
{
198198
$this->createTables();
199199
$this->expectException(InvalidArgumentException::class);
200-
$this->expectExceptionMessage('The seed class "LettersSeed" does not exist');
200+
$this->expectExceptionMessage('The seed `LettersSeed` does not exist');
201201

202202
$this->exec('migrations seed -c test --source NotThere --seed LettersSeed');
203203
}

tests/TestCase/Db/Adapter/AdapterFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testRegisterAdapterFailure()
5151
$adapter = static::class;
5252

5353
$this->expectException(RuntimeException::class);
54-
$this->expectExceptionMessage('Adapter class "Migrations\Test\Db\Adapter\AdapterFactoryTest" must implement Migrations\Db\Adapter\AdapterInterface');
54+
$this->expectExceptionMessage('Adapter class `Migrations\Test\Db\Adapter\AdapterFactoryTest` must implement `Migrations\Db\Adapter\AdapterInterface`');
5555

5656
$this->factory->registerAdapter('test', $adapter);
5757
}
@@ -89,7 +89,7 @@ public function testRegisterWrapperFailure()
8989
$wrapper = static::class;
9090

9191
$this->expectException(RuntimeException::class);
92-
$this->expectExceptionMessage('Wrapper class "Migrations\Test\Db\Adapter\AdapterFactoryTest" must implement Migrations\Db\Adapter\WrapperInterface');
92+
$this->expectExceptionMessage('Wrapper class `Migrations\Test\Db\Adapter\AdapterFactoryTest` must implement `Migrations\Db\Adapter\WrapperInterface`');
9393

9494
$this->factory->registerWrapper('test', $wrapper);
9595
}

tests/TestCase/Migration/ManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,7 @@ public function testExecuteANonExistentSeedWorksAsExpected(): void
21772177
$this->manager->setEnvironment($envStub);
21782178

21792179
$this->expectException(InvalidArgumentException::class);
2180-
$this->expectExceptionMessage('The seed class "NonExistentSeeder" does not exist');
2180+
$this->expectExceptionMessage('The seed `NonExistentSeeder` does not exist');
21812181

21822182
$this->manager->seed('NonExistentSeeder');
21832183
}

0 commit comments

Comments
 (0)