You are here

public function FormatterTest::testFormatterService in Telephone Formatter 8

Test formatter service.

::covers format.

File

tests/src/Unit/FormatterTest.php, line 46

Class

FormatterTest
Formatter test.

Namespace

Drupal\Tests\telephone_formatter\Unit

Code

public function testFormatterService() {
  $test_country = 'NO';
  $test_value = '98765432';
  $this
    ->assertEquals('987 65 432', $this->formatterService
    ->format($test_value, PhoneNumberFormat::NATIONAL, $test_country));
  $this
    ->assertEquals('+47 987 65 432', $this->formatterService
    ->format($test_value, PhoneNumberFormat::INTERNATIONAL, $test_country));
  $this
    ->assertEquals('+4798765432', $this->formatterService
    ->format($test_value, PhoneNumberFormat::E164, $test_country));
  $this
    ->assertEquals('tel:+47-987-65-432', $this->formatterService
    ->format($test_value, PhoneNumberFormat::RFC3966, $test_country));
}