public function FormBuilderFormBaseTest::testSetElementArray in Form Builder 7
@covers FormBuilderFormBase::setElementArray @covers FormBuilderFormBase::getElement @covers FormBuilderFormBase::getElementArray @covers FormBuilderFormBase::getFormArray @covers FormBuilderFormBase::addDefaults
File
- tests/
FormBuilderFormBaseTest.php, line 46
Class
Code
public function testSetElementArray() {
$form = $this
->emptyForm();
$a['#form_builder']['element_id'] = 'A';
$a['#key'] = 'a';
$a['#type'] = 'textfield';
$this
->assertEqual('A', $form
->setElementArray($a));
$rform = $form
->getFormArray();
$this
->assertArrayHasKey('a', $rform);
$a['#key'] = 'x';
$this
->assertEqual('A', $form
->setElementArray($a));
$rform = $form
->getFormArray();
$this
->assertArrayNotHasKey('a', $rform);
$this
->assertArrayHasKey('x', $rform);
$b['#key'] = 'b';
$b['#type'] = 'textfield';
$b['#form_builder'] = array(
'element_id' => 'B',
'parent_id' => 'A',
);
$this
->assertEqual('B', $form
->setElementArray($b));
$this
->assertArrayNotHasKey('b', $form
->getFormArray());
$this
->assertArrayHasKey('b', $form
->getElementArray('A'));
$b['#form_builder']['parent_id'] = 'NON EXISTING';
$this
->assertFalse($form
->setElementArray($b));
$this
->assertArrayHasKey('b', $form
->getElementArray('A'));
$b['#form_builder']['parent_id'] = FORM_BUILDER_ROOT;
$this
->assertEqual('B', $form
->setElementArray($b));
$this
->assertArrayHasKey('b', $form
->getFormArray());
$this
->assertArrayNotHasKey('b', $form
->getElementArray('A'));
}