You are here

public function CustomBlockVisibilityTest::testVisibilityOfStylesOnCustomBlockTypes in Block Style Plugins 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/CustomBlockVisibilityTest.php \Drupal\Tests\block_style_plugins\Functional\CustomBlockVisibilityTest::testVisibilityOfStylesOnCustomBlockTypes()

Test visibility of styles on custom block types.

Test that the correct styles have been included or excluded from custom block content types.

File

tests/src/Functional/CustomBlockVisibilityTest.php, line 41

Class

CustomBlockVisibilityTest
Test styles showing on content block types.

Namespace

Drupal\Tests\block_style_plugins\Functional

Code

public function testVisibilityOfStylesOnCustomBlockTypes() {
  $assert = $this
    ->assertSession();
  $this
    ->drupalLogin($this->adminUser);

  // Create the custom block.
  $block = $this
    ->createBlockContent('Custom Block Test');

  // Place the custom block.
  $this
    ->drupalPlaceBlock('block_content:' . $block
    ->uuid(), [
    'id' => 'customblocktest',
    'region' => 'content',
  ]);
  $this
    ->drupalGet('admin/structure/block/block-content/types');
  $this
    ->drupalGet('admin/structure/block/block-content');
  $this
    ->drupalGet('block/' . $block
    ->id());
  $assert
    ->pageTextContains('Block description');

  // Go to the block instance configuration page.
  $this
    ->drupalGet('admin/structure/block/manage/customblocktest');

  // Check that the simple class option is visible.
  $assert
    ->responseContains('Add a custom class to this block');

  // Check that the dropdown style options are available.
  $assert
    ->responseContains('Choose a style from the dropdown');

  // Check that the checkbox style options are NOT available.
  $assert
    ->pageTextNotContains('Check this box');
}