diff --git a/src/LionBundle/Helpers/Commands/Migrations/Migrations.php b/src/LionBundle/Helpers/Commands/Migrations/Migrations.php index 628bd4f..1e423fe 100644 --- a/src/LionBundle/Helpers/Commands/Migrations/Migrations.php +++ b/src/LionBundle/Helpers/Commands/Migrations/Migrations.php @@ -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 $list + * + * @return void + */ + $run = function (array $list): void { + foreach ($list as $migration) { + $migration->up(); } }; @@ -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"); } } diff --git a/src/LionBundle/Helpers/Commands/Seeds/Seeds.php b/src/LionBundle/Helpers/Commands/Seeds/Seeds.php index 43cbc6f..1ca153a 100644 --- a/src/LionBundle/Helpers/Commands/Seeds/Seeds.php +++ b/src/LionBundle/Helpers/Commands/Seeds/Seeds.php @@ -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 $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"); } } diff --git a/tests/Helpers/Commands/Migrations/MigrationsTest.php b/tests/Helpers/Commands/Migrations/MigrationsTest.php index 94e9549..65c582f 100644 --- a/tests/Helpers/Commands/Migrations/MigrationsTest.php +++ b/tests/Helpers/Commands/Migrations/MigrationsTest.php @@ -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); } } diff --git a/tests/Helpers/Commands/Seeds/SeedsTest.php b/tests/Helpers/Commands/Seeds/SeedsTest.php index fee6c7f..f246765 100644 --- a/tests/Helpers/Commands/Seeds/SeedsTest.php +++ b/tests/Helpers/Commands/Seeds/SeedsTest.php @@ -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); } }