fix: give the empty-field test case its own data provider
This commit is contained in:
1 parent
7493afde45
commit
493a43d952
1 file changed
+16
-5
@@ -274,13 +274,9 @@ class ApplicationFormControllerTest extends WebTestCase
|
||||
* An empty string is the shape a form posts for a field the visitor left blank, and it is as
|
||||
* unusable as an absent key - except for eu, where "" is a lawful no and has its own case.
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\DataProvider('requiredFields')]
|
||||
#[\PHPUnit\Framework\Attributes\DataProvider('nonBlankFields')]
|
||||
public function testAPayloadWithAnEmptyRequiredFieldIsRejected(string $field): void
|
||||
{
|
||||
if ('eu' === $field) {
|
||||
$this->markTestSkipped('An empty eu is a no, not a missing answer - see its own test');
|
||||
}
|
||||
|
||||
$this->post([$field => ''] + $this->payload());
|
||||
|
||||
$this->assertSame(Response::HTTP_BAD_REQUEST, $this->client->getResponse()->getStatusCode());
|
||||
@@ -306,6 +302,21 @@ class ApplicationFormControllerTest extends WebTestCase
|
||||
yield 'city' => ['city'];
|
||||
}
|
||||
|
||||
/**
|
||||
* The required fields that are NotBlank as well: all but eu, which is only NotNull because ""
|
||||
* is a lawful no (testAnEmptyEuFlagIsNotAYes).
|
||||
*
|
||||
* @return iterable<string, array{string}>
|
||||
*/
|
||||
public static function nonBlankFields(): iterable
|
||||
{
|
||||
foreach (self::requiredFields() as $name => $arguments) {
|
||||
if ('eu' !== $name) {
|
||||
yield $name => $arguments;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The one field whose format is nailed down: provisioning parses it as a date, so the day the
|
||||
* TYPO3 side switches a form back to a free-text birthday has to be a 400 here rather than a
|
||||
|
||||
Reference in new issue
Block a user