public function ContactAjaxTest::createContactAjaxForm in Contact ajax 8
Create a contact form.
1 call to ContactAjaxTest::createContactAjaxForm()
- ContactAjaxTest::configureContactAjax in tests/
src/ FunctionalJavascript/ ContactAjaxTest.php - Add a contact form for each confirmation_type available.
File
- tests/
src/ FunctionalJavascript/ ContactAjaxTest.php, line 126
Class
- ContactAjaxTest
- Tests contact form ajax submission.
Namespace
Drupal\Tests\contact_ajax\FunctionalJavascriptCode
public function createContactAjaxForm($common, $edit) {
$assert = $this
->assertSession();
$message = 'Your message has been sent.';
// 8.2.x added the message field, which is by default empty. Conditionally
// submit it if the field can be found.
$this
->drupalGet('admin/structure/contact/add');
if ($this
->xpath($this
->constructFieldXpath('name', 'message'))) {
$edit['message'] = $message;
}
// First submit the common configs. Because 'id' fields and ajax
// 'advanced settings' are not available until this first step is done, we
// can't submit all at once.
$this
->drupalPostForm(NULL, $common, t('Save'));
// Open the advanced settings.
$this
->click('#edit-advanced summary');
$assert
->waitForElementVisible('css', '[name="contact_ajax_prefix_id"]');
// Make sure the id field is visible.
$assert
->waitForElementVisible('css', '[name="id"]');
// Post the full form.
$this
->drupalPostForm(NULL, $common + $edit, t('Save'));
$assert
->pageTextContains(t('Contact form test_label has been added.'));
}