function MappingHookTest::testMapping

Tests that hook_rdf_mapping() correctly returns and processes mapping.

File

drupal/core/modules/rdf/lib/Drupal/rdf/Tests/MappingHookTest.php, line 35
Definition of Drupal\rdf\Tests\MappingHookTest.

Class

MappingHookTest
Tests the RDF mapping hook.

Namespace

Drupal\rdf\Tests

Code

function testMapping() {

  // Test that the mapping is returned correctly by the hook.
  $mapping = rdf_mapping_load('test_entity', 'test_bundle');
  $this
    ->assertIdentical($mapping['rdftype'], array(
    'sioc:Post',
  ), 'Mapping for rdftype is sioc:Post.');
  $this
    ->assertIdentical($mapping['title'], array(
    'predicates' => array(
      'dc:title',
    ),
  ), 'Mapping for title is dc:title.');
  $this
    ->assertIdentical($mapping['created'], array(
    'predicates' => array(
      'dc:created',
    ),
    'datatype' => 'xsd:dateTime',
    'callback' => 'date_iso8601',
  ), 'Mapping for created is dc:created with datatype xsd:dateTime and callback date_iso8601.');
  $this
    ->assertIdentical($mapping['uid'], array(
    'predicates' => array(
      'sioc:has_creator',
      'dc:creator',
    ),
    'type' => 'rel',
  ), 'Mapping for uid is sioc:has_creator and dc:creator, and type is rel.');
  $mapping = rdf_mapping_load('test_entity', 'test_bundle_no_mapping');
  $this
    ->assertEqual($mapping, array(), 'Empty array returned when an entity type, bundle pair has no mapping.');
}