function BooleanFormatterSettingsTest::testBooleanFormatterSettings
Same name in this branch
- 8.9.x core/modules/field/tests/src/Functional/Boolean/BooleanFormatterSettingsTest.php \Drupal\Tests\field\Functional\Boolean\BooleanFormatterSettingsTest::testBooleanFormatterSettings()
Same name in other branches
- 9 core/modules/field/tests/src/FunctionalJavascript/Boolean/BooleanFormatterSettingsTest.php \Drupal\Tests\field\FunctionalJavascript\Boolean\BooleanFormatterSettingsTest::testBooleanFormatterSettings()
- 9 core/modules/field/tests/src/Functional/Boolean/BooleanFormatterSettingsTest.php \Drupal\Tests\field\Functional\Boolean\BooleanFormatterSettingsTest::testBooleanFormatterSettings()
- 10 core/modules/field/tests/src/FunctionalJavascript/Boolean/BooleanFormatterSettingsTest.php \Drupal\Tests\field\FunctionalJavascript\Boolean\BooleanFormatterSettingsTest::testBooleanFormatterSettings()
- 10 core/modules/field/tests/src/Functional/Boolean/BooleanFormatterSettingsTest.php \Drupal\Tests\field\Functional\Boolean\BooleanFormatterSettingsTest::testBooleanFormatterSettings()
- 11.x core/modules/field/tests/src/FunctionalJavascript/Boolean/BooleanFormatterSettingsTest.php \Drupal\Tests\field\FunctionalJavascript\Boolean\BooleanFormatterSettingsTest::testBooleanFormatterSettings()
- 11.x core/modules/field/tests/src/Functional/Boolean/BooleanFormatterSettingsTest.php \Drupal\Tests\field\Functional\Boolean\BooleanFormatterSettingsTest::testBooleanFormatterSettings()
Tests the formatter settings page for the Boolean formatter.
File
-
core/
modules/ field/ tests/ src/ FunctionalJavascript/ Boolean/ BooleanFormatterSettingsTest.php, line 90
Class
- BooleanFormatterSettingsTest
- Tests the Boolean field formatter settings.
Namespace
Drupal\Tests\field\FunctionalJavascript\BooleanCode
public function testBooleanFormatterSettings() {
// List the options we expect to see on the settings form. Omit the one
// with the Unicode check/x characters, which does not appear to work
// well in WebTestBase.
$options = [
'Yes / No',
'True / False',
'On / Off',
'Enabled / Disabled',
'1 / 0',
'Custom',
];
// For several different values of the field settings, test that the
// options, including default, are shown correctly.
$settings = [
[
'Yes',
'No',
],
[
'On',
'Off',
],
[
'TRUE',
'FALSE',
],
];
$assert_session = $this->assertSession();
foreach ($settings as $values) {
// Set up the field settings.
$this->drupalGet('admin/structure/types/manage/' . $this->bundle . '/fields/node.' . $this->bundle . '.' . $this->fieldName);
$this->drupalPostForm(NULL, [
'settings[on_label]' => $values[0],
'settings[off_label]' => $values[1],
], t('Save settings'));
// Open the Manage Display page and trigger the field settings form.
$this->drupalGet('admin/structure/types/manage/' . $this->bundle . '/display');
$this->getSession()
->getPage()
->pressButton($this->fieldName . '_settings_edit');
$assert_session->waitForElement('css', '.ajax-new-content');
// Test that the settings options are present in the correct format.
foreach ($options as $string) {
$assert_session->pageTextContains($string);
}
$assert_session->pageTextContains(t('Field settings (@on_label / @off_label)', [
'@on_label' => $values[0],
'@off_label' => $values[1],
]));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.