public function ConfirmFormTest::testConfirmForm in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php \Drupal\Tests\system\Functional\Form\ConfirmFormTest::testConfirmForm()
- 10 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 28
Class
- ConfirmFormTest
- Tests confirmation forms.
Namespace
Drupal\Tests\system\Functional\FormCode
public function testConfirmForm() {
// Test the building of the form.
$this
->drupalGet('form-test/confirm-form');
$site_name = $this
->config('system.site')
->get('name');
$this
->assertTitle("ConfirmFormTestForm::getQuestion(). | {$site_name}");
$this
->assertText(t('ConfirmFormTestForm::getDescription().'), 'The description was used.');
$this
->assertFieldByXPath('//input[@id="edit-submit"]', t('ConfirmFormTestForm::getConfirmText().'), 'The confirm text was used.');
// Test cancelling the form.
$this
->clickLink(t('ConfirmFormTestForm::getCancelText().'));
$this
->assertUrl('form-test/autocomplete', [], "The form's cancel link was followed.");
// Test submitting the form.
$this
->drupalPostForm('form-test/confirm-form', NULL, t('ConfirmFormTestForm::getConfirmText().'));
$this
->assertText('The ConfirmFormTestForm::submitForm() method was used for this form.');
$this
->assertUrl('', [], "The form's redirect was followed.");
// Test submitting the form with a destination.
$this
->drupalPostForm('form-test/confirm-form', NULL, t('ConfirmFormTestForm::getConfirmText().'), [
'query' => [
'destination' => 'admin/config',
],
]);
$this
->assertUrl('admin/config', [], "The form's redirect was not followed, the destination query string was followed.");
// Test cancelling the form with a complex destination.
$this
->drupalGet('form-test/confirm-form-array-path');
$this
->clickLink(t('ConfirmFormArrayPathTestForm::getCancelText().'));
$this
->assertUrl('form-test/confirm-form', [
'query' => [
'destination' => 'admin/config',
],
], "The form's complex cancel link was followed.");
}