You are here

public function FapiExampleTest::doTestContainerDemoForm in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 form_api_example/tests/src/Functional/FapiExampleTest.php \Drupal\Tests\form_api_example\Functional\FapiExampleTest::doTestContainerDemoForm()

Test the container demo form.

1 call to FapiExampleTest::doTestContainerDemoForm()
FapiExampleTest::testFunctional in modules/form_api_example/tests/src/Functional/FapiExampleTest.php
Aggregate all the tests.

File

modules/form_api_example/tests/src/Functional/FapiExampleTest.php, line 142

Class

FapiExampleTest
Ensure that the form_api_example forms work properly.

Namespace

Drupal\Tests\form_api_example\Functional

Code

public function doTestContainerDemoForm() {
  $assert = $this
    ->assertSession();

  // Post the form.
  $edit = [
    'name' => 'Dave',
    'pen_name' => 'DMan',
    'title' => 'My Book',
    'publisher' => 'me',
    'diet' => 'vegan',
  ];
  $this
    ->drupalPostForm(Url::fromRoute('form_api_example.container_demo'), $edit, 'Submit');
  $assert
    ->pageTextContains('Value for name: Dave');
  $assert
    ->pageTextContains('Value for pen_name: DMan');
  $assert
    ->pageTextContains('Value for title: My Book');
  $assert
    ->pageTextContains('Value for publisher: me');
  $assert
    ->pageTextContains('Value for diet: vegan');
}