TelephoneFieldRdfaTest.php in Drupal 10
File
core/modules/rdf/tests/src/Kernel/Field/TelephoneFieldRdfaTest.php
View source
<?php
namespace Drupal\Tests\rdf\Kernel\Field;
use Drupal\entity_test\Entity\EntityTest;
class TelephoneFieldRdfaTest extends FieldRdfaTestBase {
protected $testValue;
protected $fieldType = 'telephone';
protected static $modules = [
'telephone',
'text',
];
protected function setUp() : void {
parent::setUp();
$this
->createTestField();
$mapping = rdf_get_mapping('entity_test', 'entity_test');
$mapping
->setFieldMapping($this->fieldName, [
'properties' => [
'schema:telephone',
],
])
->save();
$this->testValue = '555-555-5555';
$this->entity = EntityTest::create([]);
$this->entity->{$this->fieldName}->value = $this->testValue;
}
public function testAllFormatters() {
$this
->assertFormatterRdfa([
'type' => 'string',
], 'http://schema.org/telephone', [
'value' => $this->testValue,
]);
$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',
];
$this
->assertFormatterRdfa($formatter, 'http://schema.org/telephone', $expected_rdf_value);
}
}