You are here

public function FapiExampleTest::doTestBuildDemo 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::doTestBuildDemo()

Test the build demo form.

1 call to FapiExampleTest::doTestBuildDemo()
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 120

Class

FapiExampleTest
Ensure that the form_api_example forms work properly.

Namespace

Drupal\Tests\form_api_example\Functional

Code

public function doTestBuildDemo() {
  $assert = $this
    ->assertSession();
  $build_demo_url = Url::fromRoute('form_api_example.build_demo');
  $edit = [
    'change' => '1',
  ];
  $this
    ->drupalPostForm($build_demo_url, $edit, 'Submit');
  $assert
    ->pageTextContains('1. __construct');
  $assert
    ->pageTextContains('2. getFormId');
  $assert
    ->pageTextContains('3. validateForm');
  $assert
    ->pageTextContains('4. submitForm');

  // Ensure the 'submit rebuild' action performs the rebuild.
  $this
    ->drupalPostForm($build_demo_url, $edit, 'Submit Rebuild');
  $assert
    ->pageTextContains('4. rebuildFormSubmit');
}