You are here

public function DurationServiceTest::testgetHumanReadableStringFromDateInterval in Duration Field 8.2

Same name and namespace in other branches
  1. 3.0.x tests/src/Unit/Service/DurationServiceTest.php \Drupal\Tests\duration_field\Unit\Service\DurationServiceTest::testgetHumanReadableStringFromDateInterval()

@covers ::getHumanReadableStringFromDateInterval @dataProvider getHumanReadableStringFromDateIntervalDataProvider

File

tests/src/Unit/Service/DurationServiceTest.php, line 178

Class

DurationServiceTest
@coversDefaultClass \Drupal\duration_field\Service\DurationService @group duration_field

Namespace

Drupal\Tests\duration_field\Unit\Service

Code

public function testgetHumanReadableStringFromDateInterval($input, $expectedResponse, $message) {
  $duration_service = new DurationService();
  $container = new ContainerBuilder();
  $container
    ->set('string_translation', $this
    ->getStringTranslationStub());
  \Drupal::setContainer($container);
  $response = $duration_service
    ->getHumanReadableStringFromDateInterval($input['value'], $input['granularity']);
  if (is_a($response, 'Drupal\\Core\\StringTranslation\\TranslatableMarkup')) {
    $response = $response
      ->__toString();
  }
  $this
    ->assertSame($response, $expectedResponse, $message);
}