public function ContactAjaxTest::configureContactAjax in Contact ajax 8
Add a contact form for each confirmation_type available.
1 call to ContactAjaxTest::configureContactAjax()
- ContactAjaxTest::testContactAjax in tests/
src/ FunctionalJavascript/ ContactAjaxTest.php - Tests contact messages submitted through contact form.
File
- tests/
src/ FunctionalJavascript/ ContactAjaxTest.php, line 66
Class
- ContactAjaxTest
- Tests contact form ajax submission.
Namespace
Drupal\Tests\contact_ajax\FunctionalJavascriptCode
public function configureContactAjax() {
$common = [
'label' => 'test_label',
'recipients' => 'simpletest@example.com',
'reply' => '',
'selected' => TRUE,
'contact_ajax_enabled' => TRUE,
];
// Create a basic ajac contact.
$edit = [];
$edit['id'] = 'test_id';
$edit['contact_ajax_confirmation_type'] = CONTACT_AJAX_LOAD_DEFAULT_MESSAGE;
$this
->createContactAjaxForm($common, $edit);
// Add a new contact form to test the custom message confirmation type
// this form should be reload a custom text.
$edit = [];
$edit['id'] = 'test_custom_message_id';
$edit['contact_ajax_confirmation_type'] = CONTACT_AJAX_LOAD_FROM_MESSAGE;
$edit['contact_ajax_load_from_message[value]'] = '<div><b>test ajax message</b></div>';
$this
->createContactAjaxForm($common, $edit);
// Add a new contact form to test the node content confirmation type
// this form should be reload a node content.
$edit = [];
$edit['id'] = 'test_node_content';
$edit['contact_ajax_confirmation_type'] = CONTACT_AJAX_LOAD_FROM_URI;
// Create a content type.
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
$node = $this
->drupalCreateNode([
'title' => 'test ajax title',
'type' => 'article',
]);
$edit['contact_ajax_load_from_uri'] = 'test ajax title (' . $node
->id() . ')';
$this
->createContactAjaxForm($common, $edit);
// Create a form that reload the content on another div element.
$edit = [];
$edit['id'] = 'test_load_other_element';
$edit['contact_ajax_confirmation_type'] = CONTACT_AJAX_LOAD_DEFAULT_MESSAGE;
$edit['contact_ajax_prefix_id'] = 'ajax-contact-prefix';
$edit['contact_ajax_render_selector'] = '#ajax-contact-prefix';
$this
->createContactAjaxForm($common, $edit);
// Create a form that reload the content without the form.
$edit = [];
$edit['id'] = 'test_load_with_validation_errors';
$edit['contact_ajax_confirmation_type'] = CONTACT_AJAX_LOAD_DEFAULT_MESSAGE;
$this
->createContactAjaxForm($common, $edit);
// Ensure that anonymous can submit site-wide contact form.
user_role_grant_permissions(ANONYMOUS_ID, [
'access site-wide contact form',
]);
$this
->drupalLogout();
}