You are here

public function RdfaAttributesTest::testDatatypeCallback in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/rdf/tests/src/Kernel/RdfaAttributesTest.php \Drupal\Tests\rdf\Kernel\RdfaAttributesTest::testDatatypeCallback()
  2. 10 core/modules/rdf/tests/src/Kernel/RdfaAttributesTest.php \Drupal\Tests\rdf\Kernel\RdfaAttributesTest::testDatatypeCallback()

Test attribute creation for mappings which 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\Kernel

Code

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,
  ]);
}