You are here

public function RulesFormsAPITestCase::testGetElements in Rules Forms Support 7

Same name and namespace in other branches
  1. 7.2 rules_forms.test \RulesFormsAPITestCase::testGetElements()

Tests _rules_forms_get_elements().

File

./rules_forms.test, line 695
Stores tests related to Rules Form.

Class

RulesFormsAPITestCase
Tests Rules Forms actions.

Code

public function testGetElements() {
  variable_set('rules_forms_form_info', self::$formInfo);
  $form = self::$form;
  $elements =& _rules_forms_get_elements($form);
  foreach ($elements as &$element) {
    $element['test'] = 'test';
  }

  // Ensure that references are preserved by _rules_forms_get_elements().
  $message = 'Ensure the reference to $form is preserved.';
  $this
    ->assertTrue(isset($form['title']['test']) && $form['title']['test'] == 'test', $message);
  $this
    ->assertTrue(isset($form['body'][LANGUAGE_NONE][0]['value']['test']) && $form['body'][LANGUAGE_NONE][0]['value']['test'] == 'test', $message);
  $this
    ->assertTrue(isset($form['fieldset']['select']['test']) && $form['fieldset']['select']['test'] == 'test', $message);
  $this
    ->assertTrue(isset($form['fieldset']['checkboxes']['test']) && $form['fieldset']['checkboxes']['test'] == 'test', $message);
  $form = array(
    'form_id' => array(
      '#value' => 'test',
    ),
  );
  $array =& _rules_forms_get_elements($form);
  $this
    ->assertTrue(empty($array));
}