function ConfirmFormTest::testConfirmForm
Same name in other branches
- 7.x modules/system/system.test \ConfirmFormTest::testConfirmForm()
- 9 core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php \Drupal\Tests\system\Functional\Form\ConfirmFormTest::testConfirmForm()
- 8.9.x core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php \Drupal\Tests\system\Functional\Form\ConfirmFormTest::testConfirmForm()
- 11.x core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php \Drupal\Tests\system\Functional\Form\ConfirmFormTest::testConfirmForm()
File
-
core/
modules/ system/ tests/ src/ Functional/ Form/ ConfirmFormTest.php, line 27
Class
- ConfirmFormTest
- Tests confirmation forms.
Namespace
Drupal\Tests\system\Functional\FormCode
public function testConfirmForm() : void {
// Test the building of the form.
$this->drupalGet('form-test/confirm-form');
$site_name = $this->config('system.site')
->get('name');
$this->assertSession()
->titleEquals("ConfirmFormTestForm::getQuestion(). | {$site_name}");
$this->assertSession()
->pageTextContains('ConfirmFormTestForm::getDescription().');
$this->assertSession()
->buttonExists('ConfirmFormTestForm::getConfirmText().');
// Test cancelling the form.
$this->clickLink('ConfirmFormTestForm::getCancelText().');
$this->assertSession()
->addressEquals('form-test/autocomplete');
// Test submitting the form.
$this->drupalGet('form-test/confirm-form');
$this->submitForm([], 'ConfirmFormTestForm::getConfirmText().');
$this->assertSession()
->pageTextContains('The ConfirmFormTestForm::submitForm() method was used for this form.');
$this->assertSession()
->addressEquals('');
// Test submitting the form with a destination.
$this->drupalGet('form-test/confirm-form', [
'query' => [
'destination' => 'admin/config',
],
]);
$this->submitForm([], 'ConfirmFormTestForm::getConfirmText().');
$this->assertSession()
->addressEquals('admin/config');
// Test cancelling the form with a complex destination.
$this->drupalGet('form-test/confirm-form-array-path');
$this->clickLink('ConfirmFormArrayPathTestForm::getCancelText().');
// Verify that the form's complex cancel link was followed.
$this->assertSession()
->addressEquals('form-test/confirm-form?destination=admin/config');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.