function NodeContextualLinksTest::testNodeContextualLinks

Same name in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeContextualLinksTest.php \Drupal\Tests\node\Functional\NodeContextualLinksTest::testNodeContextualLinks()
  2. 8.9.x core/modules/node/tests/src/Functional/NodeContextualLinksTest.php \Drupal\Tests\node\Functional\NodeContextualLinksTest::testNodeContextualLinks()
  3. 10 core/modules/node/tests/src/Functional/NodeContextualLinksTest.php \Drupal\Tests\node\Functional\NodeContextualLinksTest::testNodeContextualLinks()

Tests contextual links.

File

core/modules/node/tests/src/Functional/NodeContextualLinksTest.php, line 31

Class

NodeContextualLinksTest
Tests views contextual links on nodes.

Namespace

Drupal\Tests\node\Functional

Code

public function testNodeContextualLinks() : void {
    // Create a node item.
    $node = Node::create([
        'type' => 'article',
        'title' => 'Unnamed',
    ]);
    $node->save();
    $user = $this->drupalCreateUser([
        'administer nodes',
        'access contextual links',
    ]);
    $this->drupalLogin($user);
    $this->drupalGet('node/' . $node->id());
    $this->assertSession()
        ->elementAttributeContains('css', 'div[data-contextual-id]', 'data-contextual-id', 'node:node=' . $node->id() . ':');
}

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