function FapiExampleTest::doTestBuildDemo

Same name in other branches
  1. 3.x modules/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 121

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->drupalGet($build_demo_url);
    $this->submitForm($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->drupalGet($build_demo_url);
    $this->submitForm($edit, 'Submit Rebuild');
    $assert->pageTextContains('4. rebuildFormSubmit');
}