NodeContextualLinksTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Drupal\Tests\node\Functional\Views;
  3. use Drupal\user\Entity\User;
  4. /**
  5. * Tests views contextual links on nodes.
  6. *
  7. * @group node
  8. */
  9. class NodeContextualLinksTest extends NodeTestBase {
  10. /**
  11. * Modules to enable.
  12. *
  13. * @var array
  14. */
  15. public static $modules = ['contextual'];
  16. /**
  17. * Tests if the node page works if Contextual Links is disabled.
  18. *
  19. * All views have Contextual links enabled by default, even with the
  20. * Contextual links module disabled. This tests if no calls are done to the
  21. * Contextual links module by views when it is disabled.
  22. *
  23. * @see https://www.drupal.org/node/2379811
  24. */
  25. public function testPageWithDisabledContextualModule() {
  26. \Drupal::service('module_installer')->uninstall(['contextual']);
  27. \Drupal::service('module_installer')->install(['views_ui']);
  28. // Ensure that contextual links don't get called for admin users.
  29. $admin_user = User::load(1);
  30. $admin_user->setPassword('new_password');
  31. $admin_user->passRaw = 'new_password';
  32. $admin_user->save();
  33. $this->drupalCreateContentType(['type' => 'page']);
  34. $this->drupalCreateNode(['promote' => 1]);
  35. $this->drupalLogin($admin_user);
  36. $this->drupalGet('node');
  37. }
  38. }