Chris@0: drupalGet(''); Chris@16: Chris@16: // We have to use the find() method on the driver directly because //html is Chris@16: // prepended to all xpath queries otherwise. Chris@16: $driver = $this->getSession()->getDriver(); Chris@16: Chris@16: $element = $driver->find('//html[contains(@prefix, "rdfs: http://www.w3.org/2000/01/rdf-schema#")]'); Chris@16: $this->assertCount(1, $element, 'A prefix declared once is displayed.'); Chris@16: Chris@16: $element = $driver->find('//html[contains(@prefix, "foaf: http://xmlns.com/foaf/0.1/")]'); Chris@16: $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.'); Chris@16: Chris@16: $element = $driver->find('//html[contains(@prefix, "foaf1: http://xmlns.com/foaf/0.1/")]'); Chris@16: $this->assertCount(1, $element, 'Two prefixes can be assigned the same namespace.'); Chris@16: Chris@16: $element = $driver->find('//html[contains(@prefix, "dc: http://purl.org/dc/terms/")]'); Chris@16: $this->assertCount(1, $element, 'When a prefix has conflicting namespaces, the first declared one is used.'); Chris@16: Chris@0: // Get all RDF namespaces. Chris@0: $ns = rdf_get_namespaces(); Chris@0: Chris@0: $this->assertEqual($ns['rdfs'], 'http://www.w3.org/2000/01/rdf-schema#', 'A prefix declared once is included.'); Chris@0: $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.'); Chris@0: $this->assertEqual($ns['foaf1'], 'http://xmlns.com/foaf/0.1/', 'Two prefixes can be assigned the same namespace.'); Chris@0: Chris@0: // Enable rdf_conflicting_namespaces to ensure that an exception is thrown Chris@0: // when RDF namespaces are conflicting. Chris@0: \Drupal::service('module_installer')->install(['rdf_conflicting_namespaces'], TRUE); Chris@0: try { Chris@0: $ns = rdf_get_namespaces(); Chris@0: $this->fail('Expected exception not thrown for conflicting namespace declaration.'); Chris@0: } Chris@0: catch (\Exception $e) { Chris@0: $this->pass('Expected exception thrown: ' . $e->getMessage()); Chris@0: } Chris@0: } Chris@0: Chris@0: }