You are here

protected function OverriddenConfigurationTest::assertOverriddenBlockDisabled in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php \Drupal\Tests\settings_tray\FunctionalJavascript\OverriddenConfigurationTest::assertOverriddenBlockDisabled()
  2. 10 core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php \Drupal\Tests\settings_tray\FunctionalJavascript\OverriddenConfigurationTest::assertOverriddenBlockDisabled()

Asserts that an overridden block has Settings Tray disabled.

Parameters

\Drupal\block\Entity\Block $overridden_block: The overridden block.

string $override_text: The override text that should appear in the block.

1 call to OverriddenConfigurationTest::assertOverriddenBlockDisabled()
OverriddenConfigurationTest::testOverriddenBlock in core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php
Tests that blocks with configuration overrides are disabled.

File

core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php, line 160

Class

OverriddenConfigurationTest
Tests handling of configuration overrides.

Namespace

Drupal\Tests\settings_tray\FunctionalJavascript

Code

protected function assertOverriddenBlockDisabled(Block $overridden_block, $override_text) {
  $web_assert = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $block_selector = $this
    ->getBlockSelector($overridden_block);
  $block_id = $overridden_block
    ->id();

  // Confirm the block does not have a quick edit link.
  $contextual_links = $page
    ->findAll('css', "{$block_selector} .contextual-links li a");
  $this
    ->assertNotEmpty($contextual_links);
  foreach ($contextual_links as $link) {
    $this
      ->assertStringNotContainsString("/admin/structure/block/manage/{$block_id}/off-canvas", $link
      ->getAttribute('href'));
  }

  // Confirm the block is not marked as Settings Tray editable.
  $this
    ->assertFalse($page
    ->find('css', $block_selector)
    ->hasAttribute('data-drupal-settingstray'));

  // Confirm the text is actually overridden.
  $web_assert
    ->elementContains('css', $this
    ->getBlockSelector($overridden_block), $override_text);
}