You are here

function FormTest::testPreview in Form Builder 7.2

Test the form builder preview.

File

modules/webform/tests/FormTest.php, line 105

Class

FormTest
Integration test for the webform integration.

Namespace

Drupal\form_builder_webform

Code

function testPreview() {
  $form = new Form('webform', 0, 'the-sid', array(), array());
  $form
    ->addComponents($this
    ->components());
  $preview = $this
    ->deleteComponentInfo($form
    ->preview());
  unset($preview['grid']);
  unset($preview['select']);
  $this
    ->assertEqual(array(
    '#tree' => TRUE,
    'fieldset1' => array(
      '#type' => 'fieldset',
      '#title' => 'fieldset1',
      '#title_display' => NULL,
      '#weight' => 0,
      '#description' => '',
      '#collapsible' => 0,
      '#collapsed' => 0,
      '#attributes' => array(
        'class' => array(
          0 => 'webform-component-fieldset',
        ),
      ),
      '#pre_render' => array(
        0 => 'form_pre_render_fieldset',
        1 => 'ctools_dependent_pre_render',
        2 => 'form_builder_pre_render',
      ),
      '#translatable' => array(
        0 => 'title',
        1 => 'description',
      ),
      'hour' => array(
        '#type' => 'webform_time',
        '#title' => 'hour',
        '#title_display' => 'before',
        '#required' => 0,
        '#weight' => 2,
        '#description' => '',
        '#element_validate' => array(
          0 => 'webform_validate_time',
        ),
        '#hourformat' => '12-hour',
        '#minuteincrements' => '1',
        '#default_value' => '',
        '#timezone' => 'user',
        '#process' => array(
          0 => 'webform_expand_time',
        ),
        '#theme' => 'webform_time',
        '#theme_wrappers' => array(
          0 => 'webform_element',
        ),
        '#translatable' => array(
          0 => 'title',
          1 => 'description',
        ),
        '#form_builder' => array(
          'element_id' => 'cid_3',
          'element_type' => 'time',
          'form_type' => 'webform',
          'form_id' => 0,
          'parent_id' => 'cid_1',
          'configurable' => TRUE,
          'removable' => TRUE,
        ),
        '#pre_render' => array(
          0 => 'form_builder_pre_render',
        ),
        '#key' => 'hour',
        '#start_time' => '',
        '#end_time' => '',
      ),
      '#form_builder' => array(
        'element_id' => 'cid_1',
        'element_type' => 'fieldset',
        'form_type' => 'webform',
        'form_id' => 0,
        'parent_id' => 0,
        'configurable' => TRUE,
        'removable' => TRUE,
      ),
      '#key' => 'fieldset1',
    ),
    'textfield1' => array(
      '#type' => 'textfield',
      '#title' => 'textfield1',
      '#title_display' => 'before',
      '#default_value' => 'textfield1',
      '#required' => '0',
      '#weight' => '1',
      '#field_prefix' => 'testprefix',
      '#field_suffix' => 'testpostfix',
      '#description' => '',
      '#attributes' => array(),
      '#theme_wrappers' => array(
        0 => 'webform_element',
      ),
      '#translatable' => array(
        0 => 'title',
        1 => 'description',
        2 => 'field_prefix',
        3 => 'field_suffix',
      ),
      '#disabled' => TRUE,
      '#size' => '4',
      '#form_builder' => array(
        'element_id' => 'cid_2',
        'element_type' => 'textfield',
        'form_type' => 'webform',
        'form_id' => 0,
        'parent_id' => 0,
        'configurable' => TRUE,
        'removable' => TRUE,
      ),
      '#pre_render' => array(
        0 => 'ctools_dependent_pre_render',
        1 => 'form_builder_pre_render',
      ),
      '#key' => 'textfield1',
    ),
    '#form_builder' => array(
      'form_type' => 'webform',
      'form_id' => 0,
      'sid' => 'the-sid',
    ),
  ), $preview);
}