$this->
assertSession()->
buttonExists('Export'
);
// Submit the export form and verify response. This will create a file in
// temporary directory with the default name config.tar.gz.
$this->
drupalGet('admin/config/development/configuration/full/export'
);
$this->
submitForm([], 'Export'
);
$this->
assertSession()->
statusCodeEquals(200
);
// Test if header contains file name with hostname and timestamp.
$request = \Drupal::
request();
$hostname =
str_replace('.', '-',
$request->
getHttpHost());
$this->
assertSession()->
responseHeaderMatches('content-disposition', '/attachment; filename="config-' .
preg_quote($hostname) . '-\d{4}-\d{2}-\d{2}-\d{2}-\d{2}\.tar\.gz"/'
);
// Extract the archive and verify it's not empty.
$file_system = \Drupal::
service('file_system'
);
assert($file_system instanceof FileSystemInterface
);
$temp_directory =
$file_system->
getTempDirectory();
$file_path =
$temp_directory . '/config.tar.gz';
$archiver =
new Tar($file_path);
$archive_contents =
$archiver->
listContents();
$this->
assertNotEmpty($archive_contents, 'Downloaded archive file is not empty.'
);
// Prepare the list of config files from active storage, see