function ContactPersonalTest::checkContactAccess
Same name in other branches
- 9 core/modules/contact/tests/src/Functional/ContactPersonalTest.php \Drupal\Tests\contact\Functional\ContactPersonalTest::checkContactAccess()
- 10 core/modules/contact/tests/src/Functional/ContactPersonalTest.php \Drupal\Tests\contact\Functional\ContactPersonalTest::checkContactAccess()
- 11.x core/modules/contact/tests/src/Functional/ContactPersonalTest.php \Drupal\Tests\contact\Functional\ContactPersonalTest::checkContactAccess()
Creates a user and then checks contact form access.
Parameters
int $response: The expected response code.
bool $contact_value: (optional) The value the contact field should be set too.
1 call to ContactPersonalTest::checkContactAccess()
- ContactPersonalTest::testAdminContact in core/
modules/ contact/ tests/ src/ Functional/ ContactPersonalTest.php - Tests the personal contact form based access when an admin adds users.
File
-
core/
modules/ contact/ tests/ src/ Functional/ ContactPersonalTest.php, line 302
Class
- ContactPersonalTest
- Tests personal contact form functionality.
Namespace
Drupal\Tests\contact\FunctionalCode
protected function checkContactAccess($response, $contact_value = NULL) {
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/people/create');
if ($this->config('contact.settings')
->get('user_default_enabled', TRUE)) {
$this->assertFieldChecked('edit-contact--2');
}
else {
$this->assertNoFieldChecked('edit-contact--2');
}
$name = $this->randomMachineName();
$edit = [
'name' => $name,
'mail' => $this->randomMachineName() . '@example.com',
'pass[pass1]' => $pass = $this->randomString(),
'pass[pass2]' => $pass,
'notify' => FALSE,
];
if (isset($contact_value)) {
$edit['contact'] = $contact_value;
}
$this->drupalPostForm('admin/people/create', $edit, t('Create new account'));
$user = user_load_by_name($name);
$this->drupalLogout();
$this->drupalGet('user/' . $user->id() . '/contact');
$this->assertSession()
->statusCodeEquals($response);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.