function HelpTopicsSyntaxTest::verifyBadTopic
Same name in other branches
- 9 core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php \Drupal\Tests\help_topics\Functional\HelpTopicsSyntaxTest::verifyBadTopic()
- 10 core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php \Drupal\Tests\help\Functional\HelpTopicsSyntaxTest::verifyBadTopic()
- 11.x core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php \Drupal\Tests\help\Functional\HelpTopicsSyntaxTest::verifyBadTopic()
Verifies that a bad topic fails in the expected way.
Parameters
string $id: ID of the topic to verify. It should start with "bad_help_topics.".
array $definitions: Array of all topic definitions, keyed by ID.
1 call to HelpTopicsSyntaxTest::verifyBadTopic()
- HelpTopicsSyntaxTest::testHelpTopics in core/
modules/ help_topics/ tests/ src/ Functional/ HelpTopicsSyntaxTest.php - Tests that all Core help topics can be rendered and have good syntax.
File
-
core/
modules/ help_topics/ tests/ src/ Functional/ HelpTopicsSyntaxTest.php, line 189
Class
- HelpTopicsSyntaxTest
- Verifies that all core Help topics can be rendered and comply with standards.
Namespace
Drupal\Tests\help_topics\FunctionalCode
protected function verifyBadTopic($id, $definitions) {
$bad_topic_type = substr($id, 16);
// Topics should fail verifyTopic() in specific ways.
try {
$this->verifyTopic($id, $definitions, 404);
} catch (ExpectationFailedException $e) {
$message = $e->getMessage();
switch ($bad_topic_type) {
case 'related':
$this->assertStringContainsString('only related to topics that exist', $message);
break;
case 'bad_html':
$this->assertStringContainsString('Unexpected end tag', $message);
break;
case 'top_level':
$this->assertStringContainsString('is either top-level or related to at least one other top-level topic', $message);
break;
case 'empty':
$this->assertStringContainsString('contains some text outside of front matter', $message);
break;
case 'translated':
$this->assertStringContainsString('Twig file has all of its text translated', $message);
break;
case 'h1':
$this->assertStringContainsString('has no H1 tag', $message);
break;
case 'hierarchy':
$this->assertStringContainsString('has the correct H2-H6 heading hierarchy', $message);
break;
default:
// This was an unexpected error.
throw $e;
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.