linkExists example

    $this->drupalGet('admin/structure/types/manage/before/display/default');
    $assert_session->checkboxNotChecked('layout[enabled]');

    $field_ui_prefix = 'admin/structure/types/manage/after/display/default';
    $this->drupalGet($field_ui_prefix);
    $assert_session->checkboxNotChecked('layout[enabled]');
    $page->checkField('layout[enabled]');
    $page->pressButton('Save');

    $layout_builder_ui = $this->getPathForFieldBlock('node', 'after', 'default', 'body');

    $assert_session->linkExists('Manage layout');
    $this->clickLink('Manage layout');
    // Ensure the body appears once and only once.     $assert_session->elementsCount('css', '.field--name-body', 1);

    // Change the body formatter to Trimmed.     $this->drupalGet($layout_builder_ui);
    $assert_session->fieldValueEquals('settings[formatter][type]', 'text_default');
    $page->selectFieldOption('settings[formatter][type]', 'text_trimmed');
    $assert_session->assertWaitOnAjaxRequest();
    $page->pressButton('Update');
    $page->pressButton('Save layout');

    


    // There should be an informational message if the PHP version is below the     // recommended version.     if (version_compare($phpversion, \Drupal::RECOMMENDED_PHP) < 0) {
      // If it's possible to run Drupal on PHP 8.1.0 to 8.1.5, warn about a       // bug in OPcache.       // @todo Remove this when \Drupal::MINIMUM_PHP is at least 8.1.6 in       // https://www.drupal.org/i/3305726.       if (version_compare(\Drupal::MINIMUM_PHP, '8.1.6') < 0) {
        $this->assertSession()->pageTextContains("PHP $phpversion has an OPcache bug that can cause fatal errors with class autoloading. This can be fixed by upgrading to PHP 8.1.6 or later.");
        $this->assertSession()->linkExists('an OPcache bug that can cause fatal errors with class autoloading');
      }
      else {
        $this->assertSession()->pageTextContains('It is recommended to upgrade to PHP version ' . \Drupal::RECOMMENDED_PHP . ' or higher');
      }
    }
    // Otherwise, the message should not be there.     else {
      $this->assertSession()->pageTextNotContains('It is recommended to upgrade to PHP version ' . \Drupal::RECOMMENDED_PHP . ' or higher');
    }
  }

}
/** * Tests comment links altering. */
  public function testCommentLinksAlter() {
    $this->drupalLogin($this->webUser);
    $comment_text = $this->randomMachineName();
    $subject = $this->randomMachineName();
    $this->postComment($this->node, $comment_text$subject);

    $this->drupalGet('node/' . $this->node->id());

    $this->assertSession()->linkExists('Report');
  }

}
->setRevisionCreationTime((new \DateTimeImmutable('11 January 2009 5pm'))->getTimestamp())
      ->setRevisionTranslationAffected(TRUE)
      ->setNewRevision();
    $entity->save();

    // Reload the entity.     $revision = \Drupal::entityTypeManager()->getStorage('block_content')
      ->loadRevision($revisionId);
    $this->drupalGet($revision->toUrl('revision-revert-form'));
    $this->assertSession()->pageTextContains('Are you sure you want to revert to the revision from Sun, 01/11/2009 - 16:00?');
    $this->assertSession()->buttonExists('Revert');
    $this->assertSession()->linkExists('Cancel');

    $countRevisions = static function D): int {
      return (int) \Drupal::entityTypeManager()->getStorage('block_content')
        ->getQuery()
        ->accessCheck(FALSE)
        ->allRevisions()
        ->count()
        ->execute();
    };

    $count = $countRevisions();
    
