You are here

protected function DateRangeFieldTest::datelistDataProvider in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php \Drupal\Tests\datetime_range\Functional\DateRangeFieldTest::datelistDataProvider()
  2. 10 core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php \Drupal\Tests\datetime_range\Functional\DateRangeFieldTest::datelistDataProvider()

The data provider for testing the validation of the datelist widget.

Return value

array An array of datelist input permutations to test.

1 call to DateRangeFieldTest::datelistDataProvider()
DateRangeFieldTest::testDatelistWidget in core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php
Tests Date Range List Widget functionality.

File

core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php, line 922

Class

DateRangeFieldTest
Tests Daterange field functionality.

Namespace

Drupal\Tests\datetime_range\Functional

Code

protected function datelistDataProvider() {
  return [
    // Year only selected, validation error on Month, Day, Hour, Minute.
    [
      [
        'year' => 2012,
        'month' => '',
        'day' => '',
        'hour' => '',
        'minute' => '',
      ],
      [
        'year' => 2013,
        'month' => '1',
        'day' => '15',
        'hour' => '3',
        'minute' => '30',
      ],
      [
        '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' => '',
      ],
      [
        'year' => 2013,
        'month' => '1',
        'day' => '15',
        'hour' => '3',
        'minute' => '30',
      ],
      [
        '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' => '',
      ],
      [
        'year' => 2013,
        'month' => '1',
        'day' => '15',
        'hour' => '3',
        'minute' => '30',
      ],
      [
        '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' => '',
      ],
      [
        'year' => 2013,
        'month' => '1',
        'day' => '15',
        'hour' => '3',
        'minute' => '30',
      ],
      [
        'A value must be selected for minute.',
      ],
    ],
    // Year selected, validation error on Month, Day, Hour, Minute.
    [
      [
        'year' => 2012,
        'month' => '12',
        'day' => '31',
        'hour' => '0',
        'minute' => '0',
      ],
      [
        'year' => 2013,
        'month' => '',
        'day' => '',
        'hour' => '',
        'minute' => '',
      ],
      [
        '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' => '31',
        'hour' => '0',
        'minute' => '0',
      ],
      [
        'year' => 2013,
        'month' => '1',
        'day' => '',
        'hour' => '',
        'minute' => '',
      ],
      [
        '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' => '0',
        'minute' => '0',
      ],
      [
        'year' => 2013,
        'month' => '1',
        'day' => '15',
        'hour' => '',
        'minute' => '',
      ],
      [
        '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' => '0',
      ],
      [
        'year' => 2013,
        'month' => '1',
        'day' => '15',
        'hour' => '3',
        'minute' => '',
      ],
      [
        'A value must be selected for minute.',
      ],
    ],
  ];
}