/**
* Asserts that a given link is not present.
*
* @param \Behat\Mink\Element\NodeElement $element
* The element to search.
* @param string $text
* The link text.
*
* @internal
*/
/**
* Tests that the search form block can be placed and works.
*/ publicfunctiontestSearchFormBlock(){
// Test availability of the search block in the admin "Place blocks" list.
$this->drupalGet('admin/structure/block'); $this->getSession()->getPage()->findLink('Place block')->click(); $this->assertSession()->linkByHrefExists('/admin/structure/block/add/search_form_block/stark', 0, 'Did not find the search block in block candidate list.');
/**
* Toggles the visibility of a contextual trigger.
*
* @param string $selector
* The selector for the element that contains the contextual link.
*/
$page->waitFor(10, function D)use($page, $selector){ return$page->find('css', "$selector .contextual-links"); }); if(count($page->findAll('css', "$selector .contextual-links")) > 1){ thrownew \Exception('More than one contextual links found by selector'); }
// Test field UI and field integration.
$this->drupalGet('admin/structure/contact');
// Test contact listing links to contact form.
$this->assertSession()->elementExists('xpath', $this->assertSession()->buildXPathQuery('//table/tbody/tr/td/a[contains(@href, :href) and text()=:text]', [ ':href' => Url::fromRoute('entity.contact_form.canonical', ['contact_form' => $contact_form])->toString(), ':text' => $label, ]));
// Find out in which row the form we want to add a field to is.
foreach($this->xpath('//table/tbody/tr')as$row){ if($row->findLink($label)){ $row->clickLink('Manage fields'); break; } }
/**
* Test to ensure that remove contextual link is present in the block.
*/ publicfunctiontestBlockContextualRemoveLinks(){ // Ensure that contextual filter links are visible on the page.
$this->drupalLogin($this->rootUser); $this->drupalGet('<front>'); $contextual_id = "[data-contextual-id^='block:block=$this->blockId:langcode=en']"; $this->assertSession()->waitForElement('css', "$contextual_id .contextual-links");
// @todo Work out why this fixes random fails in this test.
// https://www.drupal.org/project/drupal/issues/3055982
$this->getSession()->resizeWindow(800, 1000); $assert_session = $this->assertSession(); $page = $this->getSession()->getPage();
/**
* Tests dialog for filter criteria.
*/ publicfunctiontestFilterCriteriaDialog(){ // Checks that the admin summary is not double escaped.
$this->drupalGet('admin/structure/views/view/who_s_online'); $page = $this->getSession()->getPage(); $this->assertNotNull($page->findLink('User: Last access (>= -15 minutes)'));
// Add a new filter group.
$create_new_filter_group = $page->findById('views-add-group-link'); $this->assertTrue($create_new_filter_group->isVisible(), 'Add group link found.');
// Test that the bulk form works when a node gets deleted by another user
// before the loaded bulk form can be used.
$this->drupalGet('test_bulk_form'); // Now delete the node we want to delete with the bulk form.
$link = $this->getSession()->getPage()->findLink($nodes[6]->label()); $checkbox = $link->getParent()->getParent()->find('css', 'input'); $nodes[6]->delete(); $edit = [ $checkbox->getAttribute('name') => TRUE, 'action' => 'node_delete_action', ]; $this->submitForm($edit, 'Apply to selected items'); // Make sure we just return to the bulk view with no warnings.
$this->assertSession()->addressEquals('test_bulk_form'); $this->assertSession()->elementNotExists('xpath', '//div[contains(@class, "messages--status")]');
// Test that it is possible to toggle the toolbar tray.
$content = $page->findLink('Content'); $this->assertTrue($content->isVisible(), 'Toolbar tray is open by default.'); $page->clickLink('Manage'); $this->assertFalse($content->isVisible(), 'Toolbar tray is closed after clicking the "Manage" link.'); $page->clickLink('Manage'); $this->assertTrue($content->isVisible(), 'Toolbar tray is visible again after clicking the "Manage" button a second time.');
// Test toggling the toolbar tray between horizontal and vertical.
$tray = $page->findById('toolbar-item-administration-tray'); $this->assertFalse($tray->hasClass('toolbar-tray-vertical'), 'Toolbar tray is not vertically oriented by default.'); $page->pressButton('Vertical orientation'); $this->assertTrue($tray->hasClass('toolbar-tray-vertical'), 'After toggling the orientation the toolbar tray is now displayed vertically.');
// Second step: 'Storage settings' form.
$page->findButton('Save field settings')->click(); $assert_session->pageTextContains("Updated field $label field settings.");
// Test the wait...() methods by first checking the fields aren't available
// and then are available after the wait method.
$result = $page->findButton('Added button'); $this->assertEmpty($result); $test_button->click(); $result = $assert_session->waitForButton('Added button'); $this->assertNotEmpty($result); $this->assertInstanceOf(NodeElement::class, $result);
// Test that no unwanted parameters are added to the URL.
$this->assertEquals('?status=All&type=All&title=&langcode=All&items_per_page=5&order=changed&sort=asc&page=2', $link->getAttribute('href'));
// Disable a View and see if it moves to the disabled listing.
$enabled_view = $page->find('css', 'tr.views-ui-list-enabled'); $view_description = $enabled_view->find('css', '.views-ui-view-name strong')->getText(); // Open the dropdown with additional actions.
$enabled_view->find('css', 'li.dropbutton-toggle button')->click(); $disable_button = $enabled_view->findLink('Disable'); // Check that the disable button is visible now.
$this->assertTrue($disable_button->isVisible()); $disable_button->click();