You are here

public function OverriddenConfigurationTest::testOverriddenBlock in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php \Drupal\Tests\settings_tray\FunctionalJavascript\OverriddenConfigurationTest::testOverriddenBlock()
  2. 9 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 111

Class

OverriddenConfigurationTest
Tests handling of configuration overrides.

Namespace

Drupal\Tests\settings_tray\FunctionalJavascript

Code

public function testOverriddenBlock() {
  $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' => 'Labely 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, 'Labely label');
  $this
    ->openBlockForm($block_selector);
}