diff core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php @ 16:c2387f117808

Routine composer update
author Chris Cannam
date Tue, 10 Jul 2018 15:07:59 +0100
parents 4c8ae668cc8c
children
line wrap: on
line diff
--- a/core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php	Thu Apr 26 11:26:54 2018 +0100
+++ b/core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php	Tue Jul 10 15:07:59 2018 +0100
@@ -22,6 +22,25 @@
    * Tests getting RDF namespaces.
    */
   public function testGetRdfNamespaces() {
+    // Fetches the front page and extracts RDFa 1.1 prefixes.
+    $this->drupalGet('');
+
+    // We have to use the find() method on the driver directly because //html is
+    // prepended to all xpath queries otherwise.
+    $driver = $this->getSession()->getDriver();
+
+    $element = $driver->find('//html[contains(@prefix, "rdfs: http://www.w3.org/2000/01/rdf-schema#")]');
+    $this->assertCount(1, $element, 'A prefix declared once is displayed.');
+
+    $element = $driver->find('//html[contains(@prefix, "foaf: http://xmlns.com/foaf/0.1/")]');
+    $this->assertCount(1, $element, 'The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.');
+
+    $element = $driver->find('//html[contains(@prefix, "foaf1: http://xmlns.com/foaf/0.1/")]');
+    $this->assertCount(1, $element, 'Two prefixes can be assigned the same namespace.');
+
+    $element = $driver->find('//html[contains(@prefix, "dc: http://purl.org/dc/terms/")]');
+    $this->assertCount(1, $element, 'When a prefix has conflicting namespaces, the first declared one is used.');
+
     // Get all RDF namespaces.
     $ns = rdf_get_namespaces();