public function SiteSettingsUiTest::testSiteSettingsCreateNewTypeAndSetting in Site Settings and Labels 8
Test site settings create new type and add a setting to that.
File
- src/
Tests/ SiteSettingsUiTest.php, line 137
Class
- SiteSettingsUiTest
- Tests the loading of Site Settings.
Namespace
Drupal\site_settings\TestsCode
public function testSiteSettingsCreateNewTypeAndSetting() {
// Open the site settings list page.
$this
->drupalGet('admin/structure/site_setting_entity_type/add');
// Create the new site setting.
$params = [
'label' => 'testSiteSettingsCreateNewTypeAndSetting',
'id' => 'testsitesettingscreatenew',
'existing_fieldset' => 'Other',
];
$this
->drupalPostForm(NULL, $params, $this
->t('Save'));
// Ensure we saved correctly.
$this
->assertText('Created the testSiteSettingsCreateNewTypeAndSetting Site Setting type.');
// Add field.
$this
->drupalGet('admin/structure/site_setting_entity_type/testsitesettingscreatenew/edit/fields/add-field');
$params = [
'existing_storage_name' => 'field_testing',
'existing_storage_label' => 'testSiteSettingsCreateNewTypeAndSettingLabel',
];
$this
->drupalPostForm(NULL, $params, $this
->t('Save and continue'));
// Save field settings.
$params = [];
$this
->drupalPostForm(NULL, $params, $this
->t('Save settings'));
// Ensure we saved correctly.
$this
->assertText('Saved testSiteSettingsCreateNewTypeAndSettingLabel configuration.');
$this
->assertText('field_testing');
// Open the site settings list page.
$this
->drupalGet('admin/content/site-settings');
// Click add another link.
$this
->clickLink('Create setting');
$this
->assertText('testSiteSettingsCreateNewTypeAndSettingLabel');
$params = [
'field_testing[0][value]' => 'testSiteSettingsCreateNewTypeAndSettingValue',
];
$this
->drupalPostForm(NULL, $params, $this
->t('Save'));
// Ensure we saved correctly.
$this
->assertText('Created the testSiteSettingsCreateNewTypeAndSetting Site Setting.');
$this
->assertText('testSiteSettingsCreateNewTypeAndSettingValue');
}