class TimeTest in Node Revision Delete 8
Tests the Time class methods.
@group node_revision_delete @coversDefaultClass \Drupal\node_revision_delete\Utility\Time
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait- class \Drupal\Tests\node_revision_delete\Unit\Utility\TimeTest
 
Expanded class hierarchy of TimeTest
File
- tests/src/ Unit/ Utility/ TimeTest.php, line 14 
Namespace
Drupal\Tests\node_revision_delete\Unit\UtilityView source
class TimeTest extends UnitTestCase {
  /**
   * Tests the convertWordToTime() method.
   *
   * @param int $expected
   *   The expected result from calling the function.
   * @param string $word
   *   The old word to map.
   *
   * @covers ::convertWordToTime
   * @dataProvider providerConvertWordToTime
   */
  public function testConvertWordToTime($expected, $word) {
    // Testing the function.
    $this
      ->assertEquals($expected, Time::convertWordToTime($word));
  }
  /**
   * Data provider for testConvertWordToTime().
   *
   * @return array
   *   An array of arrays, each containing:
   *   - 'expected' - Expected return from Time::convertWordToTime().
   *   - 'word' - The old word to map.
   *
   * @see testConvertWordToTime()
   */
  public function providerConvertWordToTime() {
    $all_values = [
      'never' => '-1',
      'every_time' => '0',
      'every_hour' => '3600',
      'everyday' => '86400',
      'every_week' => '604800',
      'every_10_days' => '864000',
      'every_15_days' => '1296000',
      'every_month' => '2592000',
      'every_3_months' => '7776000',
      'every_6_months' => '15552000',
      'every_year' => '31536000',
      'every_2_years' => '63072000',
    ];
    $tests[] = [
      $all_values,
      NULL,
    ];
    $tests[] = [
      $all_values['never'],
      'never',
    ];
    $tests[] = [
      $all_values['every_time'],
      'every_time',
    ];
    $tests[] = [
      $all_values['every_hour'],
      'every_hour',
    ];
    $tests[] = [
      $all_values['everyday'],
      'everyday',
    ];
    $tests[] = [
      $all_values['every_week'],
      'every_week',
    ];
    $tests[] = [
      $all_values['every_10_days'],
      'every_10_days',
    ];
    $tests[] = [
      $all_values['every_15_days'],
      'every_15_days',
    ];
    $tests[] = [
      $all_values['every_month'],
      'every_month',
    ];
    $tests[] = [
      $all_values['every_3_months'],
      'every_3_months',
    ];
    $tests[] = [
      $all_values['every_6_months'],
      'every_6_months',
    ];
    $tests[] = [
      $all_values['every_year'],
      'every_year',
    ];
    $tests[] = [
      $all_values['every_2_years'],
      'every_2_years',
    ];
    return $tests;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| PhpunitCompatibilityTrait:: | public | function | Returns a mock object for the specified class using the available method. | |
| PhpunitCompatibilityTrait:: | public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
| TimeTest:: | public | function | Data provider for testConvertWordToTime(). | |
| TimeTest:: | public | function | Tests the convertWordToTime() method. | |
| UnitTestCase:: | protected | property | The random generator. | |
| UnitTestCase:: | protected | property | The app root. | 1 | 
| UnitTestCase:: | protected | function | Asserts if two arrays are equal by sorting them first. | |
| UnitTestCase:: | protected | function | Mocks a block with a block plugin. | 1 | 
| UnitTestCase:: | protected | function | Returns a stub class resolver. | |
| UnitTestCase:: | public | function | Returns a stub config factory that behaves according to the passed array. | |
| UnitTestCase:: | public | function | Returns a stub config storage that returns the supplied configuration. | |
| UnitTestCase:: | protected | function | Sets up a container with a cache tags invalidator. | |
| UnitTestCase:: | protected | function | Gets the random generator for the utility methods. | |
| UnitTestCase:: | public | function | Returns a stub translation manager that just returns the passed string. | |
| UnitTestCase:: | public | function | Generates a unique random string containing letters and numbers. | |
| UnitTestCase:: | protected | function | 340 | 
