function FilterFormTest::doFilterFormTestAsNonAdmin
Same name in other branches
- 8.9.x core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::doFilterFormTestAsNonAdmin()
- 10 core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::doFilterFormTestAsNonAdmin()
- 11.x core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::doFilterFormTestAsNonAdmin()
Tests the behavior of the 'text_format' element as a normal user.
1 call to FilterFormTest::doFilterFormTestAsNonAdmin()
- FilterFormTest::testFilterForm in core/
modules/ filter/ tests/ src/ Functional/ FilterFormTest.php - Tests various different configurations of the 'text_format' element.
File
-
core/
modules/ filter/ tests/ src/ Functional/ FilterFormTest.php, line 131
Class
- FilterFormTest
- Tests form elements with associated text formats.
Namespace
Drupal\Tests\filter\FunctionalCode
protected function doFilterFormTestAsNonAdmin() {
$this->drupalLogin($this->webUser);
$this->drupalGet('filter-test/text-format');
// Test a text format element with all formats. Only formats the user has
// access to are shown.
$formats = [
'filtered_html',
'filter_test',
];
$this->assertEnabledTextarea('edit-all-formats-no-default-value');
// If no default is given, the format with the lowest weight becomes the
// default. This happens to be 'filtered_html'.
$this->assertOptions('edit-all-formats-no-default-format--2', $formats, 'filtered_html');
$this->assertEnabledTextarea('edit-all-formats-default-value');
// \Drupal\filter_test\Form\FilterTestFormatForm::buildForm() uses
// 'filter_test' as the default value in this case.
$this->assertOptions('edit-all-formats-default-format--2', $formats, 'filter_test');
// If a missing format is given as default, non-admin users are presented
// with a disabled textarea.
$this->assertDisabledTextarea('edit-all-formats-default-missing-value');
// Test a text format element with a predefined list of formats.
$this->assertEnabledTextarea('edit-restricted-formats-no-default-value');
// The user only has access to the 'filter_test' format, so when no default
// is given that is preselected and the text format select is hidden.
$this->assertNoSelect('edit-restricted-formats-no-default-format--2');
// When the format that the user does not have access to is preselected, the
// textarea should be disabled.
$this->assertDisabledTextarea('edit-restricted-formats-default-value');
$this->assertDisabledTextarea('edit-restricted-formats-default-missing-value');
$this->assertDisabledTextarea('edit-restricted-formats-default-disallowed-value');
// Test a text format element with a fixed format.
// When there is only a single option there is no point in choosing.
$this->assertEnabledTextarea('edit-single-format-no-default-value');
$this->assertNoSelect('edit-single-format-no-default-format--2');
$this->assertEnabledTextarea('edit-single-format-default-value');
$this->assertNoSelect('edit-single-format-default-format--2');
// If the select has a missing or disallowed format make sure the textarea
// is disabled.
$this->assertDisabledTextarea('edit-single-format-default-missing-value');
$this->assertDisabledTextarea('edit-single-format-default-disallowed-value');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.