1.20.x installer.test | public InstallerTestUploadCase::testUploadModule() |
Tests upload and extraction of a module.
File
- modules/
installer/ tests/ installer.test, line 215
Class
Code
public function testUploadModule() {
// Images are not valid archives, so get one and try to install it. We
// need an extra variable to store the result of backdropGetTestFiles()
// since reset() takes an argument by reference and passing in a constant
// emits a notice in strict mode.
$imageTestFiles = $this->backdropGetTestFiles('image');
$invalidArchiveFile = reset($imageTestFiles);
$edit = array(
'files[project_upload]' => $invalidArchiveFile->uri,
);
// This also checks that the correct archive extensions are allowed.
$this->backdropPost('admin/installer/manual', $edit, t('Install'));
$this->assertText(t('Only files with the following extensions are allowed: @archive_extensions.', array('@archive_extensions' => archiver_get_extensions())), 'Only valid archives can be uploaded.');
// Check to ensure an existing module can't be reinstalled. Also checks that
// the archive was extracted since we can't know if the module is already
// installed until after extraction.
$validArchiveFile = backdrop_get_path('module', 'update') . '/tests/aaa_update_test/aaa_update_test.tar.gz';
$edit = array(
'files[project_upload]' => $validArchiveFile,
);
$this->backdropPost('admin/installer/manual', $edit, t('Install'));
$this->assertText(t('@module_name is already installed.', array('@module_name' => 'AAA Update test')), 'Existing module was extracted and not reinstalled.');
}