Skip to content

Commit f4fcbcf

Browse files
Bohdan Korablovshiftedreality
Bohdan Korablov
authored andcommitted
MAGECLOUD-2280: Setting cron_run from .magento.env.yaml does not work (#283)
1 parent 0f947fa commit f4fcbcf

File tree

3 files changed

+70
-5
lines changed

3 files changed

+70
-5
lines changed

src/Process/Deploy/InstallUpdate/ConfigUpdate/CronConsumersRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function execute()
103103
);
104104

105105
$config['cron_consumers_runner'] = [
106-
'cron_run' => $runnerConfig->get('cron_run') === 'true',
106+
'cron_run' => $runnerConfig->get('cron_run') === true,
107107
'max_messages' => $runnerConfig->get('max_messages', static::DEFAULT_MAX_MESSAGES),
108108
'consumers' => $runnerConfig->get('consumers', []),
109109
];

src/Test/Integration/AcceptanceTest.php

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function testDefault(array $environment, array $expectedConsumersRunnerCo
6060

6161
/**
6262
* @return array
63+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
6364
*/
6465
public function defaultDataProvider(): array
6566
{
@@ -86,7 +87,7 @@ public function defaultDataProvider(): array
8687
'variables' => [
8788
'ADMIN_EMAIL' => 'admin@example.com',
8889
'CRON_CONSUMERS_RUNNER' => [
89-
'cron_run' => "true",
90+
'cron_run' => true,
9091
'max_messages' => 5000,
9192
'consumers' => ['test'],
9293
],
@@ -103,11 +104,33 @@ public function defaultDataProvider(): array
103104
],
104105
],
105106
],
107+
'test cron_consumers_runner with wrong array' => [
108+
'environment' => [
109+
'variables' => [
110+
'ADMIN_EMAIL' => 'admin@example.com',
111+
'CRON_CONSUMERS_RUNNER' => [
112+
'cron_run' => 'true',
113+
'max_messages' => 5000,
114+
'consumers' => ['test'],
115+
],
116+
],
117+
],
118+
'expectedConsumersRunnerConfig' => [
119+
'cron_consumers_runner' => [
120+
'cron_run' => false,
121+
'max_messages' => 5000,
122+
'consumers' => ['test'],
123+
],
124+
'directories' => [
125+
'document_root_is_pub' => true,
126+
],
127+
],
128+
],
106129
'test cron_consumers_runner with string' => [
107130
'environment' => [
108131
'variables' => [
109132
'ADMIN_EMAIL' => 'admin@example.com',
110-
'CRON_CONSUMERS_RUNNER' => '{"cron_run":"true", "max_messages":100, "consumers":["test2"]}',
133+
'CRON_CONSUMERS_RUNNER' => '{"cron_run":true, "max_messages":100, "consumers":["test2"]}',
111134
],
112135
],
113136
'expectedConsumersRunnerConfig' => [
@@ -121,6 +144,24 @@ public function defaultDataProvider(): array
121144
],
122145
],
123146
],
147+
'test cron_consumers_runner with wrong string' => [
148+
'environment' => [
149+
'variables' => [
150+
'ADMIN_EMAIL' => 'admin@example.com',
151+
'CRON_CONSUMERS_RUNNER' => '{"cron_run":"true", "max_messages":100, "consumers":["test2"]}',
152+
],
153+
],
154+
'expectedConsumersRunnerConfig' => [
155+
'cron_consumers_runner' => [
156+
'cron_run' => false,
157+
'max_messages' => 100,
158+
'consumers' => ['test2'],
159+
],
160+
'directories' => [
161+
'document_root_is_pub' => true,
162+
],
163+
],
164+
],
124165
'disabled static content symlinks 3 jobs' => [
125166
'environment' => [
126167
'variables' => [

src/Test/Unit/Process/Deploy/InstallUpdate/ConfigUpdate/CronConsumersRunnerTest.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public function testExecute(array $config, array $configFromVariable, array $exp
120120

121121
/**
122122
* @return array
123+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
123124
*/
124125
public function executeDataProvider(): array
125126
{
@@ -182,7 +183,7 @@ public function executeDataProvider(): array
182183
'consumers' => ['test'],
183184
],
184185
],
185-
'configFromVariable' => ['cron_run' => 'true'],
186+
'configFromVariable' => ['cron_run' => true],
186187
'expectedResult' => [
187188
'someConfig' => 'someValue',
188189
'cron_consumers_runner' => [
@@ -202,7 +203,7 @@ public function executeDataProvider(): array
202203
],
203204
],
204205
'configFromVariable' => [
205-
'cron_run' => 'true',
206+
'cron_run' => true,
206207
'max_messages' => 200,
207208
'consumers' => ['test2', 'test3'],
208209
],
@@ -215,6 +216,29 @@ public function executeDataProvider(): array
215216
],
216217
],
217218
],
219+
[
220+
'config' => [
221+
'someConfig' => 'someValue',
222+
'cron_consumers_runner' => [
223+
'cron_run' => true,
224+
'max_messages' => 6000,
225+
'consumers' => ['test'],
226+
],
227+
],
228+
'configFromVariable' => [
229+
'cron_run' => 'true',
230+
'max_messages' => 200,
231+
'consumers' => ['test2', 'test3'],
232+
],
233+
'expectedResult' => [
234+
'someConfig' => 'someValue',
235+
'cron_consumers_runner' => [
236+
'cron_run' => false,
237+
'max_messages' => 200,
238+
'consumers' => ['test2', 'test3'],
239+
],
240+
],
241+
],
218242
];
219243
}
220244

0 commit comments

Comments
 (0)