You are here

public function NodeRevisionDeleteTest::testGetTimeString in Node Revision Delete 8

Tests the getTimeString() method.

@covers ::getTimeString @dataProvider providerGetTimeString

Parameters

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

array $config_name_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 104

Class

NodeRevisionDeleteTest
Tests the NodeRevisionDelete class methods.

Namespace

Drupal\Tests\node_revision_delete\Unit

Code

public function testGetTimeString($expected, array $config_name_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($config_name_time);

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

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