You are here

public function TransitionManagerTest::providerValidate in Lightning Scheduler 8

Data provider for ::testValidate().

Return value

array

File

tests/src/Kernel/TransitionManagerTest.php, line 62

Class

TransitionManagerTest
@coversDefaultClass \Drupal\lightning_scheduler\TransitionManager

Namespace

Drupal\Tests\lightning_scheduler\Kernel

Code

public function providerValidate() {
  return [
    'empty string' => [
      '',
      'Expected scheduled transitions to be an array.',
    ],
    'null' => [
      NULL,
      'Expected scheduled transitions to be an array.',
    ],
    'boolean false' => [
      FALSE,
      'Expected scheduled transitions to be an array.',
    ],
    'boolean true' => [
      TRUE,
      'Expected scheduled transitions to be an array.',
    ],
    'random string' => [
      $this
        ->randomString(128),
      'Expected scheduled transitions to be an array.',
    ],
    'integer' => [
      123,
      'Expected scheduled transitions to be an array.',
    ],
    'float' => [
      123.45,
      'Expected scheduled transitions to be an array.',
    ],
    'empty array' => [
      [],
    ],
    'time, no date' => [
      [
        'when' => '08:57',
      ],
      'Scheduled transitions must have a date and time.',
    ],
    'date, no time' => [
      [
        [
          'state' => 'fubar',
          'when' => '1984-09-19',
        ],
      ],
      '"1984-09-19" is not a valid date and time.',
    ],
    'date and time' => [
      [
        [
          'when' => '1938-37-12 08:57',
        ],
      ],
      '"1938-37-12 08:57" is not a valid date and time.',
    ],
    'date as float' => [
      [
        [
          'state' => 'fubar',
          'when' => '123.45',
        ],
      ],
      '"123.45" is not a valid date and time.',
    ],
    'valid different time stamps, invalid order' => [
      [
        [
          'state' => 'fubar',
          'when' => mktime(15, 42, 0, 11, 5, 2018),
        ],
        [
          'state' => 'fubar',
          'when' => mktime(2, 30, 0, 9, 4, 2018),
        ],
      ],
      "You cannot schedule a transition to take place before 3:42 PM on November 5, 2018.",
    ],
    'valid same dates, valid times, invalid order' => [
      [
        [
          'state' => 'fubar',
          'when' => mktime(6, 30, 0, 9, 19, 2022),
        ],
        [
          'state' => 'fubar',
          'when' => mktime(4, 46, 0, 9, 19, 2022),
        ],
      ],
      "You cannot schedule a transition to take place before 6:30 AM on September 19, 2022.",
    ],
    'valid different dates' => [
      [
        [
          'state' => 'fubar',
          'when' => mktime(2, 30, 0, 9, 4, 2022),
        ],
        [
          'state' => 'fubar',
          'when' => mktime(15, 42, 0, 11, 5, 2022),
        ],
      ],
    ],
    'valid same dates, different times' => [
      [
        [
          'state' => 'fubar',
          'when' => mktime(2, 30, 0, 9, 19, 2022),
        ],
        [
          'state' => 'fubar',
          'when' => mktime(15, 42, 0, 9, 19, 2022),
        ],
      ],
    ],
  ];
}