From 0619791f7f960f4baa40e6b5f6706996b4532d79 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 2 Jan 2026 20:49:02 +0100 Subject: [PATCH 1/3] Strip 'Seed' suffix from seed names in all command output Makes seed name display consistent across all commands by removing the 'Seed' suffix. The run command confirmation was already doing this, but status, reset, and execution output still showed the full class name. --- src/Command/SeedResetCommand.php | 9 ++++- src/Command/SeedStatusCommand.php | 8 +++- src/Migration/Manager.php | 7 +++- tests/TestCase/Command/SeedCommandTest.php | 44 +++++++++++----------- 4 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/Command/SeedResetCommand.php b/src/Command/SeedResetCommand.php index 27461d10..e02ef8b7 100644 --- a/src/Command/SeedResetCommand.php +++ b/src/Command/SeedResetCommand.php @@ -132,14 +132,19 @@ public function execute(Arguments $args, ConsoleIo $io): ?int // Reset the seeds $count = 0; foreach ($seedsToReset as $seed) { + $seedName = $seed->getName(); + if (str_ends_with($seedName, 'Seed')) { + $seedName = substr($seedName, 0, -4); + } + if ($manager->isSeedExecuted($seed)) { if (!$config->isDryRun()) { $adapter->removeSeedFromLog($seed); } - $io->info("Reset: {$seed->getName()}"); + $io->info("Reset: {$seedName}"); $count++; } else { - $io->verbose("Skipped (not executed): {$seed->getName()}"); + $io->verbose("Skipped (not executed): {$seedName}"); } } diff --git a/src/Command/SeedStatusCommand.php b/src/Command/SeedStatusCommand.php index 6647a627..f8dae29c 100644 --- a/src/Command/SeedStatusCommand.php +++ b/src/Command/SeedStatusCommand.php @@ -129,8 +129,14 @@ public function execute(Arguments $args, ConsoleIo $io): ?int } } + // Strip 'Seed' suffix for display + $displayName = $seedName; + if (str_ends_with($displayName, 'Seed')) { + $displayName = substr($displayName, 0, -4); + } + $statuses[] = [ - 'seedName' => $seedName, + 'seedName' => $displayName, 'plugin' => $plugin, 'status' => $executed ? 'executed' : 'pending', 'executedAt' => $executedAt, diff --git a/src/Migration/Manager.php b/src/Migration/Manager.php index bb32ce69..9ca7d5a4 100644 --- a/src/Migration/Manager.php +++ b/src/Migration/Manager.php @@ -619,8 +619,13 @@ protected function printMigrationStatus(MigrationInterface $migration, string $s */ protected function printSeedStatus(SeedInterface $seed, string $status, ?string $duration = null): void { + $seedName = $seed->getName(); + if (str_ends_with($seedName, 'Seed')) { + $seedName = substr($seedName, 0, -4); + } + $this->printStatusOutput( - $seed->getName(), + $seedName, $status, $duration, ); diff --git a/tests/TestCase/Command/SeedCommandTest.php b/tests/TestCase/Command/SeedCommandTest.php index 9271b326..8ccf743f 100644 --- a/tests/TestCase/Command/SeedCommandTest.php +++ b/tests/TestCase/Command/SeedCommandTest.php @@ -96,7 +96,7 @@ public function testSeederOne(): void $this->exec('seeds run -c test NumbersSeed'); $this->assertExitSuccess(); - $this->assertOutputContains('NumbersSeed: seeding'); + $this->assertOutputContains('Numbers: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -111,7 +111,7 @@ public function testSeederBaseSeed(): void $this->exec('seeds run -c test --source BaseSeeds MigrationSeedNumbers'); $this->assertExitSuccess(); $this->assertOutputContains('MigrationSeedNumbers: seeding'); - $this->assertOutputContains('AnotherNumbersSeed: seeding'); + $this->assertOutputContains('AnotherNumbers: seeding'); $this->assertOutputContains('radix=10'); $this->assertOutputContains('fetchRow=121'); $this->assertOutputContains('hasTable=1'); @@ -154,8 +154,8 @@ public function testSeederMultiple(): void $this->exec('seeds run -c test --source CallSeeds LettersSeed,NumbersCallSeed'); $this->assertExitSuccess(); - $this->assertOutputContains('NumbersCallSeed: seeding'); - $this->assertOutputContains('LettersSeed: seeding'); + $this->assertOutputContains('NumbersCall: seeding'); + $this->assertOutputContains('Letters: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -182,7 +182,7 @@ public function testSeederWithTimestampFields(): void $this->exec('seeds run -c test StoresSeed'); $this->assertExitSuccess(); - $this->assertOutputContains('StoresSeed: seeding'); + $this->assertOutputContains('Stores: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -208,7 +208,7 @@ public function testDryRunModeWarning(): void $this->assertExitSuccess(); $this->assertOutputContains('DRY-RUN mode enabled'); - $this->assertOutputContains('NumbersSeed: seeding'); + $this->assertOutputContains('Numbers: seeding'); $this->assertOutputContains('All Done'); } @@ -219,7 +219,7 @@ public function testDryRunModeShortOption(): void $this->assertExitSuccess(); $this->assertOutputContains('DRY-RUN mode enabled'); - $this->assertOutputContains('NumbersSeed: seeding'); + $this->assertOutputContains('Numbers: seeding'); $this->assertOutputContains('All Done'); } @@ -245,8 +245,8 @@ public function testDryRunModeMultipleSeeds(): void $this->assertExitSuccess(); $this->assertOutputContains('DRY-RUN mode enabled'); - $this->assertOutputContains('NumbersCallSeed: seeding'); - $this->assertOutputContains('LettersSeed: seeding'); + $this->assertOutputContains('NumbersCall: seeding'); + $this->assertOutputContains('Letters: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -303,7 +303,7 @@ public function testDryRunModeWithStoresSeed(): void $this->exec('seeds run -c test StoresSeed --dry-run'); $this->assertExitSuccess(); $this->assertOutputContains('DRY-RUN mode enabled'); - $this->assertOutputContains('StoresSeed: seeding'); + $this->assertOutputContains('Stores: seeding'); $finalCount = $connection->execute('SELECT COUNT(*) FROM stores')->fetchColumn(0); $this->assertEquals($initialCount, $finalCount, 'Dry-run mode should not modify stores table'); @@ -315,7 +315,7 @@ public function testSeederAnonymousClass(): void $this->exec('seeds run -c test AnonymousStoreSeed'); $this->assertExitSuccess(); - $this->assertOutputContains('AnonymousStoreSeed: seeding'); + $this->assertOutputContains('AnonymousStore: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -334,7 +334,7 @@ public function testSeederShortName(): void $this->exec('seeds run -c test Numbers'); $this->assertExitSuccess(); - $this->assertOutputContains('NumbersSeed: seeding'); + $this->assertOutputContains('Numbers: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -349,8 +349,8 @@ public function testSeederShortNameMultiple(): void $this->exec('seeds run -c test --source CallSeeds Letters,NumbersCall'); $this->assertExitSuccess(); - $this->assertOutputContains('NumbersCallSeed: seeding'); - $this->assertOutputContains('LettersSeed: seeding'); + $this->assertOutputContains('NumbersCall: seeding'); + $this->assertOutputContains('Letters: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -368,7 +368,7 @@ public function testSeederShortNameAnonymous(): void $this->exec('seeds run -c test AnonymousStore'); $this->assertExitSuccess(); - $this->assertOutputContains('AnonymousStoreSeed: seeding'); + $this->assertOutputContains('AnonymousStore: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -417,7 +417,7 @@ public function testSeederSpecificSeedSkipsConfirmation(): void $this->assertExitSuccess(); $this->assertOutputNotContains('The following seeds will be executed:'); $this->assertOutputNotContains('Do you want to continue?'); - $this->assertOutputContains('NumbersSeed: seeding'); + $this->assertOutputContains('Numbers: seeding'); $this->assertOutputContains('All Done'); } @@ -427,8 +427,8 @@ public function testSeederCommaSeparated(): void $this->exec('seeds run -c test --source CallSeeds Letters,NumbersCall'); $this->assertExitSuccess(); - $this->assertOutputContains('NumbersCallSeed: seeding'); - $this->assertOutputContains('LettersSeed: seeding'); + $this->assertOutputContains('NumbersCall: seeding'); + $this->assertOutputContains('Letters: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -450,7 +450,7 @@ public function testSeedStateTracking(): void // First run should execute the seed $this->exec('seeds run -c test NumbersSeed'); $this->assertExitSuccess(); - $this->assertOutputContains('NumbersSeed: seeding'); + $this->assertOutputContains('Numbers: seeding'); $this->assertOutputContains('All Done'); // Verify data was inserted @@ -460,7 +460,7 @@ public function testSeedStateTracking(): void // Second run should skip the seed (already executed) $this->exec('seeds run -c test NumbersSeed'); $this->assertExitSuccess(); - $this->assertOutputContains('NumbersSeed: already executed'); + $this->assertOutputContains('Numbers: already executed'); $this->assertOutputNotContains('seeding'); // Verify no additional data was inserted @@ -470,7 +470,7 @@ public function testSeedStateTracking(): void // Run with --force should re-execute $this->exec('seeds run -c test NumbersSeed --force'); $this->assertExitSuccess(); - $this->assertOutputContains('NumbersSeed: seeding'); + $this->assertOutputContains('Numbers: seeding'); // Verify data was inserted again (now 2 records) $query = $connection->execute('SELECT COUNT(*) FROM numbers'); @@ -495,7 +495,7 @@ public function testSeedStatusCommand(): void $this->exec('seeds status -c test'); $this->assertExitSuccess(); $this->assertOutputContains('executed'); - $this->assertOutputContains('NumbersSeed'); + $this->assertOutputContains('Numbers'); } public function testSeedResetCommand(): void From 2f706f9af68c00d2306b48b92e79f2cd7671ee6b Mon Sep 17 00:00:00 2001 From: mscherer Date: Sat, 3 Jan 2026 16:41:16 +0100 Subject: [PATCH 2/3] Add ' seed' suffix to display names for clarity Changes output from "Users" to "Users seed" to make it clearer that seeds are being displayed, not other entities. --- src/Command/SeedResetCommand.php | 4 +- src/Command/SeedStatusCommand.php | 3 +- src/Migration/Manager.php | 2 +- tests/TestCase/Command/SeedCommandTest.php | 44 +++++++++++----------- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/Command/SeedResetCommand.php b/src/Command/SeedResetCommand.php index e02ef8b7..c3d2d5ab 100644 --- a/src/Command/SeedResetCommand.php +++ b/src/Command/SeedResetCommand.php @@ -141,10 +141,10 @@ public function execute(Arguments $args, ConsoleIo $io): ?int if (!$config->isDryRun()) { $adapter->removeSeedFromLog($seed); } - $io->info("Reset: {$seedName}"); + $io->info("Reset: {$seedName} seed"); $count++; } else { - $io->verbose("Skipped (not executed): {$seedName}"); + $io->verbose("Skipped (not executed): {$seedName} seed"); } } diff --git a/src/Command/SeedStatusCommand.php b/src/Command/SeedStatusCommand.php index f8dae29c..1b1c8af8 100644 --- a/src/Command/SeedStatusCommand.php +++ b/src/Command/SeedStatusCommand.php @@ -129,11 +129,12 @@ public function execute(Arguments $args, ConsoleIo $io): ?int } } - // Strip 'Seed' suffix for display + // Strip 'Seed' suffix for display and add ' seed' suffix $displayName = $seedName; if (str_ends_with($displayName, 'Seed')) { $displayName = substr($displayName, 0, -4); } + $displayName .= ' seed'; $statuses[] = [ 'seedName' => $displayName, diff --git a/src/Migration/Manager.php b/src/Migration/Manager.php index 9ca7d5a4..1693b44e 100644 --- a/src/Migration/Manager.php +++ b/src/Migration/Manager.php @@ -625,7 +625,7 @@ protected function printSeedStatus(SeedInterface $seed, string $status, ?string } $this->printStatusOutput( - $seedName, + $seedName . ' seed', $status, $duration, ); diff --git a/tests/TestCase/Command/SeedCommandTest.php b/tests/TestCase/Command/SeedCommandTest.php index 8ccf743f..77935ae4 100644 --- a/tests/TestCase/Command/SeedCommandTest.php +++ b/tests/TestCase/Command/SeedCommandTest.php @@ -96,7 +96,7 @@ public function testSeederOne(): void $this->exec('seeds run -c test NumbersSeed'); $this->assertExitSuccess(); - $this->assertOutputContains('Numbers: seeding'); + $this->assertOutputContains('Numbers seed: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -110,8 +110,8 @@ public function testSeederBaseSeed(): void $this->createTables(); $this->exec('seeds run -c test --source BaseSeeds MigrationSeedNumbers'); $this->assertExitSuccess(); - $this->assertOutputContains('MigrationSeedNumbers: seeding'); - $this->assertOutputContains('AnotherNumbers: seeding'); + $this->assertOutputContains('MigrationSeedNumbers seed: seeding'); + $this->assertOutputContains('AnotherNumbers seed: seeding'); $this->assertOutputContains('radix=10'); $this->assertOutputContains('fetchRow=121'); $this->assertOutputContains('hasTable=1'); @@ -154,8 +154,8 @@ public function testSeederMultiple(): void $this->exec('seeds run -c test --source CallSeeds LettersSeed,NumbersCallSeed'); $this->assertExitSuccess(); - $this->assertOutputContains('NumbersCall: seeding'); - $this->assertOutputContains('Letters: seeding'); + $this->assertOutputContains('NumbersCall seed: seeding'); + $this->assertOutputContains('Letters seed: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -182,7 +182,7 @@ public function testSeederWithTimestampFields(): void $this->exec('seeds run -c test StoresSeed'); $this->assertExitSuccess(); - $this->assertOutputContains('Stores: seeding'); + $this->assertOutputContains('Stores seed: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -208,7 +208,7 @@ public function testDryRunModeWarning(): void $this->assertExitSuccess(); $this->assertOutputContains('DRY-RUN mode enabled'); - $this->assertOutputContains('Numbers: seeding'); + $this->assertOutputContains('Numbers seed: seeding'); $this->assertOutputContains('All Done'); } @@ -219,7 +219,7 @@ public function testDryRunModeShortOption(): void $this->assertExitSuccess(); $this->assertOutputContains('DRY-RUN mode enabled'); - $this->assertOutputContains('Numbers: seeding'); + $this->assertOutputContains('Numbers seed: seeding'); $this->assertOutputContains('All Done'); } @@ -245,8 +245,8 @@ public function testDryRunModeMultipleSeeds(): void $this->assertExitSuccess(); $this->assertOutputContains('DRY-RUN mode enabled'); - $this->assertOutputContains('NumbersCall: seeding'); - $this->assertOutputContains('Letters: seeding'); + $this->assertOutputContains('NumbersCall seed: seeding'); + $this->assertOutputContains('Letters seed: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -303,7 +303,7 @@ public function testDryRunModeWithStoresSeed(): void $this->exec('seeds run -c test StoresSeed --dry-run'); $this->assertExitSuccess(); $this->assertOutputContains('DRY-RUN mode enabled'); - $this->assertOutputContains('Stores: seeding'); + $this->assertOutputContains('Stores seed: seeding'); $finalCount = $connection->execute('SELECT COUNT(*) FROM stores')->fetchColumn(0); $this->assertEquals($initialCount, $finalCount, 'Dry-run mode should not modify stores table'); @@ -315,7 +315,7 @@ public function testSeederAnonymousClass(): void $this->exec('seeds run -c test AnonymousStoreSeed'); $this->assertExitSuccess(); - $this->assertOutputContains('AnonymousStore: seeding'); + $this->assertOutputContains('AnonymousStore seed: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -334,7 +334,7 @@ public function testSeederShortName(): void $this->exec('seeds run -c test Numbers'); $this->assertExitSuccess(); - $this->assertOutputContains('Numbers: seeding'); + $this->assertOutputContains('Numbers seed: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -349,8 +349,8 @@ public function testSeederShortNameMultiple(): void $this->exec('seeds run -c test --source CallSeeds Letters,NumbersCall'); $this->assertExitSuccess(); - $this->assertOutputContains('NumbersCall: seeding'); - $this->assertOutputContains('Letters: seeding'); + $this->assertOutputContains('NumbersCall seed: seeding'); + $this->assertOutputContains('Letters seed: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -368,7 +368,7 @@ public function testSeederShortNameAnonymous(): void $this->exec('seeds run -c test AnonymousStore'); $this->assertExitSuccess(); - $this->assertOutputContains('AnonymousStore: seeding'); + $this->assertOutputContains('AnonymousStore seed: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -417,7 +417,7 @@ public function testSeederSpecificSeedSkipsConfirmation(): void $this->assertExitSuccess(); $this->assertOutputNotContains('The following seeds will be executed:'); $this->assertOutputNotContains('Do you want to continue?'); - $this->assertOutputContains('Numbers: seeding'); + $this->assertOutputContains('Numbers seed: seeding'); $this->assertOutputContains('All Done'); } @@ -427,8 +427,8 @@ public function testSeederCommaSeparated(): void $this->exec('seeds run -c test --source CallSeeds Letters,NumbersCall'); $this->assertExitSuccess(); - $this->assertOutputContains('NumbersCall: seeding'); - $this->assertOutputContains('Letters: seeding'); + $this->assertOutputContains('NumbersCall seed: seeding'); + $this->assertOutputContains('Letters seed: seeding'); $this->assertOutputContains('All Done'); /** @var \Cake\Database\Connection $connection */ @@ -450,7 +450,7 @@ public function testSeedStateTracking(): void // First run should execute the seed $this->exec('seeds run -c test NumbersSeed'); $this->assertExitSuccess(); - $this->assertOutputContains('Numbers: seeding'); + $this->assertOutputContains('Numbers seed: seeding'); $this->assertOutputContains('All Done'); // Verify data was inserted @@ -460,7 +460,7 @@ public function testSeedStateTracking(): void // Second run should skip the seed (already executed) $this->exec('seeds run -c test NumbersSeed'); $this->assertExitSuccess(); - $this->assertOutputContains('Numbers: already executed'); + $this->assertOutputContains('Numbers seed: already executed'); $this->assertOutputNotContains('seeding'); // Verify no additional data was inserted @@ -470,7 +470,7 @@ public function testSeedStateTracking(): void // Run with --force should re-execute $this->exec('seeds run -c test NumbersSeed --force'); $this->assertExitSuccess(); - $this->assertOutputContains('Numbers: seeding'); + $this->assertOutputContains('Numbers seed: seeding'); // Verify data was inserted again (now 2 records) $query = $connection->execute('SELECT COUNT(*) FROM numbers'); From 228f248f65f90f4a2232143b8bca204c564b215a Mon Sep 17 00:00:00 2001 From: mscherer Date: Mon, 5 Jan 2026 23:54:08 +0100 Subject: [PATCH 3/3] Refactor seed display name logic to utility method Move the seed name suffix stripping logic to Util::getSeedDisplayName() to avoid code duplication across SeedCommand, SeedResetCommand, SeedStatusCommand, and Manager. --- src/Command/SeedCommand.php | 7 ++----- src/Command/SeedResetCommand.php | 13 +++---------- src/Command/SeedStatusCommand.php | 7 ++----- src/Migration/Manager.php | 7 +------ src/Util/Util.php | 17 +++++++++++++++++ 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/Command/SeedCommand.php b/src/Command/SeedCommand.php index 8c74e25a..b7562809 100644 --- a/src/Command/SeedCommand.php +++ b/src/Command/SeedCommand.php @@ -21,6 +21,7 @@ use Exception; use Migrations\Config\ConfigInterface; use Migrations\Migration\ManagerFactory; +use Migrations\Util\Util; /** * Seed command runs seeder scripts @@ -182,11 +183,7 @@ protected function executeSeeds(Arguments $args, ConsoleIo $io): ?int $io->out(''); $io->out('The following seeds will be executed:'); foreach ($availableSeeds as $seed) { - $seedName = $seed->getName(); - if (str_ends_with($seedName, 'Seed')) { - $seedName = substr($seedName, 0, -4); - } - $io->out(' - ' . $seedName); + $io->out(' - ' . Util::getSeedDisplayName($seed->getName())); } $io->out(''); if (!(bool)$args->getOption('force')) { diff --git a/src/Command/SeedResetCommand.php b/src/Command/SeedResetCommand.php index c3d2d5ab..18ef30b1 100644 --- a/src/Command/SeedResetCommand.php +++ b/src/Command/SeedResetCommand.php @@ -19,6 +19,7 @@ use Cake\Console\ConsoleOptionParser; use Migrations\Config\ConfigInterface; use Migrations\Migration\ManagerFactory; +use Migrations\Util\Util; /** * Seed reset command removes seeds from the execution log @@ -112,11 +113,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int $io->out(''); $io->out('All seeds will be reset:'); foreach ($seedsToReset as $seed) { - $seedName = $seed->getName(); - if (str_ends_with($seedName, 'Seed')) { - $seedName = substr($seedName, 0, -4); - } - $io->out(' - ' . $seedName); + $io->out(' - ' . Util::getSeedDisplayName($seed->getName())); } $io->out(''); @@ -132,11 +129,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int // Reset the seeds $count = 0; foreach ($seedsToReset as $seed) { - $seedName = $seed->getName(); - if (str_ends_with($seedName, 'Seed')) { - $seedName = substr($seedName, 0, -4); - } - + $seedName = Util::getSeedDisplayName($seed->getName()); if ($manager->isSeedExecuted($seed)) { if (!$config->isDryRun()) { $adapter->removeSeedFromLog($seed); diff --git a/src/Command/SeedStatusCommand.php b/src/Command/SeedStatusCommand.php index 1b1c8af8..bf4038e1 100644 --- a/src/Command/SeedStatusCommand.php +++ b/src/Command/SeedStatusCommand.php @@ -20,6 +20,7 @@ use Cake\Core\Configure; use Migrations\Config\ConfigInterface; use Migrations\Migration\ManagerFactory; +use Migrations\Util\Util; /** * Seed status command shows which seeds have been executed @@ -130,11 +131,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int } // Strip 'Seed' suffix for display and add ' seed' suffix - $displayName = $seedName; - if (str_ends_with($displayName, 'Seed')) { - $displayName = substr($displayName, 0, -4); - } - $displayName .= ' seed'; + $displayName = Util::getSeedDisplayName($seedName) . ' seed'; $statuses[] = [ 'seedName' => $displayName, diff --git a/src/Migration/Manager.php b/src/Migration/Manager.php index 1693b44e..963bd57f 100644 --- a/src/Migration/Manager.php +++ b/src/Migration/Manager.php @@ -619,13 +619,8 @@ protected function printMigrationStatus(MigrationInterface $migration, string $s */ protected function printSeedStatus(SeedInterface $seed, string $status, ?string $duration = null): void { - $seedName = $seed->getName(); - if (str_ends_with($seedName, 'Seed')) { - $seedName = substr($seedName, 0, -4); - } - $this->printStatusOutput( - $seedName . ' seed', + Util::getSeedDisplayName($seed->getName()) . ' seed', $status, $duration, ); diff --git a/src/Util/Util.php b/src/Util/Util.php index 90f101f9..e8138cd0 100644 --- a/src/Util/Util.php +++ b/src/Util/Util.php @@ -192,6 +192,23 @@ public static function isValidSeedFileName(string $fileName): bool return (bool)preg_match(static::SEED_FILE_NAME_PATTERN, $fileName); } + /** + * Get a human-readable display name for a seed class. + * + * Strips the 'Seed' suffix from class names like 'UsersSeed' to produce 'Users'. + * + * @param string $seedName The seed class name + * @return string The display name without the 'Seed' suffix + */ + public static function getSeedDisplayName(string $seedName): string + { + if (str_ends_with($seedName, 'Seed')) { + return substr($seedName, 0, -4); + } + + return $seedName; + } + /** * Expands a set of paths with curly braces (if supported by the OS). *