class TelephoneFieldRdfaTest
Same name and namespace in other branches
- 8.9.x core/modules/rdf/tests/src/Kernel/Field/TelephoneFieldRdfaTest.php \Drupal\Tests\rdf\Kernel\Field\TelephoneFieldRdfaTest
Tests RDFa output by telephone field formatters.
@group rdf @group legacy
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\field\Kernel\FieldKernelTestBase implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\rdf\Kernel\Field\FieldRdfaTestBase uses \Drupal\Tests\rdf\Traits\RdfParsingTrait implements \Drupal\Tests\field\Kernel\FieldKernelTestBase
- class \Drupal\Tests\rdf\Kernel\Field\TelephoneFieldRdfaTest implements \Drupal\Tests\rdf\Kernel\Field\FieldRdfaTestBase
- class \Drupal\Tests\rdf\Kernel\Field\FieldRdfaTestBase uses \Drupal\Tests\rdf\Traits\RdfParsingTrait implements \Drupal\Tests\field\Kernel\FieldKernelTestBase
- class \Drupal\Tests\field\Kernel\FieldKernelTestBase implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of TelephoneFieldRdfaTest
File
-
core/
modules/ rdf/ tests/ src/ Kernel/ Field/ TelephoneFieldRdfaTest.php, line 13
Namespace
Drupal\Tests\rdf\Kernel\FieldView source
class TelephoneFieldRdfaTest extends FieldRdfaTestBase {
/**
* A test value for the telephone field.
*
* @var string
*/
protected $testValue;
/**
* {@inheritdoc}
*/
protected $fieldType = 'telephone';
/**
* {@inheritdoc}
*/
protected static $modules = [
'telephone',
'text',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->createTestField();
// Add the mapping.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
$mapping->setFieldMapping($this->fieldName, [
'properties' => [
'schema:telephone',
],
])
->save();
// Set up test values.
$this->testValue = '555-555-5555';
$this->entity = EntityTest::create([]);
$this->entity->{$this->fieldName}->value = $this->testValue;
}
/**
* Tests the field formatters.
*/
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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.