You are here

public function ContextualLinksTest::testContextualLinksDestination in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\contextual\FunctionalJavascript\ContextualLinksTest::testContextualLinksDestination()

Tests the contextual links destination.

File

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

Class

ContextualLinksTest
Tests the UI for correct contextual links.

Namespace

Drupal\Tests\contextual\FunctionalJavascript

Code

public function testContextualLinksDestination() {
  $this
    ->grantPermissions(Role::load(Role::AUTHENTICATED_ID), [
    'access contextual links',
    'administer blocks',
  ]);
  $this
    ->drupalGet('user');
  $this
    ->assertSession()
    ->waitForElement('css', '.contextual button');
  $expected_destination_value = (string) $this->loggedInUser
    ->toUrl()
    ->toString();
  $contextual_link_url_parsed = parse_url($this
    ->getSession()
    ->getPage()
    ->findLink('Configure block')
    ->getAttribute('href'));
  $this
    ->assertEquals("destination={$expected_destination_value}", $contextual_link_url_parsed['query']);
}