function OverriddenConfigurationTest::testOverriddenBlock

Same name in other branches
  1. 9 core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php \Drupal\Tests\settings_tray\FunctionalJavascript\OverriddenConfigurationTest::testOverriddenBlock()
  2. 8.9.x core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php \Drupal\Tests\settings_tray\FunctionalJavascript\OverriddenConfigurationTest::testOverriddenBlock()
  3. 11.x core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php \Drupal\Tests\settings_tray\FunctionalJavascript\OverriddenConfigurationTest::testOverriddenBlock()

Tests that blocks with configuration overrides are disabled.

File

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

Class

OverriddenConfigurationTest
Tests handling of configuration overrides.

Namespace

Drupal\Tests\settings_tray\FunctionalJavascript

Code

public function testOverriddenBlock() : void {
    $web_assert = $this->assertSession();
    $page = $this->getSession()
        ->getPage();
    $overridden_block = $this->placeBlock('system_powered_by_block', [
        'id' => 'overridden_block',
        'label_display' => 1,
        'label' => 'This will be overridden.',
    ]);
    $this->drupalGet('user');
    $block_selector = $this->getBlockSelector($overridden_block);
    // Confirm the block is marked as Settings Tray editable.
    $this->assertEquals('editable', $page->find('css', $block_selector)
        ->getAttribute('data-drupal-settingstray'));
    // Confirm the label is not overridden.
    $web_assert->elementContains('css', $block_selector, 'This will be overridden.');
    $this->enableEditMode();
    $this->openBlockForm($block_selector);
    // Confirm the block Settings Tray functionality is disabled when block is
    // overridden.
    $this->container
        ->get('state')
        ->set('settings_tray_override_test.block', TRUE);
    $overridden_block->save();
    $block_config = \Drupal::configFactory()->getEditable('block.block.overridden_block');
    $block_config->set('settings', $block_config->get('settings'))
        ->save();
    $this->drupalGet('user');
    $this->assertOverriddenBlockDisabled($overridden_block, 'Now this will be the label.');
    // Test a non-overridden block does show the form in the off-canvas dialog.
    $block = $this->placeBlock('system_powered_by_block', [
        'label_display' => 1,
        'label' => 'Foo label',
    ]);
    $this->drupalGet('user');
    $block_selector = $this->getBlockSelector($block);
    // Confirm the block is marked as Settings Tray editable.
    $this->assertEquals('editable', $page->find('css', $block_selector)
        ->getAttribute('data-drupal-settingstray'));
    // Confirm the label is not overridden.
    $web_assert->elementContains('css', $block_selector, 'Foo label');
    $this->openBlockForm($block_selector);
}

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