getBlockSelector example

$this->grantPermissions(Role::load(Role::AUTHENTICATED_ID)$permissions);
    }
    if ($new_page_text) {
      // Some asserts can be based on this value, so it should not be the same       // for different blocks, because it can be saved in the site config.       $new_page_text = $new_page_text . ' ' . $theme . ' ' . $block_plugin;
    }
    $web_assert = $this->assertSession();
    $page = $this->getSession()->getPage();
    $this->enableTheme($theme);
    $block = $this->placeBlock($block_plugin);
    $block_selector = $this->getBlockSelector($block);
    $block_id = $block->id();
    $this->drupalGet('user');

    $link = $web_assert->waitForElement('css', "$block_selector .contextual-links li a");
    $this->assertEquals('Quick edit', $link->getHtml(), "'Quick edit' is the first contextual link for the block.");
    $destination = (string) $this->loggedInUser->toUrl()->toString();
    $this->assertStringContainsString("/admin/structure/block/manage/$block_id/settings-tray?destination=$destination", $link->getAttribute('href'));

    if (isset($toolbar_item)) {
      // Check that you can open a toolbar tray and it will be closed after       // entering edit mode.
      'settings_tray_test_none',
    ];

    $placed_blocks = [];
    foreach ($test_block_plugin_ids as $plugin_id) {
      $placed_blocks[$plugin_id] = $this->placeBlock($plugin_id);
    }

    $this->drupalGet('');
    $web_assert = $this->assertSession();
    foreach ($placed_blocks as $plugin_id => $placed_block) {
      $block_selector = $this->getBlockSelector($placed_block);

      // All blocks are rendered.       $web_assert->elementExists('css', $block_selector);

      // All blocks except 'settings_tray_test_false' are editable. For more       // detailed test coverage, which requires JS execution, see       // \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::testBlocks().       if ($plugin_id === 'settings_tray_test_false') {
        $web_assert->elementNotExists('css', "{$block_selector}[data-drupal-settingstray=\"editable\"]");
      }
      else {
        

  public function testOverriddenConfigurationRemoved() {
    $web_assert = $this->assertSession();
    $page = $this->getSession()->getPage();
    $this->grantPermissions(Role::load(Role::AUTHENTICATED_ID)['administer site configuration', 'administer menu']);

    // Confirm the branding block does include 'site_information' section when     // the site name is not overridden.     $branding_block = $this->placeBlock('system_branding_block');
    $this->drupalGet('user');
    $this->enableEditMode();
    $this->openBlockForm($this->getBlockSelector($branding_block));
    $web_assert->fieldExists('settings[site_information][site_name]');
    // Confirm the branding block does not include 'site_information' section     // when the site name is overridden.     $this->container->get('state')->set('settings_tray_override_test.site_name', TRUE);
    $this->drupalGet('user');
    $this->openBlockForm($this->getBlockSelector($branding_block));
    $web_assert->fieldNotExists('settings[site_information][site_name]');
    $page->pressButton('Save Site branding');
    $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)');
    $web_assert->assertWaitOnAjaxRequest();
    // Confirm we did not save changes to the configuration.

  public function testBlockConfigAccess() {
    $page = $this->getSession()->getPage();
    $web_assert = $this->assertSession();

    // Confirm that System Branding block does not expose Site Name field     // without permission.     $block = $this->placeBlock('system_branding_block');
    $this->drupalGet('user');
    $this->enableEditMode();
    $this->openBlockForm($this->getBlockSelector($block));
    // The site name field should not appear because the user doesn't have     // permission.     $web_assert->fieldNotExists('settings[site_information][site_name]');
    $page->pressButton('Save Site branding');
    $this->waitForOffCanvasToClose();
    $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)');
    $web_assert->assertWaitOnAjaxRequest();
    // Confirm we did not save changes to the configuration.     $this->assertEquals('Drupal', \Drupal::configFactory()->getEditable('system.site')->get('name'));

    $this->grantPermissions(Role::load(Role::AUTHENTICATED_ID)['administer site configuration']);
    
Home | Imprint | This part of the site doesn't use cookies.