You are here

public function DisplayBlockTest::testBlockRendering in Zircon Profile 8

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

Tests the actual rendering of the views block.

File

core/modules/block/src/Tests/Views/DisplayBlockTest.php, line 243
Contains \Drupal\block\Tests\Views\DisplayBlockTest.

Class

DisplayBlockTest
Tests the block display plugin.

Namespace

Drupal\block\Tests\Views

Code

public function testBlockRendering() {

  // Create a block and set a custom title.
  $block = $this
    ->drupalPlaceBlock('views_block:test_view_block-block_1', array(
    'label' => 'test_view_block-block_1:1',
    'views_label' => 'Custom title',
  ));
  $this
    ->drupalGet('');
  $result = $this
    ->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
  $this
    ->assertEqual((string) $result[0], 'Custom title');

  // Don't override the title anymore.
  $plugin = $block
    ->getPlugin();
  $plugin
    ->setConfigurationValue('views_label', '');
  $block
    ->save();
  $this
    ->drupalGet('');
  $result = $this
    ->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
  $this
    ->assertEqual((string) $result[0], 'test_view_block');

  // Hide the title.
  $block
    ->getPlugin()
    ->setConfigurationValue('label_display', FALSE);
  $block
    ->save();
  $this
    ->drupalGet('');
  $result = $this
    ->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
  $this
    ->assertTrue(empty($result), 'The title is not visible.');
  $this
    ->assertCacheTags(array_merge($block
    ->getCacheTags(), [
    'block_view',
    'config:block_list',
    'config:system.site',
    'config:views.view.test_view_block',
    'rendered',
  ]));
}