Index: modules/update/update.manager.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.manager.inc,v retrieving revision 1.23 diff -u -p -r1.23 update.manager.inc --- modules/update/update.manager.inc 26 May 2010 11:50:58 -0000 1.23 +++ modules/update/update.manager.inc 12 Jul 2010 07:10:42 -0000 @@ -539,8 +539,10 @@ function update_manager_install_form_sub } elseif ($_FILES['files']['name']['project_upload']) { $field = 'project_upload'; - // @todo: add some validators here. - $finfo = file_save_upload($field, array(), NULL, FILE_EXISTS_REPLACE); + // Pass in an empty list of file validators and let the arcive extraction + // code handle validation. + $validators = array('file_validate_extensions' => array()); + $finfo = file_save_upload($field, $validators, NULL, FILE_EXISTS_REPLACE); // @todo: find out if the module is already instealled, if so, throw an error. $local_cache = $finfo->uri; } Index: modules/update/update.test =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.test,v retrieving revision 1.13 diff -u -p -r1.13 update.test --- modules/update/update.test 4 Jan 2010 21:31:52 -0000 1.13 +++ modules/update/update.test 12 Jul 2010 07:10:42 -0000 @@ -493,3 +493,49 @@ class UpdateTestContribCase extends Upda } +class UpdateTestInstallCase extends UpdateTestHelper { + public static function getInfo() { + return array( + 'name' => 'Install new module functionality', + 'description' => 'Tests that we can use the update manager to add new modules to our site.', + 'group' => 'Update', + ); + } + + public function setup() { + parent::setUp('update'); + variable_set('allow_authorize_operations', TRUE); + $admin_user = $this->drupalCreateUser(array('administer software updates', 'administer site configuration')); + $this->drupalLogin($admin_user); + } + + /** + * Test that we can add a new module from a local file. + */ + public function testInstallNewLocalModule() { + // Images are not valid archives, so get one and try to install it. + $invalidArchiveFile = reset($this->drupalGetTestFiles('image')); + $edit = array( + 'files[project_upload]' => $invalidArchiveFile->uri, + ); + $this->drupalPost('admin/modules/install', $edit, t('Install')); + $this->assertText(t('Cannot extract temporary://@filename, not a valid archive.', array('@filename' => basename($invalidArchiveFile->uri))), "Invalid archive was not extracted."); + + // Try to install a valid archive, for an existing module. + $validArchiveFile = drupal_get_path('module', 'update') . '/tests/aaa_update_test.tar.gz'; + $edit = array( + 'files[project_upload]' => $validArchiveFile, + ); + $this->drupalPost('admin/modules/install', $edit, t('Install')); + $this->assertText(t('@module_name is already installed.', array('@module_name' => 'AAA Update test')), "Existing module was not reinstalled."); + + // Try to install a valid archive, valid module. + $validArchiveFile = drupal_get_path('module', 'update') . '/tests/new_test.tar.gz'; + $edit = array( + 'files[project_upload]' => $validArchiveFile, + ); + $this->drupalPost('admin/modules/install', $edit, t('Install')); + $this->assertText(t('To continue, provide your server connection details')), "Authorize.php prompts for security credentials"); + } +} +