public function RdfaAttributesTest::testDatatypeCallback in Drupal 9
Same name and namespace in other branches
- 8 core/modules/rdf/tests/src/Kernel/RdfaAttributesTest.php \Drupal\Tests\rdf\Kernel\RdfaAttributesTest::testDatatypeCallback()
- 10 core/modules/rdf/tests/src/Kernel/RdfaAttributesTest.php \Drupal\Tests\rdf\Kernel\RdfaAttributesTest::testDatatypeCallback()
Tests attribute creation for mappings that override human-readable content.
File
- core/
modules/ rdf/ tests/ src/ Kernel/ RdfaAttributesTest.php, line 55
Class
- RdfaAttributesTest
- Tests RDFa attribute generation from RDF mapping.
Namespace
Drupal\Tests\rdf\KernelCode
public function testDatatypeCallback() {
$properties = [
'dc:created',
];
$datatype = 'xsd:dateTime';
$date = 1252750327;
$iso_date = $this->container
->get('date.formatter')
->format($date, 'custom', 'c', 'UTC');
$mapping = [
'datatype' => $datatype,
'properties' => $properties,
'datatype_callback' => [
'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
],
];
$expected_attributes = [
'datatype' => $datatype,
'property' => $properties,
'content' => $iso_date,
];
$this
->_testAttributes($expected_attributes, $mapping, [
'value' => $date,
]);
}