Mercurial > hg > isophonics-drupal-site
annotate 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 |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\Tests\rdf\Functional; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Tests\BrowserTestBase; |
Chris@0 | 6 |
Chris@0 | 7 /** |
Chris@0 | 8 * Tests hook_rdf_namespaces(). |
Chris@0 | 9 * |
Chris@0 | 10 * @group rdf |
Chris@0 | 11 */ |
Chris@0 | 12 class GetRdfNamespacesTest extends BrowserTestBase { |
Chris@0 | 13 |
Chris@0 | 14 /** |
Chris@0 | 15 * Modules to enable. |
Chris@0 | 16 * |
Chris@0 | 17 * @var array |
Chris@0 | 18 */ |
Chris@0 | 19 public static $modules = ['rdf', 'rdf_test_namespaces']; |
Chris@0 | 20 |
Chris@0 | 21 /** |
Chris@0 | 22 * Tests getting RDF namespaces. |
Chris@0 | 23 */ |
Chris@0 | 24 public function testGetRdfNamespaces() { |
Chris@0 | 25 // Get all RDF namespaces. |
Chris@0 | 26 $ns = rdf_get_namespaces(); |
Chris@0 | 27 |
Chris@0 | 28 $this->assertEqual($ns['rdfs'], 'http://www.w3.org/2000/01/rdf-schema#', 'A prefix declared once is included.'); |
Chris@0 | 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.'); |
Chris@0 | 30 $this->assertEqual($ns['foaf1'], 'http://xmlns.com/foaf/0.1/', 'Two prefixes can be assigned the same namespace.'); |
Chris@0 | 31 |
Chris@0 | 32 // Enable rdf_conflicting_namespaces to ensure that an exception is thrown |
Chris@0 | 33 // when RDF namespaces are conflicting. |
Chris@0 | 34 \Drupal::service('module_installer')->install(['rdf_conflicting_namespaces'], TRUE); |
Chris@0 | 35 try { |
Chris@0 | 36 $ns = rdf_get_namespaces(); |
Chris@0 | 37 $this->fail('Expected exception not thrown for conflicting namespace declaration.'); |
Chris@0 | 38 } |
Chris@0 | 39 catch (\Exception $e) { |
Chris@0 | 40 $this->pass('Expected exception thrown: ' . $e->getMessage()); |
Chris@0 | 41 } |
Chris@0 | 42 } |
Chris@0 | 43 |
Chris@0 | 44 } |