protected function DateTimeFieldTest::datelistDataProvider in Drupal 10
Same name and namespace in other branches
- 8 core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php \Drupal\Tests\datetime\Functional\DateTimeFieldTest::datelistDataProvider()
- 9 core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php \Drupal\Tests\datetime\Functional\DateTimeFieldTest::datelistDataProvider()
The data provider for testing the validation of the datelist widget.
Parameters
string $field_label: The label of the field being tested.
Return value
array An array of datelist input permutations to test.
File
- core/
modules/ datetime/ tests/ src/ Functional/ DateTimeFieldTest.php, line 621
Class
- DateTimeFieldTest
- Tests Datetime field functionality.
Namespace
Drupal\Tests\datetime\FunctionalCode
protected function datelistDataProvider($field_label) {
return [
// Nothing selected.
[
[
'year' => '',
'month' => '',
'day' => '',
'hour' => '',
'minute' => '',
],
[
"The {$field_label} date is required.",
],
],
// Year only selected, validation error on Month, Day, Hour, Minute.
[
[
'year' => 2012,
'month' => '',
'day' => '',
'hour' => '',
'minute' => '',
],
[
"The {$field_label} date is incomplete.",
'A value must be selected for month.',
'A value must be selected for day.',
'A value must be selected for hour.',
'A value must be selected for minute.',
],
],
// Year and Month selected, validation error on Day, Hour, Minute.
[
[
'year' => 2012,
'month' => '12',
'day' => '',
'hour' => '',
'minute' => '',
],
[
"The {$field_label} date is incomplete.",
'A value must be selected for day.',
'A value must be selected for hour.',
'A value must be selected for minute.',
],
],
// Year, Month and Day selected, validation error on Hour, Minute.
[
[
'year' => 2012,
'month' => '12',
'day' => '31',
'hour' => '',
'minute' => '',
],
[
"The {$field_label} date is incomplete.",
'A value must be selected for hour.',
'A value must be selected for minute.',
],
],
// Year, Month, Day and Hour selected, validation error on Minute only.
[
[
'year' => 2012,
'month' => '12',
'day' => '31',
'hour' => '0',
'minute' => '',
],
[
"The {$field_label} date is incomplete.",
'A value must be selected for minute.',
],
],
];
}