assertEntityAccess example

/** * Ensures user labels are accessible for everyone. */
  public function testUserLabelAccess() {
    // Set up a non-admin user.     \Drupal::currentUser()->setAccount($this->createUser([], NULL, FALSE, ['uid' => 2]));

    $anonymous_user = User::getAnonymousUser();
    $user = $this->createUser();

    // The current user is allowed to view the anonymous user label.     $this->assertEntityAccess([
      'create' => FALSE,
      'update' => FALSE,
      'delete' => FALSE,
      'view' => FALSE,
      'view label' => TRUE,
    ]$anonymous_user);

    // The current user is allowed to view user labels.     $this->assertEntityAccess([
      'create' => FALSE,
      'update' => FALSE,
      
Home | Imprint | This part of the site doesn't use cookies.