comparison core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children c2387f117808
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Tests\rdf\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8 * Tests hook_rdf_namespaces().
9 *
10 * @group rdf
11 */
12 class GetRdfNamespacesTest extends BrowserTestBase {
13
14 /**
15 * Modules to enable.
16 *
17 * @var array
18 */
19 public static $modules = ['rdf', 'rdf_test_namespaces'];
20
21 /**
22 * Tests getting RDF namespaces.
23 */
24 public function testGetRdfNamespaces() {
25 // Get all RDF namespaces.
26 $ns = rdf_get_namespaces();
27
28 $this->assertEqual($ns['rdfs'], 'http://www.w3.org/2000/01/rdf-schema#', 'A prefix declared once is included.');
29 $this->assertEqual($ns['foaf'], 'http://xmlns.com/foaf/0.1/', 'The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.');
30 $this->assertEqual($ns['foaf1'], 'http://xmlns.com/foaf/0.1/', 'Two prefixes can be assigned the same namespace.');
31
32 // Enable rdf_conflicting_namespaces to ensure that an exception is thrown
33 // when RDF namespaces are conflicting.
34 \Drupal::service('module_installer')->install(['rdf_conflicting_namespaces'], TRUE);
35 try {
36 $ns = rdf_get_namespaces();
37 $this->fail('Expected exception not thrown for conflicting namespace declaration.');
38 }
39 catch (\Exception $e) {
40 $this->pass('Expected exception thrown: ' . $e->getMessage());
41 }
42 }
43
44 }