public function RulesFormsInterfaceTestCase::testFormActivation in Rules Forms Support 7
Same name and namespace in other branches
- 7.2 rules_forms.test \RulesFormsInterfaceTestCase::testFormActivation()
Tests the administrative interface.
File
- ./
rules_forms.test, line 49 - Stores tests related to Rules Form.
Class
- RulesFormsInterfaceTestCase
- Class that tests Rules Forms.
Code
public function testFormActivation() {
$this
->drupalGet(RULES_FORMS_ADMIN_PATH);
$this
->assertNoText(t('Events enabled forms'), t('No forms are activated yet.'));
$this
->assertNoText(t('Form elements'));
// Activate form event messages.
$edit = array();
$edit['enable_form_activation_message'] = 1;
$this
->drupalPost(RULES_FORMS_ADMIN_PATH, $edit, t('Save settings'));
$this
->assertText(t('The settings have been saved.'));
$this
->drupalGet(RULES_FORMS_ADMIN_PATH);
$this
->assertFieldChecked('edit-enable-form-activation-message');
$this
->drupalGet('node/add/article');
$this
->assertLink('article_node_form', 0, t('Article node form activation link is displayed.'));
// Activate the form.
$this
->clickLink('article_node_form');
$this
->assertText(t('Custom form label'));
$edit = array();
$edit['form_id_label'] = 'Article node form';
$this
->drupalPost('admin/config/workflow/rules/forms/article_node_form/activate/node%25252Fadd%25252Farticle', $edit, t('Activate'));
$this
->assertText('article_node_form ' . t('has been activated.'));
// Ensure that the newly activated form is shown in administration.
$this
->drupalGet(RULES_FORMS_ADMIN_PATH);
$this
->assertText(t('Events enabled forms'), t('Forms have been activated.'));
$this
->assertFieldByName('form_events[article_node_form]');
$this
->assertFieldByName('reset_form');
$this
->drupalGet('node/add/article');
$form_events = variable_get('rules_forms_event_info', array());
$this
->assertTrue(!empty($form_events['article_node_form']), t('Article node for was activated.'));
$this
->assertTrue(!empty($form_events['article_node_form']['path']), t('Article node form path was stored.'));
$this
->assertTrue(!empty($form_events['article_node_form']['elements']), t('Article node form elements were stored.'));
// Deactivate events for the form.
$edit = array();
$edit['form_events[article_node_form]'] = 1;
$this
->drupalPost(RULES_FORMS_ADMIN_PATH, $edit, t('Deactivate events'));
$this
->drupalGet(RULES_FORMS_ADMIN_PATH);
$this
->assertNoFieldByName('form_events[article_node_form]');
$this
->assertNoFieldByName('reset_form');
// Deactivate form event messages.
$edit = array();
$edit['enable_form_activation_message'] = FALSE;
$this
->drupalPost(RULES_FORMS_ADMIN_PATH, $edit, t('Save settings'));
$this
->drupalGet(RULES_FORMS_ADMIN_PATH);
$this
->assertNoFieldChecked('edit-enable-form-activation-message');
}