'menu[type]' => 'default tab',
      'menu[title]' => 'Test tab title',
    ], 'Apply');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->addressEquals('admin/structure/views/nojs/display/test_view/page_1/tab_options');

    $this->submitForm(['tab_options[type]' => 'tab', 'tab_options[title]' => $this->randomString()], 'Apply');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->addressEquals('admin/structure/views/view/test_view/edit/page_1');

    $this->drupalGet('admin/structure/views/view/test_view');
    $this->assertSession()->linkExists('Tab: Test tab title');
    // If it's a default tab, it should also have an additional settings link.     $this->assertSession()->linkByHrefExists('admin/structure/views/nojs/display/test_view/page_1/tab_options');

    // Ensure that you can select a parent in case the parent does not exist.     $this->drupalGet('admin/structure/views/nojs/display/test_page_display_menu/page_5/menu');
    $this->assertSession()->statusCodeEquals(200);
    $menu_options = $this->assertSession()->selectExists('edit-menu-parent')->findAll('css', 'option');
    $menu_options = array_map(function D$element) {
      return $element->getText();
    }$menu_options);

    

  public function testFilterInReuseForm() {
    $session = $this->getSession();
    $page = $session->getPage();
    $path = 'admin/structure/types/manage/article';
    $path2 = 'admin/structure/types/manage/page';
    $this->fieldUIAddNewFieldJS($path, 'horse', 'Horse');
    $this->fieldUIAddNewFieldJS($path, 'horseradish', 'Horseradish', 'text');
    $this->fieldUIAddNewFieldJS($path, 'carrot', 'Carrot', 'text');
    $this->drupalGet($path2 . '/fields');
    $this->assertSession()->linkExists('Re-use an existing field');
    $this->clickLink('Re-use an existing field');
    $this->assertSession()->waitForElementVisible('css', '#drupal-modal');
    $filter = $this->assertSession()->waitForElementVisible('css', 'input[name="search"]');
    $horse_field_row = $page->find('css', '.js-reuse-table tr[data-field-id="field_horse"]');
    $horseradish_field_row = $page->find('css', '.js-reuse-table tr[data-field-id="field_horseradish"]');
    $carrot_field_row = $page->find('css', '.js-reuse-table tr[data-field-id="field_carrot"]');
    // Confirm every field is visible first.     $this->assertTrue($horse_field_row->isVisible());
    $this->assertTrue($horseradish_field_row->isVisible());
    $this->assertTrue($carrot_field_row->isVisible());
    // Filter by 'horse' field name.
'reply' => 'Thank you for your mail',
    ];
    $this->drupalGet('admin/structure/contact/manage/feedback');
    $this->submitForm($edit, 'Save');

    // Ensure translation link is present.     $translation_base_url = 'admin/structure/contact/manage/feedback/translate';
    $this->assertSession()->linkByHrefExists($translation_base_url);

    // Make sure translate tab is present.     $this->drupalGet('admin/structure/contact/manage/feedback');
    $this->assertSession()->linkExists('Translate contact form');

    // Visit the form to confirm the changes.     $this->drupalGet('contact/feedback');
    $this->assertSession()->pageTextContains($label);

    foreach ($this->langcodes as $langcode) {
      $this->drupalGet($translation_base_url);
      $this->assertSession()->linkExists('Translate contact form');

      // 'Add' link should be present for $langcode translation.       $translation_page_url = "$translation_base_url/$langcode/add";
      
$menu_link_title = $this->randomString();

    $this->drupalLogin($this->contentAdminUser);
    $edit = [
      'title[0][value]' => $this->randomString(),
      'body[0][value]' => $this->randomString(),
      'menu[enabled]' => 1,
      'menu[title]' => $menu_link_title,
    ];
    $this->drupalGet('node/add/page');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->linkExists($menu_link_title);

    // Ensure anonymous users without "access content" permission do not see     // this menu link.     $this->drupalLogout();
    $this->drupalGet('');
    $this->assertSession()->linkNotExists($menu_link_title);

    // Ensure anonymous users with "access content" permission see this menu     // link.     $this->config('user.role.' . RoleInterface::ANONYMOUS_ID)->set('permissions', ['access content'])->save();
    $this->drupalGet('');
    
    $this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/thead/tr/th[1]', 'Name');
    $this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/thead/tr/th[2]', 'Weight');
    $this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/thead/tr/th[3]', 'Operations');

    // Look for test shortcuts in the table.     $weight = count($shortcuts);
    $edit = [];
    foreach ($shortcuts as $shortcut) {
      $title = $shortcut->getTitle();

      // Confirm that a link to the shortcut is found within the table.       $this->assertSession()->linkExists($title);

      // Look for a test shortcut weight select form element.       $this->assertSession()->fieldExists('shortcuts[links][' . $shortcut->id() . '][weight]');

      // Change the weight of the shortcut.       $edit['shortcuts[links][' . $shortcut->id() . '][weight]'] = $weight;
      $weight--;
    }

    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains("The shortcut set has been updated.");

    

  protected $defaultTheme = 'stark';

  /** * Tests deleting workspace entities and uninstalling Workspaces module. */
  public function testUninstallingWorkspace() {
    $this->createContentType(['type' => 'article']);
    $this->drupalLogin($this->rootUser);
    $this->drupalGet('/admin/modules/uninstall');
    $session = $this->assertSession();
    $session->linkExists('Remove workspaces');
    $this->clickLink('Remove workspaces');
    $session->pageTextContains('Are you sure you want to delete all workspaces?');
    $this->drupalGet('/admin/modules/uninstall/entity/workspace');
    $this->submitForm([], 'Delete all workspaces');
    $this->drupalGet('admin/modules/uninstall');
    $this->submitForm(['uninstall[workspaces]' => TRUE], 'Uninstall');
    $this->submitForm([], 'Uninstall');
    $session->pageTextContains('The selected modules have been uninstalled.');
    $session->pageTextNotContains('Workspaces');

    $this->assertFalse(\Drupal::database()->schema()->fieldExists('node_revision', 'workspace'));

    
    $result = $this->xpath('//ul[@id="views-display-menu-tabs"]/li/a/child::text()');
    $this->assertEquals('Display test 2', $result[0]->getText());
    $this->assertEquals('Display test', $result[1]->getText());

    $this->clickLink('Test option title');

    $test_option = $this->randomString();
    $this->submitForm(['test_option' => $test_option], 'Apply');

    // Check the new value has been saved by checking the UI summary text.     $this->drupalGet('admin/structure/views/view/test_view/edit/display_test_1');
    $this->assertSession()->linkExists($test_option);

    // Test the enable/disable status of a display.     $view->display_handler->setOption('enabled', FALSE);
    $this->assertFalse($view->display_handler->isEnabled(), 'Make sure that isEnabled returns FALSE on a disabled display.');
    $view->display_handler->setOption('enabled', TRUE);
    $this->assertTrue($view->display_handler->isEnabled(), 'Make sure that isEnabled returns TRUE on a disabled display.');
  }

  /** * Tests the overriding of filter_groups. */
  


  /** * Tests the moderated content local task appears. */
  public function testModeratedContentLocalTask() {
    $this->drupalLogin($this->adminUser);

    // Verify the moderated content tab exists.     $this->drupalGet('admin/content');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->linkExists('Moderated content');

    // Uninstall the node module which should also remove the tab.     $this->container->get('module_installer')->uninstall(['node']);

    // Verify the moderated content local task does not exist without the node     // module installed.     $this->drupalGet('admin/content');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->linkNotExists('Moderated content');
  }

}
    $this->drupalGet('/update-script-test/database-updates-menu-item');
    $this->assertSession()->linkNotExists('Run database updates');

    // Access the update page with the proper permission.     $this->drupalLogin($this->updateUser);
    $this->drupalGet($this->updateUrl, ['external' => TRUE]);
    $this->assertSession()->statusCodeEquals(200);

    // Check that a link to the update page is accessible to users with proper     // permissions.     $this->drupalGet('/update-script-test/database-updates-menu-item');
    $this->assertSession()->linkExists('Run database updates');

    // Access the update page as user 1.     $this->drupalLogin($this->rootUser);
    $this->drupalGet($this->updateUrl, ['external' => TRUE]);
    $this->assertSession()->statusCodeEquals(200);

    // Check that a link to the update page is accessible to user 1.     $this->drupalGet('/update-script-test/database-updates-menu-item');
    $this->assertSession()->linkExists('Run database updates');
  }

  
