3 namespace Drupal\Tests\rdf\Kernel\Field;
5 use Drupal\entity_test\Entity\EntityTest;
8 * Tests RDFa output by datetime field formatters.
12 class DateTimeFieldRdfaTest extends FieldRdfaTestBase {
17 protected $fieldType = 'datetime';
20 * The 'value' property value for testing.
24 protected $testValue = '2014-01-28T06:01:01';
29 public static $modules = ['datetime'];
31 protected function setUp() {
34 $this->createTestField();
37 $mapping = rdf_get_mapping('entity_test', 'entity_test');
38 $mapping->setFieldMapping($this->fieldName, [
39 'properties' => ['schema:dateCreated'],
42 // Set up test entity.
43 $this->entity = EntityTest::create([]);
44 $this->entity->{$this->fieldName}->value = $this->testValue;
48 * Tests the default formatter.
50 public function testDefaultFormatter() {
51 $this->assertFormatterRdfa(['type' => 'datetime_default'], 'http://schema.org/dateCreated', ['value' => $this->testValue . 'Z', 'type' => 'literal', 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime']);