You are here

function WebformMatrixTestCase::setUp in Webform Matrix Component 7.4

Implements setUp().

Overrides DrupalWebTestCase::setUp

File

tests/webform_matrix_component.test, line 26
Tests for the Weform Matrix Component module.

Class

WebformMatrixTestCase
Tests for webform matrix component.

Code

function setUp() {
  parent::setUp(array(
    'webform_matrix_component',
  ));

  // Create webform node
  $settings = array(
    'title' => 'Matrix node',
    'type' => 'webform',
  );
  $node = $this
    ->drupalCreateNode($settings);

  // Add a matrix component.
  $matrix = array(
    'nid' => $node->nid,
    'cid' => 1,
    'pid' => 0,
    'form_key' => 'matrix',
    'name' => 'Matrix',
    'type' => 'matrix',
    'value' => '',
    'extra' => array(
      'matrix_row' => 3,
      'add_row_feature' => 1,
      'remove_row_feature' => 0,
      'add_row_button_text' => 'Add a row',
      'remove_row_button_text' => 'Remove a row',
      'matrix_col' => 3,
      'element' => array(
        'element-1' => array(
          'type' => 'select',
          'title' => 'Select title',
          'mandatory' => 1,
          'option' => "key1|value1\nkey2|value2",
          'select_type' => 'list',
          'multiple' => 0,
          'default_value' => 'key2',
        ),
        'element-2' => array(
          'type' => 'textfield',
          'title' => 'Textfield title',
          'mandatory' => 1,
          'size' => 50,
          'default_value' => '',
          'maxlength ' => 50,
        ),
        'element-3' => array(
          'type' => 'date',
          'title' => 'Date title',
          'mandatory' => 0,
          'datepicker' => 1,
          'startdate' => '-2 years',
          'enddate' => '+2 years',
          'default_date' => '',
        ),
      ),
      'private' => FALSE,
      'title_display' => 0,
      'description' => '',
    ),
    'required' => '0',
    'weight' => 10,
  );
  $node->webform['components'][1] = $matrix;
  node_save($node);
}