function ConfigExampleTest::doTestConfigSimpleForm
Test the config simple form.
1 call to ConfigExampleTest::doTestConfigSimpleForm()
- ConfigExampleTest::testFunctional in modules/
config_simple_example/ tests/ src/ Functional/ ConfigExampleTest.php - Aggregate all the tests.
File
-
modules/
config_simple_example/ tests/ src/ Functional/ ConfigExampleTest.php, line 106
Class
- ConfigExampleTest
- Ensure that the form_api_example forms work properly.
Namespace
Drupal\Tests\form_api_example\FunctionalCode
public function doTestConfigSimpleForm() {
$config_page_en = Url::fromRoute('config_simple_example.settings');
$config_page_translate = $this->drupalGet('admin/config/form-api-example/config-simple-form/translate');
$config_page_es = $this->drupalGet('admin/config/form-api-example/config-simple-form/translate/es/edit');
// English.
$assert = $this->assertSession();
$this->drupalGet($config_page_en);
$assert->fieldEnabled('edit-message');
$assert->buttonExists('edit-submit');
// Ensure the 'Save configuration' action performs the save.
$this->drupalGet($config_page_en);
$edit = [
'message' => 'Message in EN',
];
$this->submitForm($edit, 'Save configuration');
$assert->pageTextContains('Message in EN');
// Form translation page and click the button to Add Spanish translation.
$this->drupalGet($config_page_translate);
$this->clickLink('Add');
$assert->fieldExists('translation[config_names][config_simple_example.settings][message]');
// Ensure the 'Save translation' action performs the save.
$edit = [
'message' => 'Message in ES',
];
$this->submitForm($edit, 'Save translation');
$this->drupalGet($config_page_es);
$assert->pageTextContains('Message in ES');
// Go back to original English version and make sure it's still there.
$this->drupalGet($config_page_en);
$assert->pageTextContains('Message in EN');
}