// Reload the page.
$this->drupalGet($path); $assert_session->pageTextContainsOnce('You have unsaved changes.'); }
/**
* Tests that elements that open the dialog are properly highlighted.
*/ publicfunctiontestAddHighlights(){ $assert_session = $this->assertSession();
$this->drupalGet('test-filter-taxonomy-index-tid'); // We expect no nodes tagged with term 1.0 or 1.1. The node tagged with
// term 2.0 and the untagged node will be shown.
$this->assertSession()->pageTextNotContains($node_with_term_1_0->label()); $this->assertSession()->pageTextNotContains($node_with_terms_1_0_and_1_1->label()); $this->assertSession()->pageTextContainsOnce($node_with_term_2_0->label()); $this->assertSession()->pageTextContainsOnce($node_no_term->label());
// Case 2:
// - filter "tid" with multiple terms as "is one of"
// - filter "tid_2" with a single term as "is one of"
$view = View::load('test_filter_taxonomy_index_tid'); $display =& $view->getDisplay('default'); $display['display_options']['filters']['tid']['value'][0] = $this->terms[1][0]->id(); $display['display_options']['filters']['tid']['value'][1] = $this->terms[1][1]->id(); $display['display_options']['filters']['tid']['operator'] = 'or'; $display['display_options']['filters']['tid']['group'] = 2;
// Hide the message field label.
$display_edit = [ 'fields[message][label]' => 'hidden', ]; $this->drupalGet('admin/structure/contact/manage/' . $contact_form . '/display'); $this->submitForm($display_edit, 'Save');
$session->pageTextContains('WARNING: Content may be overwritten on your new site.'); $session->pageTextContains('There is conflicting content of these types:'); $this->assertNotEmpty($entity_types); foreach($entity_typesas$entity_type){ $label = $entity_type_manager->getDefinition($entity_type)->getPluralLabel(); $session->pageTextContains($label); } $session->pageTextContainsOnce('content items'); $session->pageTextContains('There is translated content of these types:'); }
/**
* Helper to assert content on the Review form.
*
* @param array|null $available_paths
* An array of modules that will be upgraded. Defaults to
* $this->getAvailablePaths().
* @param array|null $missing_paths
* An array of modules that will not be upgraded. Defaults to
* $this->getMissingPaths().
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
// Check that the post information is displayed.
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $this->assertSession()->pageTextContainsOnce('Submitted by'); $node->delete();
// Set "Basic page" content type to display post information.
$edit = []; $edit['display_submitted'] = FALSE; $this->drupalGet('admin/structure/types/manage/page'); $this->submitForm($edit, 'Save content type');
// Create a node.
$edit = []; $edit['title[0][value]'] = $this->randomMachineName(8);
// Make a change. The message will appear.
$this->moveRowWithKeyboard($this->findRowById(5), 'right'); $this->assertSession()->pageTextContainsOnce('You have unsaved changes.');
// Make another change, the text will stay visible and appear only once.
$this->moveRowWithKeyboard($this->findRowById(2), 'up'); $this->assertSession()->pageTextContainsOnce('You have unsaved changes.'); }
/**
* Asserts that several pieces of markup are in a given order in the page.
*
* @param string[] $items
* An ordered list of strings.
*
* @throws \Behat\Mink\Exception\ExpectationException
* When any of the given string is not found.
*
* @todo Remove this and use the WebAssert method when #2817657 is done.
*
* @internal
*/
// We need to check that this string is found as part of a project row, not
// just in the "Failed to get available update data" message at the top of
// the page.
$this->assertSession()->responseContains('<div class="project-update__status">Failed to get available update data');
// We should see the output messages from fetching manually.
$this->assertSession()->pageTextContainsOnce('Checked available update data for 3 projects.'); $this->assertSession()->pageTextContainsOnce('Failed to get available update data for one project.');
protectedfunctiondoTestMenuLinksDiscoveredAlter(){ // Check that machine name does not need to be defined since it is already
// set as the key of each menu link.
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */ $menu_link_manager = \Drupal::service('plugin.manager.menu.link'); $menu_links = $menu_link_manager->loadLinksByRoute('menu_test.custom'); $menu_link = reset($menu_links); $this->assertEquals('menu_test.custom', $menu_link->getPluginId(), 'Menu links added at hook_menu_links_discovered_alter() obtain the machine name from the $links key.'); // Make sure that rebuilding the menu tree does not produce duplicates of
// links added by hook_menu_links_discovered_alter().
$this->drupalGet('menu-test'); $this->assertSession()->pageTextContainsOnce('Custom link'); }
// Make sure admin/appearance warns you you're missing a security update.
$this->drupalGet('admin/appearance'); $this->assertSession()->pageTextNotContains('There are updates available for your version of Drupal.'); $this->assertSession()->pageTextContains('There is a security update available for your version of Drupal.');
// Make sure duplicate messages don't appear on Update status pages.
$this->drupalGet('admin/reports/status'); $this->assertSession()->pageTextContainsOnce('There is a security update available for your version of Drupal.');
$this->drupalGet('admin/reports/updates/settings'); $this->assertSession()->pageTextNotContains('There is a security update available for your version of Drupal.'); }
/**
* Tests the Update Manager module when the update server returns 503 errors.
*/
// Save complete translations for the string in langcode fr.
$edit = [ "strings[$lid][translations][0]" => '1 seconde updated', "strings[$lid][translations][1]" => '@count secondes updated', ]; $this->drupalGet($path); $this->submitForm($edit, 'Save translations');
// User interface input for translating seconds should not be duplicated
$this->assertSession()->pageTextContainsOnce('@count seconds');
// Member for time should be translated. Change the created time to ensure
// that the we're dealing in multiple seconds and it can't be exactly 1
// second or minute.
$this->adminUser->set('created', time() - 2)->save(); $this->drupalGet('user'); $this->assertSession()->pageTextContains("secondes updated"); }
/**
* Tests plural editing and export functionality.
*/
/**
* Tests the upgrade report with the view enabled, disabled and uninstalled.
*/ publicfunctiontestUpgradeReport(){ $session = $this->assertSession();
$this->assertTrue(View::load('watchdog')->status(), 'Watchdog view is enabled'); // Tests redirection to report page when the watchdog view is enabled.
$this->drupalGet('admin/reports/upgrade'); $session->optionExists('type[]', 'migrate_drupal_ui')->isSelected(); $session->pageTextContainsOnce('A test message');
// Tests redirection to report page when the watchdog view is disabled.
$this->drupalGet('admin/reports/upgrade'); $session->optionExists('type[]', 'migrate_drupal_ui')->isSelected(); $session->pageTextContainsOnce('A test message');
/**
* Tests that errors messages are displayed for exposed filters via ajax.
*/ publicfunctiontestExposedFilterErrorMessages(): void { $this->drupalGet('test_user_name'); // Submit an invalid name, triggering validation errors.
$name = $this->randomMachineName(); $this->submitForm(['uid' => $name], 'Apply'); $this->assertSession()->waitForElement('css', 'div[aria-label="Error message"]'); $this->assertSession()->pageTextContainsOnce(sprintf('There are no users matching "%s"', $name));
// Preview the node.
$this->drupalGet('node/' . $node->id() . '/edit'); $this->submitForm($edit, 'Preview'); // Ensure that term is displayed when previewing the node.
$this->assertSession()->pageTextContainsOnce($term2->getName()); $this->drupalGet('node/' . $node->id() . '/edit'); $this->submitForm([], 'Preview'); // Ensure that term is displayed when previewing the node again.
$this->assertSession()->pageTextContainsOnce($term2->getName()); }
/**
* Tests term creation with a free-tagging vocabulary from the node form.
*/ publicfunctiontestNodeTermCreationAndDeletion(){ // Enable tags in the vocabulary.