function ContactPersonalTest::testPersonalContactFormUserCopy

Same name in other branches
  1. 11.x core/modules/contact/tests/src/Functional/ContactPersonalTest.php \Drupal\Tests\contact\Functional\ContactPersonalTest::testPersonalContactFormUserCopy()

Tests that the opt-out message is not included in user copy emails.

File

core/modules/contact/tests/src/Functional/ContactPersonalTest.php, line 380

Class

ContactPersonalTest
Tests personal contact form functionality.

Namespace

Drupal\Tests\contact\Functional

Code

public function testPersonalContactFormUserCopy() : void {
    $opt_out_message = "If you don't want to receive such messages, you can change your settings at";
    // Send an email from an admin.
    $this->drupalLogin($this->adminUser);
    $this->submitPersonalContact($this->contactUser, [], TRUE);
    $this->drupalLogout();
    // Send an email from a non-admin.
    $this->drupalLogin($this->webUser);
    $this->submitPersonalContact($this->contactUser, [], TRUE);
    $user_copy_emails = $this->getMails([
        'id' => 'contact_user_copy',
    ]);
    // Tests that the opt-out message is not included in admin user copy emails.
    $this->assertStringNotContainsString($opt_out_message, $user_copy_emails[0]['body'], 'Opt-out message not included in admin user copy email.');
    // Tests that the opt-out message is not included in non-admin user copy emails.
    $this->assertStringNotContainsString($opt_out_message, $user_copy_emails[1]['body'], 'Opt-out message not included in non-admin user copy email.');
}

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