BlockTemplateSuggestionsTest.php in Drupal 10
File
core/modules/block/tests/src/Kernel/BlockTemplateSuggestionsTest.php
View source
<?php
namespace Drupal\Tests\block\Kernel;
use Drupal\block\Entity\Block;
use Drupal\KernelTests\KernelTestBase;
class BlockTemplateSuggestionsTest extends KernelTestBase {
protected static $modules = [
'block',
'system',
];
public function testBlockThemeHookSuggestions() {
$this
->installConfig([
'system',
]);
$block = Block::create([
'plugin' => 'system_menu_block:admin',
'region' => 'footer',
'id' => 'machinename',
]);
$variables = [];
$plugin = $block
->getPlugin();
$variables['elements']['#configuration'] = $plugin
->getConfiguration();
$variables['elements']['#plugin_id'] = $plugin
->getPluginId();
$variables['elements']['#id'] = $block
->id();
$variables['elements']['#base_plugin_id'] = $plugin
->getBaseId();
$variables['elements']['#derivative_plugin_id'] = $plugin
->getDerivativeId();
$variables['elements']['content'] = [];
$suggestions = block_theme_suggestions_block($variables);
$this
->assertSame([
'block__system',
'block__system_menu_block',
'block__system_menu_block__admin',
'block__machinename',
], $suggestions);
}
}