annotate core/modules/rdf/src/Tests/GetNamespacesTest.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author |
Chris Cannam |
date |
Mon, 23 Apr 2018 09:33:26 +0100 |
parents |
4c8ae668cc8c |
children |
|
rev |
line source |
Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\rdf\Tests;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\simpletest\WebTestBase;
|
Chris@0
|
6
|
Chris@0
|
7 /**
|
Chris@0
|
8 * Confirm that the serialization of RDF namespaces in present in the HTML
|
Chris@0
|
9 * markup.
|
Chris@0
|
10 *
|
Chris@0
|
11 * @group rdf
|
Chris@0
|
12 */
|
Chris@0
|
13 class GetNamespacesTest extends WebTestBase {
|
Chris@0
|
14
|
Chris@0
|
15 /**
|
Chris@0
|
16 * Modules to enable.
|
Chris@0
|
17 *
|
Chris@0
|
18 * @var array
|
Chris@0
|
19 */
|
Chris@0
|
20 public static $modules = ['rdf', 'rdf_test_namespaces'];
|
Chris@0
|
21
|
Chris@0
|
22 /**
|
Chris@0
|
23 * Tests RDF namespaces.
|
Chris@0
|
24 */
|
Chris@0
|
25 public function testGetRdfNamespaces() {
|
Chris@0
|
26 // Fetches the front page and extracts RDFa 1.1 prefixes.
|
Chris@0
|
27 $this->drupalGet('');
|
Chris@0
|
28
|
Chris@0
|
29 $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
|
Chris@0
|
30 ':prefix_binding' => 'rdfs: http://www.w3.org/2000/01/rdf-schema#',
|
Chris@0
|
31 ]);
|
Chris@0
|
32 $this->assertTrue(!empty($element), 'A prefix declared once is displayed.');
|
Chris@0
|
33
|
Chris@0
|
34 $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
|
Chris@0
|
35 ':prefix_binding' => 'foaf: http://xmlns.com/foaf/0.1/',
|
Chris@0
|
36 ]);
|
Chris@0
|
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.');
|
Chris@0
|
38
|
Chris@0
|
39 $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
|
Chris@0
|
40 ':prefix_binding' => 'foaf1: http://xmlns.com/foaf/0.1/',
|
Chris@0
|
41 ]);
|
Chris@0
|
42 $this->assertTrue(!empty($element), 'Two prefixes can be assigned the same namespace.');
|
Chris@0
|
43
|
Chris@0
|
44 $element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
|
Chris@0
|
45 ':prefix_binding' => 'dc: http://purl.org/dc/terms/',
|
Chris@0
|
46 ]);
|
Chris@0
|
47 $this->assertTrue(!empty($element), 'When a prefix has conflicting namespaces, the first declared one is used.');
|
Chris@0
|
48 }
|
Chris@0
|
49
|
Chris@0
|
50 }
|