You are here

public function TelephoneFieldRdfaTest::testAllFormatters in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/rdf/tests/src/Kernel/Field/TelephoneFieldRdfaTest.php \Drupal\Tests\rdf\Kernel\Field\TelephoneFieldRdfaTest::testAllFormatters()

Tests the field formatters.

File

core/modules/rdf/tests/src/Kernel/Field/TelephoneFieldRdfaTest.php, line 51

Class

TelephoneFieldRdfaTest
Tests RDFa output by telephone field formatters.

Namespace

Drupal\Tests\rdf\Kernel\Field

Code

public function testAllFormatters() {

  // Tests the plain formatter.
  $this
    ->assertFormatterRdfa([
    'type' => 'string',
  ], 'http://schema.org/telephone', [
    'value' => $this->testValue,
  ]);

  // Tests the telephone link formatter.
  $this
    ->assertFormatterRdfa([
    'type' => 'telephone_link',
  ], 'http://schema.org/telephone', [
    'value' => 'tel:' . $this->testValue,
    'type' => 'uri',
  ]);
  $formatter = [
    'type' => 'telephone_link',
    'settings' => [
      'title' => 'Contact us',
    ],
  ];
  $expected_rdf_value = [
    'value' => 'tel:' . $this->testValue,
    'type' => 'uri',
  ];

  // Tests the telephone link formatter with custom title.
  $this
    ->assertFormatterRdfa($formatter, 'http://schema.org/telephone', $expected_rdf_value);
}