function NodeContextualLinksTest::testPageWithDisabledContextualModule

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

Tests if the node page works if Contextual Links is disabled.

All views have Contextual links enabled by default, even with the Contextual links module disabled. This tests if no calls are done to the Contextual links module by views when it is disabled.

See also

https://www.drupal.org/node/2379811

File

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

Class

NodeContextualLinksTest
Tests views contextual links on nodes.

Namespace

Drupal\Tests\node\Functional\Views

Code

public function testPageWithDisabledContextualModule() {
    \Drupal::service('module_installer')->uninstall([
        'contextual',
    ]);
    \Drupal::service('module_installer')->install([
        'views_ui',
    ]);
    // Ensure that contextual links don't get called for admin users.
    $admin_user = User::load(1);
    $admin_user->setPassword('new_password');
    $admin_user->passRaw = 'new_password';
    $admin_user->save();
    $this->drupalCreateContentType([
        'type' => 'page',
    ]);
    $this->drupalCreateNode([
        'promote' => 1,
    ]);
    $this->drupalLogin($admin_user);
    $this->drupalGet('node');
}

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