You are here

class AdminTest in Form Builder 7.2

Hierarchy

  • class \Drupal\form_builder\AdminTest extends \Drupal\form_builder\DrupalUnitTestCase

Expanded class hierarchy of AdminTest

File

tests/AdminTest.php, line 5

Namespace

Drupal\form_builder
View source
class AdminTest extends \DrupalUnitTestCase {

  /**
   * Prepare test objects and load includes.
   */
  public function setUp() {
    parent::setUp();
    $this->form = new FormBase('webform', 'test', NULL, array(), array(), NULL);
    $this->form
      ->save();
    module_load_include('inc', 'form_builder', 'includes/form_builder.admin');
  }

  /**
   * Purge data stored to the form cache during the tests.
   */
  public function tearDown() {
    parent::tearDown();
    FormBase::purge(0);
    Loader::instance()
      ->fromCache(NULL, NULL, NULL, TRUE);
  }

  /**
   * Test: Elements can change the tabs displayed on their configure form.
   */
  public function testChangingGroupsInElement() {
    $loader = Loader::instance();
    $fields = $loader
      ->getElementTypeInfo('webform', 0);
    $a = $fields['textfield']['default'];
    $a['#form_builder']['element_id'] = 'A';
    $a['#key'] = 'a';
    $a['#type'] = 'textfield';
    $a['#weight'] = 0;
    $element_id = $this->form
      ->setElementArray($a);
    $this->form
      ->save();
    $form_state = [];
    $form = form_builder_field_configure([], $form_state, 'webform', 'test', $element_id);
    $form['#property_groups']['test'] = [
      'title' => 'Test',
      'weight' => 0,
    ];
    $form['size']['#form_builder']['property_group'] = 'test';
    $form = form_builder_field_configure_pre_render($form);
    $this
      ->assertArrayHasKey('test_property_group', $form);
    $this
      ->assertEqual('Test', $form['test_property_group']['#title']);
    $this
      ->assertArrayHasKey('size', $form['test_property_group']);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AdminTest::setUp public function Prepare test objects and load includes.
AdminTest::tearDown public function Purge data stored to the form cache during the tests.
AdminTest::testChangingGroupsInElement public function Test: Elements can change the tabs displayed on their configure form.