You are here

public function NodeRevisionDeleteTest::testGetRelativeTime in Node Revision Delete 8

Tests the getRelativeTime() method.

@covers ::getRelativeTime @dataProvider providerGetRelativeTime

Parameters

string $expected: The expected result from calling the function.

array $time: The configured time name.

string $config_name: The config name.

int $number: The number for the $config_name parameter configuration.

File

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

Class

NodeRevisionDeleteTest
Tests the NodeRevisionDelete class methods.

Namespace

Drupal\Tests\node_revision_delete\Unit

Code

public function testGetRelativeTime($expected, array $time, $config_name, $number) {

  // ImmutableConfig mock.
  $config = $this
    ->createMock('Drupal\\Core\\Config\\ImmutableConfig');

  // ImmutableConfig::get mock.
  $config
    ->expects($this
    ->any())
    ->method('get')
    ->with('node_revision_delete_' . $config_name . '_time')
    ->willReturn($time);

  // Mocking get method.
  $this->configFactory
    ->expects($this
    ->any())
    ->method('get')
    ->with($this->configFile)
    ->willReturn($config);

  // Asserting the values.
  $this
    ->assertEquals($expected, $this->nodeRevisionDelete
    ->getRelativeTime($config_name, $number));
}