You are here

public function NodeContextualLinksTest::testNodeContextualLinks in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Tests/Views/NodeContextualLinksTest.php \Drupal\node\Tests\Views\NodeContextualLinksTest::testNodeContextualLinks()

Tests contextual links.

File

core/modules/node/src/Tests/Views/NodeContextualLinksTest.php, line 37
Contains \Drupal\node\Tests\Views\NodeContextualLinksTest.

Class

NodeContextualLinksTest
Tests views contextual links on nodes.

Namespace

Drupal\node\Tests\Views

Code

public function testNodeContextualLinks() {
  $this
    ->drupalCreateContentType(array(
    'type' => 'page',
  ));
  $this
    ->drupalCreateNode(array(
    'promote' => 1,
  ));
  $this
    ->drupalGet('node');
  $user = $this
    ->drupalCreateUser(array(
    'administer nodes',
    'access contextual links',
  ));
  $this
    ->drupalLogin($user);
  $response = $this
    ->renderContextualLinks(array(
    'node:node=1:',
  ), 'node');
  $this
    ->assertResponse(200);
  $json = Json::decode($response);
  $this
    ->setRawContent($json['node:node=1:']);

  // @todo Add these back when the functionality for making Views displays
  //   appear in contextual links is working again.
  // $this->assertLinkByHref('node/1/contextual-links', 0, 'The contextual link to the view was found.');
  // $this->assertLink('Test contextual link', 0, 'The contextual link to the view was found.');
}