class GetRdfNamespacesTest
Same name and namespace in other branches
- 8.9.x core/modules/rdf/tests/src/Functional/GetRdfNamespacesTest.php \Drupal\Tests\rdf\Functional\GetRdfNamespacesTest
Tests hook_rdf_namespaces().
@group rdf @group legacy
Hierarchy
- class \Drupal\Tests\rdf\Functional\GetRdfNamespacesTest
Expanded class hierarchy of GetRdfNamespacesTest
File
-
core/
modules/ rdf/ tests/ src/ Functional/ GetRdfNamespacesTest.php, line 13
Namespace
Drupal\Tests\rdf\FunctionalView source
class GetRdfNamespacesTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'rdf',
'rdf_test_namespaces',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests getting RDF namespaces.
*/
public function testGetRdfNamespaces() {
// Fetches the front page and extracts RDFa 1.1 prefixes.
$this->drupalGet('');
// We have to use the find() method on the driver directly because //html is
// prepended to all xpath queries otherwise.
$driver = $this->getSession()
->getDriver();
$element = $driver->find('//html[contains(@prefix, "rdfs: http://www.w3.org/2000/01/rdf-schema#")]');
$this->assertCount(1, $element, 'A prefix declared once is displayed.');
$element = $driver->find('//html[contains(@prefix, "foaf: http://xmlns.com/foaf/0.1/")]');
$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.');
$element = $driver->find('//html[contains(@prefix, "foaf1: http://xmlns.com/foaf/0.1/")]');
$this->assertCount(1, $element, 'Two prefixes can be assigned the same namespace.');
$element = $driver->find('//html[contains(@prefix, "dc: http://purl.org/dc/terms/")]');
$this->assertCount(1, $element, 'When a prefix has conflicting namespaces, the first declared one is used.');
// Get all RDF namespaces.
$ns = rdf_get_namespaces();
$this->assertEquals('http://www.w3.org/2000/01/rdf-schema#', $ns['rdfs'], 'A prefix declared once is included.');
$this->assertEquals('http://xmlns.com/foaf/0.1/', $ns['foaf'], 'The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.');
$this->assertEquals('http://xmlns.com/foaf/0.1/', $ns['foaf1'], 'Two prefixes can be assigned the same namespace.');
// Enable rdf_conflicting_namespaces to ensure that an exception is thrown
// when RDF namespaces are conflicting.
\Drupal::service('module_installer')->install([
'rdf_conflicting_namespaces',
], TRUE);
try {
$ns = rdf_get_namespaces();
$this->fail('Expected exception not thrown for conflicting namespace declaration.');
} catch (\Exception $e) {
// Expected exception; just continue testing.
}
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary |
---|---|---|---|---|
AssertLegacyTrait::assert | Deprecated | protected | function | |
AssertLegacyTrait::assertCacheTag | Deprecated | protected | function | Asserts whether an expected cache tag was present in the last response. |
AssertLegacyTrait::assertElementNotPresent | Deprecated | protected | function | Asserts that the element with the given CSS selector is not present. |
AssertLegacyTrait::assertElementPresent | Deprecated | protected | function | Asserts that the element with the given CSS selector is present. |
AssertLegacyTrait::assertEqual | Deprecated | protected | function | |
AssertLegacyTrait::assertEscaped | Deprecated | protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. |
AssertLegacyTrait::assertField | Deprecated | protected | function | Asserts that a field exists with the given name or ID. |
AssertLegacyTrait::assertFieldById | Deprecated | protected | function | Asserts that a field exists with the given ID and value. |
AssertLegacyTrait::assertFieldByName | Deprecated | protected | function | Asserts that a field exists with the given name and value. |
AssertLegacyTrait::assertFieldByXPath | Deprecated | protected | function | Asserts that a field exists in the current page by the given XPath. |
AssertLegacyTrait::assertFieldChecked | Deprecated | protected | function | Asserts that a checkbox field in the current page is checked. |
AssertLegacyTrait::assertFieldsByValue | Deprecated | protected | function | Asserts that a field exists in the current page with a given Xpath result. |
AssertLegacyTrait::assertHeader | Deprecated | protected | function | Checks that current response header equals value. |
AssertLegacyTrait::assertIdentical | Deprecated | protected | function | |
AssertLegacyTrait::assertIdenticalObject | Deprecated | protected | function | |
AssertLegacyTrait::assertLink | Deprecated | protected | function | Passes if a link with the specified label is found. |
AssertLegacyTrait::assertLinkByHref | Deprecated | protected | function | Passes if a link containing a given href (part) is found. |
AssertLegacyTrait::assertNoCacheTag | Deprecated | protected | function | Asserts whether an expected cache tag was absent in the last response. |
AssertLegacyTrait::assertNoEscaped | Deprecated | protected | function | Passes if the raw text is not found escaped on the loaded page. |
AssertLegacyTrait::assertNoField | Deprecated | protected | function | Asserts that a field does NOT exist with the given name or ID. |
AssertLegacyTrait::assertNoFieldById | Deprecated | protected | function | Asserts that a field does not exist with the given ID and value. |
AssertLegacyTrait::assertNoFieldByName | Deprecated | protected | function | Asserts that a field does not exist with the given name and value. |
AssertLegacyTrait::assertNoFieldByXPath | Deprecated | protected | function | Asserts that a field does not exist or its value does not match, by XPath. |
AssertLegacyTrait::assertNoFieldChecked | Deprecated | protected | function | Asserts that a checkbox field in the current page is not checked. |
AssertLegacyTrait::assertNoLink | Deprecated | protected | function | Passes if a link with the specified label is not found. |
AssertLegacyTrait::assertNoLinkByHref | Deprecated | protected | function | Passes if a link containing a given href (part) is not found. |
AssertLegacyTrait::assertNoOption | Deprecated | protected | function | Asserts that a select option does NOT exist in the current page. |
AssertLegacyTrait::assertNoPattern | Deprecated | protected | function | Triggers a pass if the Perl regex pattern is not found in the raw content. |
AssertLegacyTrait::assertNoRaw | Deprecated | protected | function | Passes if the raw text IS not found on the loaded page, fail otherwise. |
AssertLegacyTrait::assertNotEqual | Deprecated | protected | function | |
AssertLegacyTrait::assertNoText | Deprecated | protected | function | Passes if the page (with HTML stripped) does not contains the text. |
AssertLegacyTrait::assertNotIdentical | Deprecated | protected | function | |
AssertLegacyTrait::assertNoUniqueText | Deprecated | protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. |
AssertLegacyTrait::assertOption | Deprecated | protected | function | Asserts that a select option in the current page exists. |
AssertLegacyTrait::assertOptionByText | Deprecated | protected | function | Asserts that a select option with the visible text exists. |
AssertLegacyTrait::assertOptionSelected | Deprecated | protected | function | Asserts that a select option in the current page is checked. |
AssertLegacyTrait::assertPattern | Deprecated | protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. |
AssertLegacyTrait::assertRaw | Deprecated | protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. |
AssertLegacyTrait::assertResponse | Deprecated | protected | function | Asserts the page responds with the specified response code. |
AssertLegacyTrait::assertText | Deprecated | protected | function | Passes if the page (with HTML stripped) contains the text. |
AssertLegacyTrait::assertTextHelper | Deprecated | protected | function | Helper for assertText and assertNoText. |
AssertLegacyTrait::assertTitle | Deprecated | protected | function | Pass if the page title is the given string. |
AssertLegacyTrait::assertUniqueText | Deprecated | protected | function | Passes if the text is found ONLY ONCE on the text version of the page. |
AssertLegacyTrait::assertUrl | Deprecated | protected | function | Passes if the internal browser's URL matches the given path. |
AssertLegacyTrait::buildXPathQuery | Deprecated | protected | function | Builds an XPath query. |
AssertLegacyTrait::constructFieldXpath | Deprecated | protected | function | Helper: Constructs an XPath for the given set of attributes and value. |
AssertLegacyTrait::getAllOptions | Deprecated | protected | function | Get all option elements, including nested options, in a select. |
AssertLegacyTrait::getRawContent | Deprecated | protected | function | Gets the current raw content. |
AssertLegacyTrait::pass | Deprecated | protected | function | |
AssertLegacyTrait::verbose | Deprecated | protected | function | |
GetRdfNamespacesTest::$defaultTheme | protected | property | The theme to install as the default for testing. | |
GetRdfNamespacesTest::$modules | protected static | property | Modules to enable. | |
GetRdfNamespacesTest::testGetRdfNamespaces | public | function | Tests getting RDF namespaces. | |
PhpUnitWarnings::$deprecationWarnings | private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings::addWarning | public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
StorageCopyTrait::replaceStorageContents | protected static | function | Copy the configuration from one storage to another and remove stale items. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.