function ContactPersonalTest::submitPersonalContact

Same name in other branches
  1. 8.9.x core/modules/contact/tests/src/Functional/ContactPersonalTest.php \Drupal\Tests\contact\Functional\ContactPersonalTest::submitPersonalContact()
  2. 10 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.

Return value

array An array with the form fields being used.

2 calls to ContactPersonalTest::submitPersonalContact()
ContactPersonalTest::testPersonalContactFlood in core/modules/contact/tests/src/Functional/ContactPersonalTest.php
Tests the personal contact form flood protection.
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 343

Class

ContactPersonalTest
Tests personal contact form functionality.

Namespace

Drupal\Tests\contact\Functional

Code

protected function submitPersonalContact(AccountInterface $account, array $message = []) {
    $message += [
        'subject[0][value]' => $this->randomMachineName(16) . '< " =+ >',
        'message[0][value]' => $this->randomMachineName(64) . '< " =+ >',
    ];
    $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.