You are here

function BlockTemplateSuggestionsTest::testBlockThemeHookSuggestions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/block/src/Tests/BlockTemplateSuggestionsTest.php \Drupal\block\Tests\BlockTemplateSuggestionsTest::testBlockThemeHookSuggestions()

Tests template suggestions from block_theme_suggestions_block().

File

core/modules/block/src/Tests/BlockTemplateSuggestionsTest.php, line 29
Contains \Drupal\block\Tests\BlockTemplateSuggestionsTest.

Class

BlockTemplateSuggestionsTest
Tests the block_theme_suggestions_block() function.

Namespace

Drupal\block\Tests

Code

function testBlockThemeHookSuggestions() {

  // Define a block with a derivative to be preprocessed, which includes both
  // an underscore (not transformed) and a hyphen (transformed to underscore),
  // and generates possibilities for each level of derivative.
  // @todo Clarify this comment.

  /** @var \Drupal\block\BlockInterface $block */
  $block = entity_create('block', array(
    'plugin' => 'system_menu_block:admin',
    'region' => 'footer',
    'id' => 'machinename',
  ));
  $variables = array();
  $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'] = array();
  $suggestions = block_theme_suggestions_block($variables);
  $this
    ->assertEqual($suggestions, array(
    'block__system',
    'block__system_menu_block',
    'block__system_menu_block__admin',
    'block__machinename',
  ));
}