You are here

public function NodeRevisionDeleteTest::providerGetTimeString in Node Revision Delete 8

Data provider for testGetTimeString.

Return value

array An array of arrays, each containing:

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

See also

testGetTimeString()

File

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

Class

NodeRevisionDeleteTest
Tests the NodeRevisionDelete class methods.

Namespace

Drupal\Tests\node_revision_delete\Unit

Code

public function providerGetTimeString() {
  $expected = [
    '5 days',
    '2 days',
    '1 day',
    '10 weeks',
    '20 weeks',
    '1 week',
    '12 months',
    '24 months',
    '1 month',
    $this
      ->getStringTranslationStub()
      ->translate('After @number @time of inactivity', [
      '@number' => 5,
      '@time' => 'days',
    ]),
    $this
      ->getStringTranslationStub()
      ->translate('After @number @time of inactivity', [
      '@number' => 2,
      '@time' => 'days',
    ]),
    $this
      ->getStringTranslationStub()
      ->translate('After @number @time of inactivity', [
      '@number' => 1,
      '@time' => 'day',
    ]),
    $this
      ->getStringTranslationStub()
      ->translate('After @number @time of inactivity', [
      '@number' => 10,
      '@time' => 'weeks',
    ]),
    $this
      ->getStringTranslationStub()
      ->translate('After @number @time of inactivity', [
      '@number' => 20,
      '@time' => 'weeks',
    ]),
    $this
      ->getStringTranslationStub()
      ->translate('After @number @time of inactivity', [
      '@number' => 1,
      '@time' => 'week',
    ]),
    $this
      ->getStringTranslationStub()
      ->translate('After @number @time of inactivity', [
      '@number' => 12,
      '@time' => 'months',
    ]),
    $this
      ->getStringTranslationStub()
      ->translate('After @number @time of inactivity', [
      '@number' => 24,
      '@time' => 'months',
    ]),
    $this
      ->getStringTranslationStub()
      ->translate('After @number @time of inactivity', [
      '@number' => 1,
      '@time' => '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[9],
    $days,
    'when_to_delete',
    5,
  ];
  $tests['days 5'] = [
    $expected[10],
    $days,
    'when_to_delete',
    2,
  ];
  $tests['days 6'] = [
    $expected[11],
    $days,
    'when_to_delete',
    1,
  ];
  $tests['weeks 4'] = [
    $expected[12],
    $weeks,
    'when_to_delete',
    10,
  ];
  $tests['weeks 5'] = [
    $expected[13],
    $weeks,
    'when_to_delete',
    20,
  ];
  $tests['weeks 6'] = [
    $expected[14],
    $weeks,
    'when_to_delete',
    1,
  ];
  $tests['months 4'] = [
    $expected[15],
    $months,
    'when_to_delete',
    12,
  ];
  $tests['months 5'] = [
    $expected[16],
    $months,
    'when_to_delete',
    24,
  ];
  $tests['months 6'] = [
    $expected[17],
    $months,
    'when_to_delete',
    1,
  ];
  return $tests;
}