function FieldEntityLinkTest::testEntityLink

Same name and namespace in other branches
  1. 8.9.x core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php \Drupal\Tests\views\Kernel\Handler\FieldEntityLinkTest::testEntityLink()
  2. 10 core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php \Drupal\Tests\views\Kernel\Handler\FieldEntityLinkTest::testEntityLink()
  3. 11.x core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php \Drupal\Tests\views\Kernel\Handler\FieldEntityLinkTest::testEntityLink()

Tests entity link fields.

File

core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php, line 70

Class

FieldEntityLinkTest
Tests the core <a href="/api/drupal/core%21modules%21views%21src%21Plugin%21views%21field%21EntityOperations.php/class/EntityOperations/9" title="Renders all operations links for an entity." class="local">Drupal\views\Plugin\views\field\EntityOperations</a> handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testEntityLink() {
    // Anonymous users cannot see edit/delete links.
    $expected_results = [
        'canonical' => TRUE,
        'edit-form' => FALSE,
        'delete-form' => FALSE,
        'canonical_raw' => TRUE,
        'canonical_raw_absolute' => TRUE,
    ];
    $this->doTestEntityLink(\Drupal::currentUser(), $expected_results);
    // Admin users cannot see all links.
    $expected_results = [
        'canonical' => TRUE,
        'edit-form' => TRUE,
        'delete-form' => TRUE,
        'canonical_raw' => TRUE,
        'canonical_raw_absolute' => TRUE,
    ];
    $this->doTestEntityLink($this->adminUser, $expected_results);
}

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