You are here

public function NodeRevisionDeleteTest::providerGetRelativeTime in Node Revision Delete 8

Data provider for testGetRelativeTime.

Return value

array An array of arrays, each containing:

  • 'expected' - Expected return from getRelativeTime().
  • 'time' - The configured time.
  • 'config_name' - The config name.
  • 'number' - The number for the $config_name parameter configuration.

See also

testGetRelativeTime()

File

tests/src/Unit/NodeRevisionDeleteTest.php, line 421

Class

NodeRevisionDeleteTest
Tests the NodeRevisionDelete class methods.

Namespace

Drupal\Tests\node_revision_delete\Unit

Code

public function providerGetRelativeTime() {
  $expected = [
    strtotime('-5 days'),
    strtotime('-2 days'),
    strtotime('-1 day'),
    strtotime('-10 weeks'),
    strtotime('-20 weeks'),
    strtotime('-1 week'),
    strtotime('-12 months'),
    strtotime('-24 months'),
    strtotime('-1 month'),
  ];
  $days = [
    'time' => 'days',
  ];
  $weeks = [
    'time' => 'weeks',
  ];
  $months = [
    'time' => 'months',
  ];

  // Test for minimum_age_to_delete.
  $tests['days 1'] = [
    $expected[0],
    $days,
    'minimum_age_to_delete',
    5,
  ];
  $tests['days 2'] = [
    $expected[1],
    $days,
    'minimum_age_to_delete',
    2,
  ];
  $tests['days 3'] = [
    $expected[2],
    $days,
    'minimum_age_to_delete',
    1,
  ];
  $tests['weeks 1'] = [
    $expected[3],
    $weeks,
    'minimum_age_to_delete',
    10,
  ];
  $tests['weeks 2'] = [
    $expected[4],
    $weeks,
    'minimum_age_to_delete',
    20,
  ];
  $tests['weeks 3'] = [
    $expected[5],
    $weeks,
    'minimum_age_to_delete',
    1,
  ];
  $tests['months 1'] = [
    $expected[6],
    $months,
    'minimum_age_to_delete',
    12,
  ];
  $tests['months 2'] = [
    $expected[7],
    $months,
    'minimum_age_to_delete',
    24,
  ];
  $tests['months 3'] = [
    $expected[8],
    $months,
    'minimum_age_to_delete',
    1,
  ];

  // Test for when_to_delete.
  $tests['days 4'] = [
    $expected[0],
    $days,
    'when_to_delete',
    5,
  ];
  $tests['days 5'] = [
    $expected[1],
    $days,
    'when_to_delete',
    2,
  ];
  $tests['days 6'] = [
    $expected[2],
    $days,
    'when_to_delete',
    1,
  ];
  $tests['weeks 4'] = [
    $expected[3],
    $weeks,
    'when_to_delete',
    10,
  ];
  $tests['weeks 5'] = [
    $expected[4],
    $weeks,
    'when_to_delete',
    20,
  ];
  $tests['weeks 6'] = [
    $expected[5],
    $weeks,
    'when_to_delete',
    1,
  ];
  $tests['months 4'] = [
    $expected[6],
    $months,
    'when_to_delete',
    12,
  ];
  $tests['months 5'] = [
    $expected[7],
    $months,
    'when_to_delete',
    24,
  ];
  $tests['months 6'] = [
    $expected[8],
    $months,
    'when_to_delete',
    1,
  ];
  return $tests;
}