Skip to content

Commit 4591403

Browse files
committed
prevent infinite loop on invalid non-interactive input
1 parent e6edf5d commit 4591403

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

features/non-interactive.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,16 @@ Feature: It is possible to interactively fill in a form from the CLI
2828
Options:
2929
--password
3030
"""
31+
32+
Scenario: Provide invalid value
33+
When I run the command "form:color --color='invalid color'" non-interactively
34+
Then the command was not successful
35+
And the output should contain
36+
"""
37+
Invalid data provided: color:
38+
ERROR: This value is not valid.
39+
"""
40+
And the output should contain
41+
"""
42+
There were form errors.
43+
"""

src/Console/Helper/FormHelper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ function (FormInterface $formField) use (&$validFormFields) {
9090
},
9191
$form->all()
9292
);
93+
94+
if (!$input->isInteractive()) {
95+
throw new \RuntimeException('There were form errors.');
96+
}
9397
}
9498
} while (!$form->isValid());
9599

0 commit comments

Comments
 (0)