function DefaultViewsTest::clickViewsOperationLink

Same name in other branches
  1. 9 core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views_ui\Functional\DefaultViewsTest::clickViewsOperationLink()
  2. 8.9.x core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views_ui\Functional\DefaultViewsTest::clickViewsOperationLink()
  3. 11.x core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views_ui\Functional\DefaultViewsTest::clickViewsOperationLink()

Click a link to perform an operation on a view.

In general, we expect lots of links titled "enable" or "disable" on the various views listing pages, and they might have tokens in them. So we need special code to find the correct one to click.

Parameters

$label: Text between the anchor tags of the desired link.

$unique_href_part: A unique string that is expected to occur within the href of the desired link. For example, if the link URL is expected to look like "admin/structure/views/view/glossary/*", then "/glossary/" could be passed as the expected unique string.

2 calls to DefaultViewsTest::clickViewsOperationLink()
DefaultViewsTest::testDefaultViews in core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
Tests default views.
DefaultViewsTest::testSplitListing in core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
Tests that enabling views moves them to the correct table.

File

core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php, line 222

Class

DefaultViewsTest
Tests enabling, disabling, and reverting default views via the listing page.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function clickViewsOperationLink($label, $unique_href_part) {
    $this->assertSession()
        ->elementExists('xpath', "//a[normalize-space(text())='{$label}' and contains(@href, '{$unique_href_part}')]")
        ->click();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.