public function manageFieldsPage($type = '') {
    $type = empty($type) ? $this->contentType : $type;
    $this->drupalGet('admin/structure/types/manage/' . $type . '/fields');
    // Check all table columns.     $table_headers = ['Label', 'Machine name', 'Field type', 'Operations'];
    foreach ($table_headers as $table_header) {
      // We check that the label appear in the table headings.       $this->assertSession()->responseContains($table_header . '</th>');
    }

    // Test the "Create a new field" action link.     $this->assertSession()->linkExists('Create a new field');

    // Assert entity operations for all fields.     $number_of_links = 3;
    $number_of_links_found = 0;
    $operation_links = $this->xpath('//ul[@class = "dropbutton"]/li/a');
    $url = base_path() . "admin/structure/types/manage/$type/fields/node.$type.body";

    foreach ($operation_links as $link) {
      switch ($link->getAttribute('title')) {
        case 'Edit field settings.':
          $this->assertSame($url$link->getAttribute('href'));
          

  protected function addFormBlock($label$path$expected_save_message) {
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();

    // Go to edit the layout.     $this->drupalGet($path . '/layout');

    // Add the form block.     $assert_session->linkExists('Add block');
    $this->clickLink('Add block');
    $assert_session->waitForElementVisible('named', ['link', $label]);
    $assert_session->linkExists($label);
    $this->clickLink($label);
    $assert_session->waitForElementVisible('named', ['button', 'Add block']);
    $page->pressButton('Add block');
    $assert_session->assertWaitOnAjaxRequest();
    $assert_session->pageTextContains($label);
    $assert_session->addressEquals($path . '/layout');

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