Skip to content

Commit

Permalink
Merge pull request #105 from lion-packages/support
Browse files Browse the repository at this point in the history
Removed screen outputs for running seed groups and migrations
  • Loading branch information
GabrielPalac authored Nov 29, 2024
2 parents 844f08b + b126581 commit a5f4481
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 57 deletions.
25 changes: 8 additions & 17 deletions src/LionBundle/Helpers/Commands/Migrations/Migrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,14 @@ public function executeMigrationsGroup(array $list): void
}
}

$execute = function (MigrationUpInterface $migration, string $namespace): void {
$response = $migration->up();

echo("\033[0;33m\t>> MIGRATION: {$namespace}\033[0m\n");

if (isError($response)) {
echo("\033[0;31m\t>> MIGRATION: {$response->message}\033[0m\n");
} else {
echo("\033[0;32m\t>> MIGRATION: {$response->message}\033[0m\n");
}
};

$run = function (array $list) use ($execute): void {
foreach ($list as $namespace => $migration) {
$execute($migration, $namespace);
/**
* @param array<string, MigrationUpInterface> $list
*
* @return void
*/
$run = function (array $list): void {
foreach ($list as $migration) {
$migration->up();
}
};

Expand All @@ -208,7 +201,5 @@ public function executeMigrationsGroup(array $list): void
$run($migrations[ViewInterface::class]);

$run($migrations[StoreProcedureInterface::class]);

echo("\n\033[0;36m\t>> Migration group executed successfully\033[0m \n");
}
}
25 changes: 8 additions & 17 deletions src/LionBundle/Helpers/Commands/Seeds/Seeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,17 @@ public function executeSeedsGroup(array $list): void
$seeds[$namespace] = $classObject;
}

$execute = function (SeedInterface $seed, string $namespace): void {
$response = $seed->run();

echo("\033[0;33m\t>> SEED: {$namespace}\033[0m\n");

if (isError($response)) {
echo("\033[0;31m\t>> SEED: {$response->message}\033[0m\n");
} else {
echo("\033[0;32m\t>> SEED: {$response->message}\033[0m\n");
}
};

$run = function (array $list) use ($execute): void {
foreach ($list as $namespace => $seed) {
$execute($seed, $namespace);
/**
* @param array<string, SeedInterface> $list
*
* @return void
*/
$run = function (array $list): void {
foreach ($list as $seed) {
$seed->run();
}
};

$run($this->migrations->orderList($seeds));

echo("\n\033[0;36m\t>> Seed group executed successfully\033[0m \n");
}
}
15 changes: 0 additions & 15 deletions tests/Helpers/Commands/Migrations/MigrationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,25 +210,10 @@ public function executeMigrationsGroup(): void
StoreProcedureInterface::class,
]);

ob_start();

$this->migrations->executeMigrationsGroup([
self::CLASS_NAMESPACE_TABLE . self::CLASS_NAME,
self::CLASS_NAMESPACE_VIEW . self::CLASS_NAME,
self::CLASS_NAMESPACE_STORE_PROCEDURE . self::CLASS_NAME,
]);

$output = ob_get_clean();

$this->assertStringContainsString('execution finished', $output);
$this->assertStringContainsString('Database\Migrations\LionDatabase\MySQL\Tables\TestMigration', $output);
$this->assertStringContainsString('Database\Migrations\LionDatabase\MySQL\Views\TestMigration', $output);

$this->assertStringContainsString(
'Database\Migrations\LionDatabase\MySQL\StoreProcedures\TestMigration',
$output
);

$this->assertStringContainsString('Migration group executed successfully', $output);
}
}
8 changes: 0 additions & 8 deletions tests/Helpers/Commands/Seeds/SeedsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,8 @@ public function executeSeedsGroup(): void
self::NAMESPACE_SEED . self::SEED_NAME,
]);

ob_start();

$this->seeds->executeSeedsGroup([
self::NAMESPACE_SEED . self::SEED_NAME,
]);

$output = ob_get_clean();

$this->assertStringContainsString('Database\Seed\TestSeed', $output);
$this->assertStringContainsString('run seed', $output);
$this->assertStringContainsString('Seed group executed successfully', $output);
}
}

0 comments on commit a5f4481

Please sign in to comment.