You are here

public function TelephoneFieldTest::testTelephoneFormatter in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php \Drupal\Tests\telephone\Functional\TelephoneFieldTest::testTelephoneFormatter()
  2. 9 core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php \Drupal\Tests\telephone\Functional\TelephoneFieldTest::testTelephoneFormatter()

Tests the telephone formatter.

@covers \Drupal\telephone\Plugin\Field\FieldFormatter\TelephoneLinkFormatter::viewElements

@dataProvider providerPhoneNumbers

File

core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php, line 102

Class

TelephoneFieldTest
Tests the creation of telephone fields.

Namespace

Drupal\Tests\telephone\Functional

Code

public function testTelephoneFormatter($input, $expected) {

  // Test basic entry of telephone field.
  $edit = [
    'title[0][value]' => $this
      ->randomMachineName(),
    'field_telephone[0][value]' => $input,
  ];
  $this
    ->drupalGet('node/add/article');
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->responseContains('<a href="tel:' . $expected . '">');
}