9d1819fca3d8c22faade8a92f45489bd3d3952ce
[yaffs-website] / web / core / modules / update / src / Tests / FileTransferAuthorizeFormTest.php
1 <?php
2
3 namespace Drupal\update\Tests;
4
5 /**
6  * Tests the Update Manager module upload via authorize.php functionality.
7  *
8  * @group update
9  */
10 class FileTransferAuthorizeFormTest extends UpdateTestBase {
11
12   /**
13    * Modules to enable.
14    *
15    * @var array
16    */
17   public static $modules = ['update', 'update_test'];
18
19   protected function setUp() {
20     parent::setUp();
21     $admin_user = $this->drupalCreateUser(['administer modules', 'administer software updates', 'administer site configuration']);
22     $this->drupalLogin($admin_user);
23
24     // Create a local cache so the module is not downloaded from drupal.org.
25     $cache_directory = _update_manager_cache_directory(TRUE);
26     $validArchiveFile = __DIR__ . '/../../tests/update_test_new_module/8.x-1.0/update_test_new_module.tar.gz';
27     copy($validArchiveFile, $cache_directory . '/update_test_new_module.tar.gz');
28   }
29
30   /**
31    * Tests the Update Manager module upload via authorize.php functionality.
32    */
33   public function testViaAuthorize() {
34     // Ensure the that we can select which file transfer backend to use.
35     \Drupal::state()->set('test_uploaders_via_prompt', TRUE);
36
37     // Ensure the module does not already exist.
38     $this->drupalGet('admin/modules');
39     $this->assertNoText('Update test new module');
40
41     $edit = [
42       // This project has been cached in the test's setUp() method.
43       'project_url' => 'https://ftp.drupal.org/files/projects/update_test_new_module.tar.gz',
44     ];
45     $this->drupalPostForm('admin/modules/install', $edit, t('Install'));
46     $edit = [
47       'connection_settings[authorize_filetransfer_default]' => 'system_test',
48       'connection_settings[system_test][update_test_username]' => $this->randomMachineName(),
49     ];
50     $this->drupalPostForm(NULL, $edit, t('Continue'));
51     $this->assertText(t('Installation was completed successfully.'));
52
53     // Ensure the module is available to install.
54     $this->drupalGet('admin/modules');
55     $this->assertText('Update test new module');
56   }
57
58 }