diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigExportForm.php b/core/modules/config/lib/Drupal/config/Form/ConfigExportForm.php index 4cf5bcd..28d25bd 100644 --- a/core/modules/config/lib/Drupal/config/Form/ConfigExportForm.php +++ b/core/modules/config/lib/Drupal/config/Form/ConfigExportForm.php @@ -1,17 +1,30 @@ '

' . t('Use the export button below to download your site configuration.') . '

', ); @@ -19,13 +32,21 @@ public function buildForm(array $form, array &$form_state) { '#type' => 'submit', '#value' => t('Export'), ); + return $form; } + /** + * {@inheritdoc} + */ public function validateForm(array &$form, array &$form_state) { } + /** + * {@inheritdoc} + */ public function submitForm(array &$form, array &$form_state) { + $form_state['redirect'] = 'admin/config/development/export-download'; } -} +} diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigExportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigExportUITest.php new file mode 100644 index 0000000..d3df96d --- /dev/null +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigExportUITest.php @@ -0,0 +1,64 @@ + 'Export UI', + 'description' => 'Tests the user interface for exporting configuration.', + 'group' => 'Configuration', + ); + } + + function setUp() { + parent::setUp(); + + $this->web_user = $this->drupalCreateUser(array('export configuration')); + $this->drupalLogin($this->web_user); + } + + /** + * Tests export of configuration. + */ + function testExport() { + // Verify the export page with export submit button is available. + $this->drupalGet('admin/config/development/export'); + $this->assertFieldById('edit-submit', t('Export')); + + // Submit the export form and verify response. + $this->drupalPost('admin/config/development/export', array(), t('Export')); + $this->assertResponse(200, 'User can access the download callback.'); + + // Get the archived binary file provided to user for download. + $archive_data = $this->drupalGetContent(); + + // Temporarily save the archive file. + $uri = file_unmanaged_save_data($archive_data, 'temporary://config.tar.gz'); + + // Extract the archive and verify it's not empty. + $file_path = file_directory_temp() . '/' . file_uri_target($uri); + $archiver = new Tar($file_path); + $archive_content = $archiver->listContents(); + $this->assert(!empty($archive_content), 'Content of the downloaded archive file is not empty.'); + } +} \ No newline at end of file