clickLink example

->removeComponent('body')
      ->save();

    $view_mode_edit = ['view_mode' => 'teaser'];
    $this->drupalGet('node/preview/' . $uuid . '/full');
    $this->submitForm($view_mode_edit, 'Switch');
    $this->assertSession()->responseContains('view-mode-teaser');
    $this->assertSession()->pageTextNotContains($edit[$body_key]);

    // Check that the title, body and term fields are displayed with the     // values after going back to the content edit page.     $this->clickLink('Back to content editing');
    $this->assertSession()->fieldValueEquals($title_key$edit[$title_key]);
    $this->assertSession()->fieldValueEquals($body_key$edit[$body_key]);
    $this->assertSession()->fieldValueEquals($term_key$edit[$term_key]);
    $this->assertSession()->fieldValueEquals('field_image[0][alt]', 'Picture of llamas');
    $this->getSession()->getPage()->pressButton('Add another item');
    $this->assertSession()->fieldExists('field_test_multi[0][value]');
    $this->assertSession()->fieldExists('field_test_multi[1][value]');

    // Return to page preview to check everything is as expected.     $this->submitForm([], 'Preview');
    $this->assertSession()->titleEquals($expected_title);
    
/** * Tests that requirements warnings and errors are correctly displayed. */
  public function testRequirements() {
    $update_script_test_config = $this->config('update_script_test.settings');
    $this->drupalLogin($this->updateUser);

    // If there are no requirements warnings or errors, we expect to be able to     // go through the update process uninterrupted.     $this->drupalGet($this->updateUrl, ['external' => TRUE]);
    $this->updateRequirementsProblem();
    $this->clickLink('Continue');
    $this->assertSession()->pageTextContains('No pending updates.');
    // Confirm that all caches were cleared.     $this->assertSession()->pageTextContains('hook_cache_flush() invoked for update_script_test.module.');

    // If there is a requirements warning, we expect it to be initially     // displayed, but clicking the link to proceed should allow us to go     // through the rest of the update process uninterrupted.
    // First, run this test with pending updates to make sure they can be run     // successfully.     $this->drupalLogin($this->updateUser);
    

    $this->assertCacheTags($expected_cache_tags);

    \Drupal::configFactory()
      ->getEditable('stark.settings')
      ->set('third_party_settings.shortcut.module_link', TRUE)
      ->save(TRUE);

    // Add cron to the default shortcut set, now the shortcut list cache tag     // is expected.     $this->drupalGet('admin/config/system/cron');
    $this->clickLink('Add to Default shortcuts');
    $expected_cache_tags[] = 'config:shortcut_set_list';
    $this->assertCacheTags($expected_cache_tags);

    // Verify that users without the 'access shortcuts' permission can't see the     // shortcuts.     $this->drupalLogin($this->drupalCreateUser(['access toolbar']));
    $this->assertSession()->linkNotExists('Shortcuts');
    $this->verifyDynamicPageCache($test_page_url, 'MISS');
    $this->verifyDynamicPageCache($test_page_url, 'HIT');

    // Verify that users without the 'administer site configuration' permission
/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * Tests that links respect 'data-dialog-renderer' attribute. */
  public function testModalRenderer() {
    $session_assert = $this->assertSession();
    $this->drupalGet('/dialog_renderer-test-links');
    $this->clickLink('Normal Modal!');

    // Neither of the wide modals should have been used.     $style = $session_assert->waitForElementVisible('css', '.ui-dialog')->getAttribute('style');
    $this->assertStringNotContainsString('700px', $style);
    $this->assertStringNotContainsString('1000px', $style);

    // Tabbable should focus the close button when it is the only tabbable item.     $this->assertJsCondition('document.activeElement === document.querySelector(".ui-dialog .ui-dialog-titlebar-close")');
    $this->drupalGet('/dialog_renderer-test-links');
    $this->clickLink('Wide Modal!');
    $this->assertNotEmpty($session_assert->waitForElementVisible('css', '.ui-dialog[style*="width: 700px;"]'));
    
    $this->drupalGet('entity_test/1/test');
    $this->assertSession()->elementNotExists('css', '.layout__region--content ');
    $this->drupalGet('entity_test/1');
    $this->assertSession()->elementNotExists('css', '.layout__region--content');

    // Change the layout for the "test" view mode. See     // core.entity_view_mode.entity_test.test.yml.     $this->drupalGet('entity_test/structure/entity_test/display');
    $this->click('#edit-modes');
    $this->getSession()->getPage()->checkField('display_modes_custom[test]');
    $this->submitForm([], 'Save');
    $this->clickLink('configure them');
    $this->getSession()->getPage()->pressButton('Show row weights');
    $this->getSession()->getPage()->selectFieldOption('fields[field_test_text][region]', 'content');
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->submitForm([], 'Save');

    // Each view mode has a different layout.     $this->drupalGet('entity_test/1/test');
    $this->assertSession()->elementTextContains('css', '.layout__region--content', 'The field test text value');
    $this->drupalGet('entity_test/1');
    $this->assertSession()->elementNotExists('css', '.layout__region--content');
  }

  
// No validation error upon enabling the Style plugin.     $this->assertNoRealtimeValidationErrors();
    $assert_session->pageTextContains('No styles configured');

    // Still no validation error when configuring other functionality first.     $this->triggerKeyUp('.ckeditor5-toolbar-item-undo', 'ArrowDown');
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertNoRealtimeValidationErrors();

    // The Style plugin settings form should now be present and should have no     // styles configured.     $page->clickLink('Style');
    $this->assertNotNull($assert_session->waitForElementVisible('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-style-styles"]'));

    $javascript = <<<JS const allowedTags = document.querySelector('[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-style-styles"]'); allowedTags.value = 'p.foo.bar | Foobar paragraph'; allowedTags.dispatchEvent(new Event('input')); JS;
    $this->getSession()->executeScript($javascript);

    // Immediately save the configuration. Intentionally do nothing that would     // trigger an AJAX rebuild.
'edit any bundle_with_section_field content',
    ]));
    $page = $this->getSession()->getPage();

    // Create a node.     $this->node = $this->createNode([
      'type' => 'bundle_with_section_field',
      'title' => 'A node at rest will stay at rest.',
    ]);

    $this->drupalGet('node/' . $this->node->id() . '/layout');
    $page->clickLink('Add block');
    $page->clickLink('Powered by Drupal');
    $page->fillField('settings[label]', 'This is an override');
    $page->checkField('settings[label_display]');
    $page->pressButton('Add block');
    $page->pressButton('Save layout');
    $assert_session->pageTextContains('This is an override');

    $this->nodeStorage = $this->container->get('entity_type.manager')->getStorage('node');
    $this->node = $this->nodeStorage->load($this->node->id());

    $this->drupalLogout();
    
