function UpdateTestUploadCase::testUploadModule

Tests upload and extraction of a module.

File

modules/update/update.test, line 718

Class

UpdateTestUploadCase
Tests project upload and extract functionality.

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 drupalGetTestFiles()
    // since reset() takes an argument by reference and passing in a constant
    // emits a notice in strict mode.
    $imageTestFiles = $this->drupalGetTestFiles('image');
    $invalidArchiveFile = reset($imageTestFiles);
    $edit = array(
        'files[project_upload]' => $invalidArchiveFile->uri,
    );
    // This also checks that the correct archive extensions are allowed.
    $this->drupalPost('admin/modules/install', $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 = 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 extracted and not reinstalled.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.