public function ThemeSettingsFormTest::testFormSettingsSubmissionHandler in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/FunctionalJavascript/ThemeSettingsFormTest.php \Drupal\Tests\system\FunctionalJavascript\ThemeSettingsFormTest::testFormSettingsSubmissionHandler()
- 10 core/modules/system/tests/src/FunctionalJavascript/ThemeSettingsFormTest.php \Drupal\Tests\system\FunctionalJavascript\ThemeSettingsFormTest::testFormSettingsSubmissionHandler()
Tests that submission handler works correctly.
@dataProvider providerTestFormSettingsSubmissionHandler
File
- core/
modules/ system/ tests/ src/ FunctionalJavascript/ ThemeSettingsFormTest.php, line 43
Class
- ThemeSettingsFormTest
- Tests that theme form settings works correctly.
Namespace
Drupal\Tests\system\FunctionalJavascriptCode
public function testFormSettingsSubmissionHandler($theme) {
\Drupal::service('theme_installer')
->install([
$theme,
]);
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$this
->drupalGet("admin/appearance/settings/{$theme}");
// Add a new managed file.
$file = current($this
->getTestFiles('image'));
$image_file_path = \Drupal::service('file_system')
->realpath($file->uri);
$page
->attachFileToField('files[custom_logo]', $image_file_path);
$assert_session
->waitForButton('custom_logo_remove_button');
// Assert the new file is uploaded as temporary. This file should not be
// saved as permanent if settings are not submitted.
$image_field = $this
->assertSession()
->hiddenFieldExists('custom_logo[fids]');
$file = File::load($image_field
->getValue());
$this
->assertFalse($file
->isPermanent());
$page
->pressButton('Save configuration');
\Drupal::entityTypeManager()
->getStorage('file')
->resetCache();
// Assert the uploaded file is saved as permanent.
$image_field = $this
->assertSession()
->hiddenFieldExists('custom_logo[fids]');
$file = File::load($image_field
->getValue());
$this
->assertTrue($file
->isPermanent());
}