function MappingDefinitionTest::testAttributesInMarkup2

Tests if RDF mapping defined in rdf_test.install is used.

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 58
Definition of Drupal\rdf\Tests\MappingDefinitionTest.

Class

MappingDefinitionTest
Tests the RDF mapping definition functionality.

Namespace

Drupal\rdf\Tests

Code

function testAttributesInMarkup2() {
  $type = $this
    ->drupalCreateContentType(array(
    'type' => 'test_bundle_hook_install',
  ));
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'test_bundle_hook_install',
  ));
  $isoDate = date('c', $node->changed);
  $url = url('node/' . $node->nid);
  $this
    ->drupalGet('node/' . $node->nid);

  // Ensure the mapping defined in rdf_module.test is used.
  $test_bundle_title = $this
    ->xpath("//meta[@property='dc:title' and @content='{$node->title}']");
  $test_bundle_meta = $this
    ->xpath("//div[(@about='{$url}') and contains(@typeof, 'foo:mapping_install1') and contains(@typeof, 'bar:mapping_install2')]//span[contains(@property, 'dc:date') and contains(@property, 'dc:created') and @datatype='xsd:dateTime' and @content='{$isoDate}']");
  $this
    ->assertTrue(!empty($test_bundle_title), 'Property dc:title is present in meta tag.');
  $this
    ->assertTrue(!empty($test_bundle_meta), 'RDF type is present on post. Properties dc:date and dc:created are present on post date.');
}