assertContactLinks example

// Create an account with no access to contact pages.     $no_contact_account = $this->drupalCreateUser();
    $accounts['no_contact'] = $no_contact_account;

    // Create an account with access to contact pages.     $contact_account = $this->drupalCreateUser(['access user contact forms']);
    $accounts['contact'] = $contact_account;

    $this->drupalLogin($admin_account);
    $this->drupalGet('test-contact-link');
    // The admin user has access to all contact links beside their own.     $this->assertContactLinks($accounts['root', 'no_contact', 'contact']);

    $this->drupalLogin($no_contact_account);
    $this->drupalGet('test-contact-link');
    // Ensure that the user without the permission doesn't see any link.     $this->assertContactLinks($accounts[]);

    $this->drupalLogin($contact_account);
    $this->drupalGet('test-contact-link');
    $this->assertContactLinks($accounts['root', 'admin', 'no_contact']);

    // Disable contact link for no_contact.
Home | Imprint | This part of the site doesn't use cookies.