/** * Tests book export ("printer-friendly version") functionality. */
  public function testBookExport() {
    // Create a book.     $nodes = $this->createBook();

    // Log in as web user and view printer-friendly version.     $this->drupalLogin($this->webUser);
    $this->drupalGet('node/' . $this->book->id());
    $this->clickLink('Printer-friendly version');

    // Make sure each part of the book is there.     foreach ($nodes as $node) {
      $this->assertSession()->pageTextContains($node->label());
      $this->assertSession()->responseContains($node->body->processed);
    }

    // Make sure we can't export an unsupported format.     $this->drupalGet('book/export/foobar/' . $this->book->id());
    $this->assertSession()->statusCodeEquals(404);

    
// Enable the second group of dependee modules.     $second_module_form_post = [];
    foreach ($second_modules as $module) {
      $second_module_form_post["modules[$module][enable]"] = 1;
    }
    $this->drupalGet('admin/modules');
    $this->submitForm($second_module_form_post, 'Install');
    $assert_module_enabled_message($second_modules);

    // The theme should now be installable, so install it.     $this->drupalGet('admin/appearance');
    $page->clickLink("Install $theme_name theme");
    $assert_session->addressEquals('admin/appearance');
    $assert_session->pageTextContains("The $theme_name theme has been installed");

    // Confirm that the dependee modules can't be uninstalled because an enabled     // theme depends on them.     $this->drupalGet('admin/modules/uninstall');
    foreach ($all_dependent_modules as $attribute) {
      $assert_session->elementExists('css', "[name=\"uninstall[$attribute]\"][disabled]");
    }
    foreach ($required_by_messages as $selector => $message) {
      $assert_session->elementTextContains('css', $selector$message);
    }

  public function testAliases() {
    // Switch to French and try to access the now inaccessible block.     $this->drupalGet('');

    // Create an alias for user/UID just for en, make sure that this is a 404     // on the french page exist in english, no matter which language is     // checked first. Create the alias after visiting frontpage to make sure     // there is no existing cache entry for this that affects the tests.     $this->createPathAlias('/user/' . $this->adminUser->id(), '/user-page', 'en');

    $this->clickLink('French');
    $this->drupalGet('user-page');
    $this->assertSession()->statusCodeEquals(404);

    // Switch to english, make sure it works now.     $this->clickLink('English');
    $this->drupalGet('user-page');
    $this->assertSession()->statusCodeEquals(200);

    // Clear cache and repeat the check, this time with english first.     $this->resetAll();
    $this->drupalGet('user-page');
    
/** * Tests that analyze works in general. */
  public function testAnalyzeBasic() {
    $this->drupalLogin($this->adminUser);

    $this->drupalGet('admin/structure/views/view/test_view/edit');
    $this->assertSession()->linkExists('Analyze view');

    // This redirects the user to the analyze form.     $this->clickLink('Analyze view');
    $this->assertSession()->titleEquals('View analysis | Drupal');

    foreach (['ok', 'warning', 'error'] as $type) {
      // Check that analyse messages with the expected type found.       $this->assertSession()->elementExists('css', 'div.' . $type);
    }

    // This redirects the user back to the main views edit page.     $this->submitForm([], 'Ok');
  }

}
public function testSettingsForm() {
    $account = $this->drupalCreateUser([
      'access administration pages',
      'administer media',
    ]);
    $this->drupalLogin($account);

    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->drupalGet('/admin/config');
    $page->clickLink('Media Library settings');
    $page->checkField('Enable advanced UI');
    $page->pressButton('Save configuration');
    $assert_session->checkboxChecked('Enable advanced UI');
    $page->uncheckField('Enable advanced UI');
    $page->pressButton('Save configuration');
    $assert_session->checkboxNotChecked('Enable advanced UI');
  }

}


  /** * Tests that after removing sections reloading the page does not re-add them. */
  public function testReloadWithNoSections() {
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();

    // Remove all of the sections from the page.     $this->drupalGet(static::FIELD_UI_PREFIX . '/display/default/layout');
    $page->clickLink('Remove Section 1');
    $assert_session->assertWaitOnAjaxRequest();
    $page->pressButton('Remove');
    $assert_session->assertWaitOnAjaxRequest();
    // Assert that there are no sections on the page.     $assert_session->pageTextNotContains('Remove Section 1');
    $assert_session->pageTextNotContains('Add block');

    // Reload the page.     $this->drupalGet(static::FIELD_UI_PREFIX . '/display/default/layout');
    // Assert that there are no sections on the page.     $assert_session->pageTextNotContains('Remove Section 1');
    
// Log in as an administrative user to access the full menu trail.     $this->drupalLogin($this->drupalCreateUser([
      'access administration pages',
      'administer site configuration',
    ]));

    // Get the list page.     $this->drupalGet('admin/structure/config_test');
    $this->assertSession()->linkByHrefExists('admin/structure/config_test/manage/dotted.default');

    // Add a new entity using the action link.     $this->clickLink('Add test configuration');
    $edit = [
      'label' => 'Antilop',
      'id' => 'antilop',
      'langcode' => 'hu',
    ];
    $this->submitForm($edit, 'Save');
    // Ensure that operations for editing the Hungarian entity appear in English.     $this->assertSession()->linkByHrefExists('admin/structure/config_test/manage/antilop');

    // Get the list page in Hungarian and assert Hungarian admin links     // regardless of language of config entities.
    // removed.     foreach (['1', '2', '1'] as $link_index) {
      $this->assertOffCanvasDialog($link_index, 'side');
      $header_text = $this->getOffCanvasDialog()->find('css', '.ui-dialog-title')->getText();
      if ($link_index == '2') {
        // Check no title behavior.         $web_assert->elementExists('css', '.ui-dialog-empty-title');
        $this->assertEquals(' ', $header_text);

        $style = $page->find('css', '.ui-dialog-off-canvas')->getAttribute('style');
        $this->assertStringContainsString('width: 555px;', $style, 'Dialog width respected.');
        $page->clickLink("Open side panel 1");
        $this->waitForOffCanvasToOpen();
        $style = $page->find('css', '.ui-dialog-off-canvas')->getAttribute('style');
        $this->assertStringNotContainsString('width: 555px;', $style, 'Dialog width reset to default.');
      }
      else {
        // Check that header is correct.         $this->assertEquals("Thing $link_index", $header_text);
        $web_assert->elementNotExists('css', '.ui-dialog-empty-title');
      }
    }

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