diff --git a/core/MAINTAINERS.txt b/core/MAINTAINERS.txt index e4120cc3d8..3003d6dc34 100644 --- a/core/MAINTAINERS.txt +++ b/core/MAINTAINERS.txt @@ -232,6 +232,10 @@ Hypertext Application Language (HAL) Help - ? +Help Topics +- Amber Matz 'Amber Himes Matz' https://www.drupal.org/u/amber-himes-matz +- Andrey Postnikov 'andypost' https://www.drupal.org/u/andypost + Image - Claudiu Cristea 'claudiu.cristea' https://www.drupal.org/u/claudiu.cristea diff --git a/core/composer.json b/core/composer.json index 020498f834..772d96e91a 100644 --- a/core/composer.json +++ b/core/composer.json @@ -123,6 +123,7 @@ "drupal/forum": "self.version", "drupal/hal": "self.version", "drupal/help": "self.version", + "drupal/help_topics": "self.version", "drupal/history": "self.version", "drupal/image": "self.version", "drupal/inline_form_errors": "self.version", diff --git a/core/modules/help_topics/help_topics.info.yml b/core/modules/help_topics/help_topics.info.yml new file mode 100644 index 0000000000..3afdacc432 --- /dev/null +++ b/core/modules/help_topics/help_topics.info.yml @@ -0,0 +1,8 @@ +name: Help Topics +type: module +description: 'Displays help topics provided by themes and modules.' +core: 8.x +package: Core (Experimental) +version: VERSION +dependencies: + - drupal:help diff --git a/core/modules/help_topics/help_topics.module b/core/modules/help_topics/help_topics.module new file mode 100644 index 0000000000..9ec6d21335 --- /dev/null +++ b/core/modules/help_topics/help_topics.module @@ -0,0 +1,63 @@ +' . t('About') . ''; + $output .= '
' . t('The Help Topics module adds module- and theme-provided help topics to the module overviews from the core Help module. For more information, see the online documentation for the Help Topics module.', [':online' => 'https://www.drupal.org/modules/help_topics']) . '
'; + $output .= '' . t('See the Help page for more topics.', [ + ':help_page' => Url::fromRoute('help.main')->toString(), + ]) . '
'; + } +} + +/** + * Implements hook_theme(). + */ +function help_topics_theme($existing, $type, $theme, $path) { + $twigPlugins = array_filter(\Drupal::service('plugin.manager.help_topic')->getDefinitions(), function (array $definition) { + return $definition['class'] === HelpTopicTwig::class; + }); + $return = [ + 'help_topic' => [ + 'variables' => [ + 'body' => [], + 'related' => [], + ], + ], + ]; + foreach ($twigPlugins as $pluginId => $definition) { + $hook = HelpTopicTwig::getThemeHook($pluginId); + $return[$hook] = [ + 'variables' => [], + 'path' => drupal_get_path('module', $definition['provider']) . '/help_topics/templates', + 'template' => strtr($hook, '_', '-'), + ]; + } + return $return; +} diff --git a/core/modules/help_topics/help_topics.permissions.yml b/core/modules/help_topics/help_topics.permissions.yml new file mode 100644 index 0000000000..e7ce493278 --- /dev/null +++ b/core/modules/help_topics/help_topics.permissions.yml @@ -0,0 +1,2 @@ +view help topics: + title: 'View help topics' diff --git a/core/modules/help_topics/help_topics.routing.yml b/core/modules/help_topics/help_topics.routing.yml new file mode 100644 index 0000000000..5038440d20 --- /dev/null +++ b/core/modules/help_topics/help_topics.routing.yml @@ -0,0 +1,6 @@ +help_topics.help_topic: + path: '/admin/help/topic/{id}' + defaults: + _controller: '\Drupal\help_topics\Controller\HelpTopicPluginController::viewHelpTopic' + requirements: + _permission: 'view help topics' diff --git a/core/modules/help_topics/help_topics.services.yml b/core/modules/help_topics/help_topics.services.yml new file mode 100644 index 0000000000..8fd573f4b5 --- /dev/null +++ b/core/modules/help_topics/help_topics.services.yml @@ -0,0 +1,9 @@ +services: + help_topics.breadcrumb: + class: Drupal\help_topics\HelpBreadcrumbBuilder + arguments: ['@string_translation'] + tags: + - { name: breadcrumb_builder, priority: 900 } + plugin.manager.help_topic: + class: Drupal\help_topics\Plugin\HelpTopic\HelpTopicPluginManager + arguments: ['@module_handler', '@theme_handler'] diff --git a/core/modules/help_topics/help_topics.tokens.inc b/core/modules/help_topics/help_topics.tokens.inc new file mode 100644 index 0000000000..979e369acc --- /dev/null +++ b/core/modules/help_topics/help_topics.tokens.inc @@ -0,0 +1,69 @@ + t("Help Topics"), + 'description' => t("Tokens for help topics."), + ]; + + $topics = []; + $topics['url'] = [ + 'name' => t('URL'), + 'description' => t('The URL to the topic. Provide the topic machine name as help_topic:url:MACHINE_NAME'), + ]; + + return [ + 'types' => $types, + 'tokens' => [ + 'help_topic' => $topics, + ], + ]; +} + +/** + * Implements hook_tokens(). + */ +function help_topics_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) { + $replacements = []; + $token_service = \Drupal::token(); + /** @var \Drupal\help_topics\Plugin\HelpTopic\HelpTopicPluginManagerInterface $plugin_manager */ + $plugin_manager = \Drupal::service('plugin.manager.help_topic'); + + // Our tokens generate URLs, which depend on language. See if a language is + // passed in; if not, we will let the URL system use its own defaults. + $url_options = []; + if (isset($options['langcode'])) { + $language_manager = \Drupal::languageManager(); + $language = $language_manager->getLanguage($options['langcode']); + if ($language) { + $url_options['language'] = $language; + } + } + + if ($type == 'help_topic') { + $topics = $token_service->findWithPrefix($tokens, 'url'); + foreach ($topics as $name => $original) { + /** @var \Drupal\help_topics\Plugin\HelpTopic\HelpTopicPluginInterface $topic */ + if ($plugin_manager->hasDefinition($name) && $topic = $plugin_manager->createInstance($name, [])) { + $url = $topic->toUrl($url_options)->toString(TRUE); + $replacements[$original] = $url->getGeneratedUrl(); + $bubbleable_metadata + ->addCacheableDependency($url) + ->addCacheableDependency($topic); + } + } + } + + return $replacements; +} diff --git a/core/modules/help_topics/help_topics/config_basic.help_topic.yml b/core/modules/help_topics/help_topics/config_basic.help_topic.yml new file mode 100644 index 0000000000..eb6504f765 --- /dev/null +++ b/core/modules/help_topics/help_topics/config_basic.help_topic.yml @@ -0,0 +1,5 @@ +id: config_basic +label: 'Changing basic site settings' +top_level: true +related: { } +list_on: { } diff --git a/core/modules/help_topics/help_topics/config_error.help_topic.yml b/core/modules/help_topics/help_topics/config_error.help_topic.yml new file mode 100644 index 0000000000..6317dfbb7f --- /dev/null +++ b/core/modules/help_topics/help_topics/config_error.help_topic.yml @@ -0,0 +1,11 @@ +id: config_error +label: 'Configuring error responses, including 403/404 pages' +top_level: false +related: + - config_basic + - maintenance +list_on: + - config_basic + - maintenance + - menu_overview + - security diff --git a/core/modules/help_topics/help_topics/help_topic_writing.help_topic.yml b/core/modules/help_topics/help_topics/help_topic_writing.help_topic.yml new file mode 100644 index 0000000000..04d972821a --- /dev/null +++ b/core/modules/help_topics/help_topics/help_topic_writing.help_topic.yml @@ -0,0 +1,5 @@ +id: help_topic_writing +label: 'Writing good help' +top_level: true +related: { } +list_on: { } diff --git a/core/modules/help_topics/help_topics/maintenance.help_topic.yml b/core/modules/help_topics/help_topics/maintenance.help_topic.yml new file mode 100644 index 0000000000..1aee4e0128 --- /dev/null +++ b/core/modules/help_topics/help_topics/maintenance.help_topic.yml @@ -0,0 +1,5 @@ +id: maintenance +label: 'Maintaining and troubleshooting your site' +top_level: true +related: { } +list_on: { } diff --git a/core/modules/help_topics/help_topics/menu_overview.help_topic.yml b/core/modules/help_topics/help_topics/menu_overview.help_topic.yml new file mode 100644 index 0000000000..fbc3bd3ebf --- /dev/null +++ b/core/modules/help_topics/help_topics/menu_overview.help_topic.yml @@ -0,0 +1,5 @@ +id: menu_overview +label: 'Defining navigation and URLs' +top_level: true +related: { } +list_on: { } diff --git a/core/modules/help_topics/help_topics/security.help_topic.yml b/core/modules/help_topics/help_topics/security.help_topic.yml new file mode 100644 index 0000000000..2980019181 --- /dev/null +++ b/core/modules/help_topics/help_topics/security.help_topic.yml @@ -0,0 +1,5 @@ +id: security +label: 'Making your site secure' +top_level: true +related: { } +list_on: { } diff --git a/core/modules/help_topics/help_topics/security_account_settings.help_topic.yml b/core/modules/help_topics/help_topics/security_account_settings.help_topic.yml new file mode 100644 index 0000000000..14dfddaac3 --- /dev/null +++ b/core/modules/help_topics/help_topics/security_account_settings.help_topic.yml @@ -0,0 +1,8 @@ +id: security_account_settings +label: 'Defining how user accounts are created' +top_level: false +related: + - security +list_on: + - config_basic + - security diff --git a/core/modules/help_topics/help_topics/templates/help-topic-config-basic.html.twig b/core/modules/help_topics/help_topics/templates/help-topic-config-basic.html.twig new file mode 100644 index 0000000000..1a5b686c97 --- /dev/null +++ b/core/modules/help_topics/help_topics/templates/help-topic-config-basic.html.twig @@ -0,0 +1,12 @@ +{% set regional_url = render_var(url('system.regional_settings')) %} +{% set information_url = render_var(url('system.site_information_settings')) %} +{% set datetime_url = render_var(url('entity.date_format.collection')) %} +{% trans %}The settings for your site are configured on various administrative pages, as follows:{% endtrans %}
+{% trans %}The core software provides default responses for 403 response (Not Authorized: when someone tries to visit a page they do not have permission to see) and 404 response (Not Found: when someone tries to visit a page that does not exist). You can change what page is displayed for these responses on the Basic site settings page, which you can reach in the main Manage administrative menu, by navigating to Configuration > System > Basic site settings. Note that the pages you want to use must already exist as either system-provided pages or content that you have created.{% endtrans %}
+{% trans %}Software errors on your site are logged, if you have a logging module installed (such as the core Database Logging module or the core Syslog module). You can configure whether or not error messages are also shown (to both administrators and other site visitors) on the Logging and errors configuration page, which you can reach in the main Manage administrative menu, by navigating to Configuration > Development > Logging and errors.{% endtrans %}
+{% trans %}If you have the core Database Logging module installed, you can view recent error and informational messages by navigating in the main Manage administrative menu to Reports > Recent log messages. If you are using the core Syslog module for logging, error messages will be logged in your web server''s log files.{% endtrans %}
diff --git a/core/modules/help_topics/help_topics/templates/help-topic-help-topic-writing.html.twig b/core/modules/help_topics/help_topics/templates/help-topic-help-topic-writing.html.twig new file mode 100644 index 0000000000..ca43f59b18 --- /dev/null +++ b/core/modules/help_topics/help_topics/templates/help-topic-help-topic-writing.html.twig @@ -0,0 +1,7 @@ +{% trans %}Here are some suggestions for how to make your help topics as useful as possible for readers:{% endtrans %}
+{% trans %}The related topics listed here will help you keep your site running and troubleshoot problems.{% endtrans %}
diff --git a/core/modules/help_topics/help_topics/templates/help-topic-menu-overview.html.twig b/core/modules/help_topics/help_topics/templates/help-topic-menu-overview.html.twig new file mode 100644 index 0000000000..9a119ab0c4 --- /dev/null +++ b/core/modules/help_topics/help_topics/templates/help-topic-menu-overview.html.twig @@ -0,0 +1 @@ +{% trans %}The related topics listed here describe how to set up various aspects of site navigation and URLs.{% endtrans %}
diff --git a/core/modules/help_topics/help_topics/templates/help-topic-security-account-settings.html.twig b/core/modules/help_topics/help_topics/templates/help-topic-security-account-settings.html.twig new file mode 100644 index 0000000000..6db302beac --- /dev/null +++ b/core/modules/help_topics/help_topics/templates/help-topic-security-account-settings.html.twig @@ -0,0 +1,8 @@ +{% set account_settings_url = render_var(url('entity.user.admin_form')) %} +{% trans %}On the Account settings page, which you can reach from the Manage administrative menu, by navigating to Configuration > People > Account settings (requires the Administer account settings permission), you can configure several settings related to how user accounts are created:{% endtrans %}
+{% trans %}The topics listed here will help you make and keep your site secure.{% endtrans %}
diff --git a/core/modules/help_topics/help_topics/templates/help-topic-ui-accessibility.html.twig b/core/modules/help_topics/help_topics/templates/help-topic-ui-accessibility.html.twig new file mode 100644 index 0000000000..0c014af6e6 --- /dev/null +++ b/core/modules/help_topics/help_topics/templates/help-topic-ui-accessibility.html.twig @@ -0,0 +1,5 @@ +{% trans %}The following features of the administrative user interface may help administrative users with disabilities access your site:{% endtrans %}
+{% trans %}The related topics listed here describe various aspects of the administrative interface, and tell how to use them.{% endtrans %}
diff --git a/core/modules/help_topics/help_topics/templates/help-topic-ui-contextual.html.twig b/core/modules/help_topics/help_topics/templates/help-topic-ui-contextual.html.twig new file mode 100644 index 0000000000..431f2b3c47 --- /dev/null +++ b/core/modules/help_topics/help_topics/templates/help-topic-ui-contextual.html.twig @@ -0,0 +1,9 @@ +{% trans %}Contextual links give users with the Use contextual links permission quick access to administrative tasks related to areas of non-administrative pages. For example, if a page on your site displays a block, the block would have a contextual link that would allow users with permission to configure the block. If the block contains a menu or a view, it would also have a contextual link for editing the menu links or the view. Clicking a contextual link takes you to the related administrative page directly, without needing to navigate through the administrative menu system.{% endtrans %}
+{% trans %}If you have the core Contextual Links module installed, the contextual links related to an area on a page can be displayed by clicking the contextual links button in that area of the page. In most themes, this button looks like a pencil and is placed in the upper right corner of the page area (upper left for right-to-left languages); however, contextual links buttons are normally hidden. Here are two ways to make contextual links buttons visible:{% endtrans %}
+{% trans %}While the contextual links button for the area of interest is visible, click the button to display the list of links for that area. Click a link in the list to perform the task.{% endtrans %}
diff --git a/core/modules/help_topics/help_topics/templates/help-topic-ui-shortcuts.html.twig b/core/modules/help_topics/help_topics/templates/help-topic-ui-shortcuts.html.twig new file mode 100644 index 0000000000..69536add95 --- /dev/null +++ b/core/modules/help_topics/help_topics/templates/help-topic-ui-shortcuts.html.twig @@ -0,0 +1,6 @@ +{% trans %}Shortcuts are quick links to administrative pages; they are managed by the core Shortcut module. A site can have one or more shortcut sets, which can be shared by one or more users; each set contains one or more shortcuts. Users need Use shortcuts permission to view shortcuts; Edit current shortcut set permission to add, delete, or edit the shortcuts in the set assigned to them; and Select any shortcut set permission to select a different shortcut set when editing their user profile. There is also an Administer shortcuts permission, which allows an administrator to do any of these actions, and also permits assigning shortcut sets to other users.{% endtrans %}
+{% trans %}When viewing certain administrative pages, you will see a link that allows you to add the page to your current shortcut set. In the core Seven administrative theme, the link looks like a star, and is displayed next to the page title. If the page is already in your shortcut set, you will instead see a link that allows you to remove it.{% endtrans %}
+{% trans %}If you have the core Toolbar module installed, click Shortcuts in the toolbar to display your shortcuts. Once they are displayed, click any link in the shortcut bar to go directly to the administrative page. If you are not using the Toolbar module, you can display shortcuts by placing the Shortcuts block in a region of your theme.{% endtrans %}
diff --git a/core/modules/help_topics/help_topics/templates/help-topic-ui-tours.html.twig b/core/modules/help_topics/help_topics/templates/help-topic-ui-tours.html.twig new file mode 100644 index 0000000000..6a48a54786 --- /dev/null +++ b/core/modules/help_topics/help_topics/templates/help-topic-ui-tours.html.twig @@ -0,0 +1,4 @@ +{% trans %}The core Tour module provides users with tours, which are guided tours of the administrative interface. Each tour starts on a particular administrative page, and consists of one or more tips that highlight elements of the page, guide you through a workflow, or explain key concepts. Users need Access tour permission to view tours, and JavaScript must be enabled in their browsers.{% endtrans %}
+{% trans %}If a tour is available on a page, and you have the core Toolbar module installed, a Tour button will appear on the right end of the toolbar (left end for right-to-left languages). Click this button to view the first tip of the tour; click the Next button to advance to the next tip, and End tour at the end to close the tour.{% endtrans %}
diff --git a/core/modules/help_topics/help_topics/ui_accessibility.help_topic.yml b/core/modules/help_topics/help_topics/ui_accessibility.help_topic.yml new file mode 100644 index 0000000000..489f96cdbc --- /dev/null +++ b/core/modules/help_topics/help_topics/ui_accessibility.help_topic.yml @@ -0,0 +1,7 @@ +id: ui_accessibility +label: 'Accessibility features' +top_level: false +related: + - ui_components +list_on: + - ui_components diff --git a/core/modules/help_topics/help_topics/ui_components.help_topic.yml b/core/modules/help_topics/help_topics/ui_components.help_topic.yml new file mode 100644 index 0000000000..098d584491 --- /dev/null +++ b/core/modules/help_topics/help_topics/ui_components.help_topic.yml @@ -0,0 +1,5 @@ +id: ui_components +label: 'Using the administrative interface' +top_level: true +related: { } +list_on: { } diff --git a/core/modules/help_topics/help_topics/ui_contextual.help_topic.yml b/core/modules/help_topics/help_topics/ui_contextual.help_topic.yml new file mode 100644 index 0000000000..4b3c23d3a7 --- /dev/null +++ b/core/modules/help_topics/help_topics/ui_contextual.help_topic.yml @@ -0,0 +1,7 @@ +id: ui_contextual +label: 'Contextual links' +top_level: false +related: + - ui_components +list_on: + - ui_components diff --git a/core/modules/help_topics/help_topics/ui_shortcuts.help_topic.yml b/core/modules/help_topics/help_topics/ui_shortcuts.help_topic.yml new file mode 100644 index 0000000000..24af5d2408 --- /dev/null +++ b/core/modules/help_topics/help_topics/ui_shortcuts.help_topic.yml @@ -0,0 +1,7 @@ +id: ui_shortcuts +label: Shortcuts +top_level: false +related: + - ui_components +list_on: + - ui_components diff --git a/core/modules/help_topics/help_topics/ui_tours.help_topic.yml b/core/modules/help_topics/help_topics/ui_tours.help_topic.yml new file mode 100644 index 0000000000..7f5c9872df --- /dev/null +++ b/core/modules/help_topics/help_topics/ui_tours.help_topic.yml @@ -0,0 +1,7 @@ +id: ui_tours +label: Tours +top_level: false +related: + - ui_components +list_on: + - ui_components diff --git a/core/modules/help_topics/src/Controller/HelpTopicPluginController.php b/core/modules/help_topics/src/Controller/HelpTopicPluginController.php new file mode 100644 index 0000000000..2193dad4a1 --- /dev/null +++ b/core/modules/help_topics/src/Controller/HelpTopicPluginController.php @@ -0,0 +1,145 @@ +helpTopicPluginManager = $help_topic_plugin_manager; + $this->token = $token; + $this->renderer = $renderer; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('plugin.manager.help_topic'), + $container->get('token'), + $container->get('renderer') + ); + } + + /** + * Displays a help topic page. + * + * @param string $id + * The plugin ID. Maps to the {id} placeholder in the + * help_topics.help_topic route. + * + * @return array + * A render array with the contents of a help topic page. + */ + public function viewHelpTopic($id) { + $build = []; + + if (!$this->helpTopicPluginManager->hasDefinition($id)) { + throw new AccessDeniedHttpException(); + } + /* @var \Drupal\help_topics\Plugin\HelpTopic\HelpTopicPluginInterface $help_topic */ + $help_topic = $this->helpTopicPluginManager->createInstance($id); + + $build['#body'] = $help_topic->getBody(); + + $this->renderer->addCacheableDependency($build, $help_topic); + + // Build the related topics section, starting with the list this topic + // says are related. + $links = []; + + $related = $help_topic->getRelated(); + foreach ($related as $other_id) { + if ($other_id !== $help_topic->getPluginId()) { + if (!$this->helpTopicPluginManager->hasDefinition($other_id)) { + continue; + } + /** @var \Drupal\help_topics\Plugin\HelpTopic\HelpTopicPluginInterface $topic */ + $topic = $this->helpTopicPluginManager->createInstance($other_id); + if ($topic) { + $links[$other_id] = [ + 'title' => $topic->getLabel(), + 'url' => Url::fromRoute('help_topics.help_topic', ['id' => $other_id]), + ]; + $this->renderer->addCacheableDependency($build, $topic); + } + } + } + + // Add in any plugins that have said "List me on this topic". + $liston = $this->helpTopicPluginManager->getAllListOn($id); + foreach ($liston as $topic) { + $other_id = $topic->getPluginId(); + $links[$other_id] = [ + 'title' => $topic->getLabel(), + 'url' => Url::fromRoute('help_topics.help_topic', ['id' => $other_id]), + ]; + $this->renderer->addCacheableDependency($build, $topic); + } + + if (count($links)) { + uasort($links, function ($a, $b) { + if ($a['title'] == $b['title']) { + return 0; + } + return ($a['title'] < $b['title']) ? -1 : 1; + }); + $build['#related'] = [ + '#theme' => 'links', + '#heading' => [ + 'text' => $this->t('Related topics'), + 'level' => 'h2', + ], + '#links' => $links, + ]; + } + + $build['#theme'] = 'help_topic'; + $build['#title'] = $help_topic->getLabel(); + return $build; + } + +} diff --git a/core/modules/help_topics/src/HelpBreadcrumbBuilder.php b/core/modules/help_topics/src/HelpBreadcrumbBuilder.php new file mode 100644 index 0000000000..586be5303a --- /dev/null +++ b/core/modules/help_topics/src/HelpBreadcrumbBuilder.php @@ -0,0 +1,49 @@ +stringTranslation = $string_translation; + } + + /** + * {@inheritdoc} + */ + public function applies(RouteMatchInterface $route_match) { + return $route_match->getRouteName() == 'help_topics.help_topic'; + } + + /** + * {@inheritdoc} + */ + public function build(RouteMatchInterface $route_match) { + $breadcrumb = new Breadcrumb(); + $breadcrumb->addLink(Link::createFromRoute($this->t('Home'), '{% trans %}This topic should get listed automatically on the Help test topic.{% endtrans %}
diff --git a/core/modules/help_topics/tests/modules/help_topics_test/help_topics/templates/help-topic-help-test-linked.html.twig b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/templates/help-topic-help-test-linked.html.twig new file mode 100644 index 0000000000..2205cf45ad --- /dev/null +++ b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/templates/help-topic-help-test-linked.html.twig @@ -0,0 +1 @@ +{% trans %}This topic is not supposed to be top-level.{% endtrans %}
diff --git a/core/modules/help_topics/tests/modules/help_topics_test/help_topics/templates/help-topic-help-test.html.twig b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/templates/help-topic-help-test.html.twig new file mode 100644 index 0000000000..65a7a5e86c --- /dev/null +++ b/core/modules/help_topics/tests/modules/help_topics_test/help_topics/templates/help-topic-help-test.html.twig @@ -0,0 +1,2 @@ +{% set help_topic_url = render_var(url('help_topics.help_topic', {id: 'help_topic_writing'})) %} +{% trans %}This is a test. It should link to the writing good help topic. Also there should be a related topic link below to the Help module topic page and the linked topic.{% endtrans %}
diff --git a/core/modules/help_topics/tests/modules/help_topics_test/help_topics_test.info.yml b/core/modules/help_topics/tests/modules/help_topics_test/help_topics_test.info.yml new file mode 100644 index 0000000000..155c43d565 --- /dev/null +++ b/core/modules/help_topics/tests/modules/help_topics_test/help_topics_test.info.yml @@ -0,0 +1,7 @@ +# The name of this module is deliberately different from its machine +# name to test the presented order of help topics. +name: 'ABC Help Test' +type: module +description: 'Support module for help testing.' +package: Testing +core: 8.x diff --git a/core/modules/help_topics/tests/modules/help_topics_test/help_topics_test.module b/core/modules/help_topics/tests/modules/help_topics_test/help_topics_test.module new file mode 100644 index 0000000000..a6724446cf --- /dev/null +++ b/core/modules/help_topics/tests/modules/help_topics_test/help_topics_test.module @@ -0,0 +1,18 @@ +install(['seven']); + \Drupal::service('config.factory')->getEditable('system.theme')->set('admin', 'seven')->save(); + + // Place various blocks. + $settings = [ + 'theme' => 'seven', + 'region' => 'help', + ]; + $this->placeBlock('help_block', $settings); + $this->placeBlock('local_tasks_block', $settings); + $this->placeBlock('local_actions_block', $settings); + $this->placeBlock('page_title_block', $settings); + + // Create users. + $this->adminUser = $this->createUser([ + 'access administration pages', + 'view the administration theme', + 'administer permissions', + 'view help topics', + ]); + $this->anyUser = $this->createUser([]); + } + + /** + * Tests the main help page and individual pages for topics. + */ + public function testHelp() { + // Log in the regular user. + $this->drupalLogin($this->anyUser); + $this->verifyHelp(403); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + $this->verifyHelp(); + $this->verifyHelpLinks(); + + // Verify that help topics text appears on admin/help. + $this->drupalGet('admin/help'); + $session = $this->assertSession(); + $session->responseContains('