function MappingDefinitionTest::testMappingDefinitionRandomContentType

Creates a random content type and node and ensures the default mapping for the node is being used.

File

drupal/core/modules/rdf/lib/Drupal/rdf/Tests/MappingDefinitionTest.php, line 113
Contains Drupal\rdf\Tests\MappingDefinitionTest.

Class

MappingDefinitionTest
Tests the RDF mapping definition functionality.

Namespace

Drupal\rdf\Tests

Code

function testMappingDefinitionRandomContentType() {
  $type = $this
    ->drupalCreateContentType();
  $node = $this
    ->drupalCreateNode(array(
    'type' => $type->type,
  ));
  $expected_mapping = array(
    'rdftype' => array(
      'sioc:Item',
      'foaf:Document',
    ),
    'title' => array(
      'predicates' => array(
        'dc:title',
      ),
    ),
    'body' => array(
      'predicates' => array(
        'content:encoded',
      ),
    ),
    'created' => array(
      'predicates' => array(
        'dc:date',
        'dc:created',
      ),
      'callback' => 'date_iso8601',
      'datatype' => 'xsd:dateTime',
    ),
  );
  $node = node_load($node->nid);
  foreach ($expected_mapping as $key => $mapping) {
    $this
      ->assertEqual($node->rdf_mapping[$key], $mapping, format_string('Expected mapping found for @key.', array(
      '@key' => $key,
    )));
  }
}