NodeContextualLinksTest.php

Same filename in this branch
  1. 11.x core/modules/node/tests/src/Functional/Views/NodeContextualLinksTest.php
Same filename in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeContextualLinksTest.php
  2. 9 core/modules/node/tests/src/Functional/Views/NodeContextualLinksTest.php
  3. 8.9.x core/modules/node/tests/src/Functional/NodeContextualLinksTest.php
  4. 8.9.x core/modules/node/tests/src/Functional/Views/NodeContextualLinksTest.php
  5. 10 core/modules/node/tests/src/Functional/NodeContextualLinksTest.php
  6. 10 core/modules/node/tests/src/Functional/Views/NodeContextualLinksTest.php

Namespace

Drupal\Tests\node\Functional

File

core/modules/node/tests/src/Functional/NodeContextualLinksTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\node\Functional;

use Drupal\node\Entity\Node;

/**
 * Tests views contextual links on nodes.
 *
 * @group node
 */
class NodeContextualLinksTest extends NodeTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'contextual',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected $defaultTheme = 'stark';
    
    /**
     * Tests contextual links.
     */
    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() . ':');
    }

}

Classes

Title Deprecated Summary
NodeContextualLinksTest Tests views contextual links on nodes.

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