You are here

public function DurationServiceTest::testCheckDurationInvalid in Duration Field 8

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

@covers ::checkDurationInvalid @dataProvider checkDurationInvalidDataProvider

File

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

Class

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

Namespace

Drupal\Tests\duration_field\Unit\Service

Code

public function testCheckDurationInvalid($pattern, $expectedResponse, $message) {
  $duration_service = new DurationService();
  $duration_service
    ->setStringTranslation($this
    ->getStringTranslationStub());
  if ($expectedResponse) {
    $this
      ->expectException('Drupal\\duration_field\\Exception\\InvalidDurationException');
    $duration_service
      ->checkDurationInvalid($pattern);
  }
  else {
    $response = $duration_service
      ->checkDurationInvalid($pattern);
    $this
      ->assertTrue((bool) $response == $expectedResponse, $message);
  }
}