You are here

function MultiFormExampleTest::testMultiFormBuilder in Multiple forms 8

Tests functionality of the multiform module.

File

multiform_example/src/Tests/MultiFormExampleTest.php, line 33
Definition of Drupal\multiform\Tests\MultiFormExampleTest.

Class

MultiFormExampleTest
Creates a multiform test interface.

Namespace

Drupal\multiform_example\Tests

Code

function testMultiFormBuilder() {
  $multiform_path = '/multiform_example/multiform';
  $this
    ->drupalGet($multiform_path);
  $this
    ->assertResponse(200);

  // Ensure that we have the correct form element on the multiform.
  $this
    ->assertTrue($this
    ->xpath('//input[@name=:name]', array(
    ':name' => 'multiform[example_form1_0][text_field_1]',
  )));
  $this
    ->assertTrue($this
    ->xpath('//input[@name=:name]', array(
    ':name' => 'multiform[example_form2_1][text_field_2]',
  )));
  $this
    ->drupalPostForm($multiform_path, array(), t('Save'));
  $this
    ->assertText('Multiform Example 1 test Save.');
  $this
    ->assertText('Multiform Example 2 test Save.');
  $this
    ->drupalGet($multiform_path);
  $this
    ->assertResponse(200);
  $this
    ->drupalPostForm($multiform_path, array(), t('Delete'));
  $this
    ->assertText('Multiform Example 1 test Delete.');
  $this
    ->assertText('Multiform Example 2 test Delete.');
}