From 4168320ab97bbadef4b3646624572e9fd6061385 Mon Sep 17 00:00:00 2001 From: Florian PARRENO Date: Wed, 17 Jul 2024 09:22:48 +0200 Subject: [PATCH 1/3] Use APP_ENV variable to enable enduser to make command more flexible --- Resources/views/template.txt.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/template.txt.twig b/Resources/views/template.txt.twig index 9e3f9fe..51d8d60 100644 --- a/Resources/views/template.txt.twig +++ b/Resources/views/template.txt.twig @@ -4,6 +4,6 @@ MAILTO="{{ mailto }}" {% for cron in crons %} # {{ cron.name }} -{{ cron.expression }} {{ user }} {{ php_version }} {{ absolute_path }} {{ cron.command }} --env={{ env }} +{{ cron.expression }} {{ user }} APP_ENV={{ env }} {{ php_version }} {{ absolute_path }} {{ cron.command }} {% endfor %} From a2571bba93764d90d3c43960ca913383871d80af Mon Sep 17 00:00:00 2001 From: Florian PARRENO Date: Wed, 17 Jul 2024 09:29:15 +0200 Subject: [PATCH 2/3] Update tests to check for APP_ENV --- .../Functional/Command/GenerateCronFileCommandTest.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Tests/Functional/Command/GenerateCronFileCommandTest.php b/Tests/Functional/Command/GenerateCronFileCommandTest.php index 6935548..474b2d3 100644 --- a/Tests/Functional/Command/GenerateCronFileCommandTest.php +++ b/Tests/Functional/Command/GenerateCronFileCommandTest.php @@ -17,11 +17,12 @@ public function testGenerateFullConfiguration() $this->assertSame(0, $tester->execute(['env-mode' => 'staging'])); - $expected = '* * * * * project_staging php7.3 path/to/staging app:test --env=staging'; + $expected = '* * * * * project_staging php7.3 path/to/staging app:test'; $cacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir').'/cron_test'; - $this->assertStringContainsString($expected, file_get_contents($cacheDir)); + $this->assertStringContainsString($expected, $content = file_get_contents($cacheDir)); + $this->assertStringContainsString('APP_ENV=staging', $content); } public function testGenerateEmptyCrons() @@ -52,9 +53,10 @@ public function testDryRun() $this->assertStringContainsString('[OK] Dry run generated', $tester->getDisplay()); $this->assertStringContainsString('# send email', $tester->getDisplay()); $this->assertStringContainsString( - '* * * * * project_staging php7.3 path/to/staging app:test --env=staging', - $tester->getDisplay() + '* * * * * project_staging php7.3 path/to/staging app:test', + $display = $tester->getDisplay() ); + $this->assertStringContainsString('APP_ENV=staging', $display); } public function testCheckExecutivePath() From 50803cc8f6fa82dd63768ee8c76ab278f2955939 Mon Sep 17 00:00:00 2001 From: Florian PARRENO Date: Wed, 17 Jul 2024 09:41:57 +0200 Subject: [PATCH 3/3] Fix tests --- .../Functional/Command/GenerateCronFileCommandTest.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Tests/Functional/Command/GenerateCronFileCommandTest.php b/Tests/Functional/Command/GenerateCronFileCommandTest.php index 474b2d3..603f783 100644 --- a/Tests/Functional/Command/GenerateCronFileCommandTest.php +++ b/Tests/Functional/Command/GenerateCronFileCommandTest.php @@ -17,12 +17,11 @@ public function testGenerateFullConfiguration() $this->assertSame(0, $tester->execute(['env-mode' => 'staging'])); - $expected = '* * * * * project_staging php7.3 path/to/staging app:test'; + $expected = '* * * * * project_staging APP_ENV=staging php7.3 path/to/staging app:test'; $cacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir').'/cron_test'; - $this->assertStringContainsString($expected, $content = file_get_contents($cacheDir)); - $this->assertStringContainsString('APP_ENV=staging', $content); + $this->assertStringContainsString($expected, file_get_contents($cacheDir)); } public function testGenerateEmptyCrons() @@ -53,10 +52,9 @@ public function testDryRun() $this->assertStringContainsString('[OK] Dry run generated', $tester->getDisplay()); $this->assertStringContainsString('# send email', $tester->getDisplay()); $this->assertStringContainsString( - '* * * * * project_staging php7.3 path/to/staging app:test', - $display = $tester->getDisplay() + '* * * * * project_staging APP_ENV=staging php7.3 path/to/staging app:test', + $tester->getDisplay() ); - $this->assertStringContainsString('APP_ENV=staging', $display); } public function testCheckExecutivePath()