summaryrefslogtreecommitdiff
path: root/sites/all/modules/ds/tests/ds.forms.test
blob: 85069ed46cd7d6218a24d38d16e07a5c1b665bef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php

/**
 * @file
 * Form layout tests.
 */

class dsFormTests extends dsBaseTest {

  /**
   * Implements getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => t('Forms'),
      'description' => t('Tests for managing layouts on forms.'),
      'group' => t('Display Suite'),
    );
  }

  /**
   * Forms tests.
   */
  function testDSForms() {

    // Create a node.
    $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => FALSE));

    // Configure teaser layout.
    $form = array(
      'additional_settings[layout]' => 'ds_2col_stacked',
    );
    $form_assert = array(
      'regions' => array(
        'header' => '<td colspan="8">' . t('Header') . '</td>',
        'left' => '<td colspan="8">' . t('Left') . '</td>',
        'right' => '<td colspan="8">' . t('Right') . '</td>',
        'footer' => '<td colspan="8">' . t('Footer') . '</td>',
      ),
    );
    $this->dsSelectLayout($form, $form_assert, 'admin/structure/types/manage/article/fields');

    $fields = array(
      'fields[title][region]' => 'header',
      'fields[body][region]' => 'left',
      'fields[field_image][region]' => 'right',
      'fields[field_tags][region]' => 'right',
    );
    $this->dsConfigureUI($fields, 'admin/structure/types/manage/article/fields');

    // Inspect the node.
    $this->drupalGet('node/' . $node->nid . '/edit');
    $this->assertRaw('ds_2col_stacked', 'ds-form class added');
    $this->assertRaw('group-header', 'Template found (region header)');
    $this->assertRaw('group-left', 'Template found (region left)');
    $this->assertRaw('group-right', 'Template found (region right)');
    $this->assertRaw('group-footer', 'Template found (region footer)');
    $this->assertRaw('edit-title', 'Title field found');
    $this->assertRaw('edit-submit', 'Submit field found');
    $this->assertRaw('edit-field-tags-und', 'Tags field found');
    $this->assertRaw('edit-log', 'Revision log found');
  }
}