function ContextualLinksTest::testContextualLinksDestinationWithQuery

Same name in other branches
  1. 9 core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\contextual\FunctionalJavascript\ContextualLinksTest::testContextualLinksDestinationWithQuery()
  2. 11.x core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\contextual\FunctionalJavascript\ContextualLinksTest::testContextualLinksDestinationWithQuery()

Tests the contextual links destination with query.

File

core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php, line 142

Class

ContextualLinksTest
Tests the UI for correct contextual links.

Namespace

Drupal\Tests\contextual\FunctionalJavascript

Code

public function testContextualLinksDestinationWithQuery() : void {
    $this->grantPermissions(Role::load(Role::AUTHENTICATED_ID), [
        'access contextual links',
        'administer blocks',
    ]);
    $this->drupalGet('admin/structure/block', [
        'query' => [
            'foo' => 'bar',
        ],
    ]);
    $this->assertSession()
        ->waitForElement('css', '.contextual button');
    $expected_destination_value = Url::fromRoute('block.admin_display')->toString();
    $contextual_link_url_parsed = parse_url($this->getSession()
        ->getPage()
        ->findLink('Configure block')
        ->getAttribute('href'));
    $this->assertEquals("destination={$expected_destination_value}%3Ffoo%3Dbar", $contextual_link_url_parsed['query']);
}

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