function MappingDefinitionTest::testMappingDefinitionTestBundleInstall

Creates a content type and a node of type test_bundle_hook_install and tests whether the RDF mapping defined in rdf_test.install is used.

File

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

Class

MappingDefinitionTest
Tests the RDF mapping definition functionality.

Namespace

Drupal\rdf\Tests

Code

function testMappingDefinitionTestBundleInstall() {
  $this
    ->drupalCreateContentType(array(
    'type' => 'test_bundle_hook_install',
  ));
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'test_bundle_hook_install',
  ));
  $expected_mapping = array(
    'rdftype' => array(
      'foo:mapping_install1',
      'bar:mapping_install2',
    ),
    '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,
    )));
  }
}