3 namespace Drupal\Tests\rdf\Kernel\Field;
5 use Drupal\entity_test\Entity\EntityTest;
8 * Tests the RDFa output of a text field formatter with a datatype callback.
12 class FieldRdfaDatatypeCallbackTest extends FieldRdfaTestBase {
17 protected $fieldType = 'text';
22 public static $modules = ['text', 'filter'];
24 protected function setUp() {
27 $this->createTestField();
29 $this->installConfig(['filter']);
32 $mapping = rdf_get_mapping('entity_test', 'entity_test');
33 $mapping->setFieldMapping($this->fieldName, [
34 'properties' => ['schema:interactionCount'],
35 'datatype_callback' => [
36 'callable' => 'Drupal\rdf\Tests\Field\TestDataConverter::convertFoo',
40 // Set up test values.
41 $this->testValue = $this->randomMachineName();
42 $this->entity = EntityTest::create();
43 $this->entity->{$this->fieldName}->value = $this->testValue;
44 $this->entity->save();
46 $this->uri = $this->getAbsoluteUri($this->entity);
50 * Tests the default formatter.
52 public function testDefaultFormatter() {
53 // Expected value is the output of the datatype callback, not the raw value.
54 $this->assertFormatterRdfa(['type' => 'text_default'], 'http://schema.org/interactionCount', ['value' => 'foo' . $this->testValue]);