doTestEntityLink example

Role::load(AccountInterface::ANONYMOUS_ROLE)
      ->grantPermission('view test entity')
      ->save();
  }

  /** * Tests entity link fields. */
  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);
  }

  /** * Tests whether entity links behave as expected. * * @param \Drupal\Core\Session\AccountInterface $account * The user account to be used to run the test; * @param bool[] $expected_results * An associative array of expected results keyed by link template name. */
Home | Imprint | This part of the site doesn't use cookies.