Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / block / tests / src / Functional / BlockTemplateSuggestionsTest.php
1 <?php
2
3 namespace Drupal\Tests\block\Functional;
4
5 use Drupal\block\Entity\Block;
6 use Drupal\Tests\BrowserTestBase;
7
8 /**
9  * Tests the block_theme_suggestions_block() function.
10  *
11  * @group block
12  */
13 class BlockTemplateSuggestionsTest extends BrowserTestBase {
14
15   /**
16    * Modules to install.
17    *
18    * @var array
19    */
20   public static $modules = ['block'];
21
22   /**
23    * Tests template suggestions from block_theme_suggestions_block().
24    */
25   public function testBlockThemeHookSuggestions() {
26     // Define a block with a derivative to be preprocessed, which includes both
27     // an underscore (not transformed) and a hyphen (transformed to underscore),
28     // and generates possibilities for each level of derivative.
29     // @todo Clarify this comment.
30     $block = Block::create([
31       'plugin' => 'system_menu_block:admin',
32       'region' => 'footer',
33       'id' => 'machinename',
34     ]);
35
36     $variables = [];
37     $plugin = $block->getPlugin();
38     $variables['elements']['#configuration'] = $plugin->getConfiguration();
39     $variables['elements']['#plugin_id'] = $plugin->getPluginId();
40     $variables['elements']['#id'] = $block->id();
41     $variables['elements']['#base_plugin_id'] = $plugin->getBaseId();
42     $variables['elements']['#derivative_plugin_id'] = $plugin->getDerivativeId();
43     $variables['elements']['content'] = [];
44     $suggestions = block_theme_suggestions_block($variables);
45     $this->assertEqual($suggestions, ['block__system', 'block__system_menu_block', 'block__system_menu_block__admin', 'block__machinename']);
46   }
47
48 }