ca46c5cd794c9b0137c0187fddbc8408a436b3f1
[yaffs-website] / web / core / modules / rdf / src / Tests / GetNamespacesTest.php
1 <?php
2
3 namespace Drupal\rdf\Tests;
4
5 use Drupal\simpletest\WebTestBase;
6
7 /**
8  * Confirm that the serialization of RDF namespaces in present in the HTML
9  * markup.
10  *
11  * @group rdf
12  */
13 class GetNamespacesTest extends WebTestBase {
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = ['rdf', 'rdf_test_namespaces'];
21
22   /**
23    * Tests RDF namespaces.
24    */
25   public function testGetRdfNamespaces() {
26     // Fetches the front page and extracts RDFa 1.1 prefixes.
27     $this->drupalGet('');
28
29     $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
30       ':prefix_binding' => 'rdfs: http://www.w3.org/2000/01/rdf-schema#',
31     ]);
32     $this->assertTrue(!empty($element), 'A prefix declared once is displayed.');
33
34     $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
35       ':prefix_binding' => 'foaf: http://xmlns.com/foaf/0.1/',
36     ]);
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.');
38
39     $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
40       ':prefix_binding' => 'foaf1: http://xmlns.com/foaf/0.1/',
41     ]);
42     $this->assertTrue(!empty($element), 'Two prefixes can be assigned the same namespace.');
43
44     $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
45       ':prefix_binding' => 'dc: http://purl.org/dc/terms/',
46     ]);
47     $this->assertTrue(!empty($element), 'When a prefix has conflicting namespaces, the first declared one is used.');
48   }
49
50 }