3 namespace Drupal\rdf\Tests;
5 use Drupal\simpletest\WebTestBase;
8 * Confirm that the serialization of RDF namespaces in present in the HTML
13 class GetNamespacesTest extends WebTestBase {
20 public static $modules = ['rdf', 'rdf_test_namespaces'];
23 * Tests RDF namespaces.
25 public function testGetRdfNamespaces() {
26 // Fetches the front page and extracts RDFa 1.1 prefixes.
29 $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
30 ':prefix_binding' => 'rdfs: http://www.w3.org/2000/01/rdf-schema#',
32 $this->assertTrue(!empty($element), 'A prefix declared once is displayed.');
34 $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
35 ':prefix_binding' => 'foaf: http://xmlns.com/foaf/0.1/',
37 $this->assertTrue(!empty($element), 'The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.');
39 $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
40 ':prefix_binding' => 'foaf1: http://xmlns.com/foaf/0.1/',
42 $this->assertTrue(!empty($element), 'Two prefixes can be assigned the same namespace.');
44 $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
45 ':prefix_binding' => 'dc: http://purl.org/dc/terms/',
47 $this->assertTrue(!empty($element), 'When a prefix has conflicting namespaces, the first declared one is used.');