From 33c16bf2a27988caa3b143c6bd3152f9cafff596 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Tue, 14 Jul 2020 10:37:35 +0100 Subject: [PATCH] Issue #3087879 by andypost, jhodgdon, alexpott: Use admin theme annotation for help topics search --- .../src/Plugin/Search/HelpSearch.php | 3 +- .../tests/src/Kernel/HelpSearchPluginTest.php | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 core/modules/help_topics/tests/src/Kernel/HelpSearchPluginTest.php diff --git a/core/modules/help_topics/src/Plugin/Search/HelpSearch.php b/core/modules/help_topics/src/Plugin/Search/HelpSearch.php index 458dc4b8ac48..56db5107aa3a 100644 --- a/core/modules/help_topics/src/Plugin/Search/HelpSearch.php +++ b/core/modules/help_topics/src/Plugin/Search/HelpSearch.php @@ -33,7 +33,8 @@ * * @SearchPlugin( * id = "help_search", - * title = @Translation("Help") + * title = @Translation("Help"), + * use_admin_theme = TRUE, * ) * * @internal diff --git a/core/modules/help_topics/tests/src/Kernel/HelpSearchPluginTest.php b/core/modules/help_topics/tests/src/Kernel/HelpSearchPluginTest.php new file mode 100644 index 000000000000..eaea9fe2fc49 --- /dev/null +++ b/core/modules/help_topics/tests/src/Kernel/HelpSearchPluginTest.php @@ -0,0 +1,37 @@ +<?php + +namespace Drupal\Tests\help_topics\Kernel; + +use Drupal\Core\Access\AccessibleInterface; +use Drupal\KernelTests\KernelTestBase; +use Drupal\search\Plugin\SearchIndexingInterface; + +/** + * Tests search plugin behaviors. + * + * @group help_topics + * + * @see \Drupal\help_topics\Plugin\Search\HelpSearch + */ +class HelpSearchPluginTest extends KernelTestBase { + + /** + * {@inheritdoc} + */ + protected static $modules = ['help', 'help_topics', 'search']; + + /** + * Tests search plugin annotation and interfaces. + */ + public function testAnnotation() { + /** @var \Drupal\search\SearchPluginManager $manager */ + $manager = \Drupal::service('plugin.manager.search'); + /** @var \Drupal\help_topics\Plugin\Search\HelpSearch $plugin */ + $plugin = $manager->createInstance('help_search'); + $this->assertInstanceOf(AccessibleInterface::class, $plugin); + $this->assertInstanceOf(SearchIndexingInterface::class, $plugin); + $this->assertSame('Help', (string) $plugin->getPluginDefinition()['title']); + $this->assertTrue($plugin->usesAdminTheme()); + } + +} -- GitLab