enableEditMode example


  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();
    
if (isset($toolbar_item)) {
      // Check that you can open a toolbar tray and it will be closed after       // entering edit mode.       if ($element = $page->find('css', "#toolbar-administration a.is-active")) {
        // If a tray was open from page load close it.         $element->click();
        $web_assert->assertNoElementAfterWait('css', "#toolbar-administration a.is-active");
      }
      $page->find('css', $toolbar_item)->click();
      $this->assertElementVisibleAfterWait('css', "{$toolbar_item}.is-active");
    }
    $this->enableEditMode();
    if (isset($toolbar_item)) {
      $web_assert->assertNoElementAfterWait('css', "{$toolbar_item}.is-active");
    }
    $this->openBlockForm($block_selector);
    switch ($block_plugin) {
      case 'system_powered_by_block':
        // Confirm "Display Title" is not checked.         $web_assert->checkboxNotChecked('settings[label_display]');
        // Confirm Title is not visible.         $this->assertFalse($this->isLabelInputVisible(), 'Label is not visible');
        $page->checkField('settings[label_display]');
        
/** * Tests access to block forms with related configuration is correct. */
  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'));

    
Home | Imprint | This part of the site doesn't use cookies.