function OverriddenConfigurationTest::assertOverriddenBlockDisabled

Same name in other branches
  1. 9 core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php \Drupal\Tests\settings_tray\FunctionalJavascript\OverriddenConfigurationTest::assertOverriddenBlockDisabled()
  2. 8.9.x core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php \Drupal\Tests\settings_tray\FunctionalJavascript\OverriddenConfigurationTest::assertOverriddenBlockDisabled()
  3. 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.

@internal

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 173

Class

OverriddenConfigurationTest
Tests handling of configuration overrides.

Namespace

Drupal\Tests\settings_tray\FunctionalJavascript

Code

protected function assertOverriddenBlockDisabled(Block $overridden_block, string $override_text) : void {
    $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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.