diff --git a/core/modules/block/tests/src/Kernel/BlockDefinitionsTest.php b/core/modules/block/tests/src/Kernel/BlockDefinitionsTest.php index 151189d..4091b00 100644 --- a/core/modules/block/tests/src/Kernel/BlockDefinitionsTest.php +++ b/core/modules/block/tests/src/Kernel/BlockDefinitionsTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\block\Kernel; +use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; use Drupal\KernelTests\KernelTestBase; @@ -16,6 +17,20 @@ class BlockDefinitionsTest extends KernelTestBase { * Tests that every block have a category. */ public function testBlockCategory() { + // Get a list of all modules. + $listing = new ExtensionDiscovery(\Drupal::root()); + $module_list = $listing->scan('module'); + + // Filter out test modules. + $modules = array_filter(array_keys($module_list), function ($module) { + return !strstr($module, 'test'); + }); + + // Load all modules so we can scan them for block plugins. + $this->enableModules($modules); + + // We use the AnnotatedClassDiscovery instead of the BlockManager so we can + // check for empty categories before they are fill with the module's name. $namespaces = $this->container->get('container.namespaces'); $discovery = new AnnotatedClassDiscovery('Plugin/Block', $namespaces, 'Drupal\Core\Block\Annotation\Block'); foreach ($discovery->getDefinitions() as $definition) {