function ContactPersonalTest::submitPersonalContact

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

Fills out a user's personal contact form and submits it.

Parameters

\Drupal\Core\Session\AccountInterface $account: A user object of the user being contacted.

array $message: (optional) An array with the form fields being used. Defaults to an empty array.

bool $user_copy: (optional) A boolean to determine whether to send a user copy email. Defaults to FALSE.

Return value

array An array with the form fields being used.

4 calls to ContactPersonalTest::submitPersonalContact()
ContactPersonalTest::testPersonalContactFlood in core/modules/contact/tests/src/Functional/ContactPersonalTest.php
Tests the personal contact form flood protection.
ContactPersonalTest::testPersonalContactForm in core/modules/contact/tests/src/Functional/ContactPersonalTest.php
Tests that the opt-out message is included correctly in contact emails.
ContactPersonalTest::testPersonalContactFormUserCopy in core/modules/contact/tests/src/Functional/ContactPersonalTest.php
Tests that the opt-out message is not included in user copy emails.
ContactPersonalTest::testSendPersonalContactMessage in core/modules/contact/tests/src/Functional/ContactPersonalTest.php
Tests that mails for contact messages are correctly sent.

File

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

Class

ContactPersonalTest
Tests personal contact form functionality.

Namespace

Drupal\Tests\contact\Functional

Code

protected function submitPersonalContact(AccountInterface $account, array $message = [], bool $user_copy = FALSE) {
    $message += [
        'subject[0][value]' => $this->randomMachineName(16) . '< " =+ >',
        'message[0][value]' => $this->randomMachineName(64) . '< " =+ >',
        'copy' => $user_copy,
    ];
    $this->drupalGet('user/' . $account->id() . '/contact');
    $this->submitForm($message, 'Send message');
    return $message;
}

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