3 namespace Drupal\Tests\rdf\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests hook_rdf_namespaces().
12 class GetRdfNamespacesTest extends BrowserTestBase {
19 public static $modules = ['rdf', 'rdf_test_namespaces'];
22 * Tests getting RDF namespaces.
24 public function testGetRdfNamespaces() {
25 // Get all RDF namespaces.
26 $ns = rdf_get_namespaces();
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.');
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);
36 $ns = rdf_get_namespaces();
37 $this->fail('Expected exception not thrown for conflicting namespace declaration.');
39 catch (\Exception $e) {
40 $this->pass('Expected exception thrown: ' . $e->getMessage());