FileTransferAuthorizeFormTest.php in Drupal 9
File
core/modules/update/tests/src/Functional/FileTransferAuthorizeFormTest.php
View source
<?php
namespace Drupal\Tests\update\Functional;
class FileTransferAuthorizeFormTest extends UpdateTestBase {
protected static $modules = [
'update',
'update_test',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$admin_user = $this
->drupalCreateUser([
'administer modules',
'administer software updates',
'administer site configuration',
]);
$this
->drupalLogin($admin_user);
$cache_directory = _update_manager_cache_directory(TRUE);
foreach ([
'.tar.gz',
'.zip',
] as $extension) {
$filename = 'update_test_new_module' . $extension;
copy(__DIR__ . '/../../update_test_new_module/8.x-1.0/' . $filename, $cache_directory . '/' . $filename);
}
}
public function testViaAuthorize($url) {
\Drupal::state()
->set('test_uploaders_via_prompt', TRUE);
$this
->drupalGet('admin/modules');
$this
->assertSession()
->pageTextNotContains('Update test new module');
$edit = [
'project_url' => $url,
];
$this
->drupalGet('admin/modules/install');
$this
->submitForm($edit, 'Continue');
$edit = [
'connection_settings[authorize_filetransfer_default]' => 'system_test',
'connection_settings[system_test][update_test_username]' => $this
->randomMachineName(),
];
$this
->submitForm($edit, 'Continue');
$this
->assertSession()
->pageTextContains('Files were added successfully.');
$this
->drupalGet('admin/modules');
$this
->assertSession()
->pageTextContains('Update test new module');
}
public function archiveFileUrlProvider() {
return [
'tar.gz' => [
'url' => 'https://ftp.drupal.org/files/projects/update_test_new_module.tar.gz',
],
'zip' => [
'url' => 'https://ftp.drupal.org/files/projects/update_test_new_module.zip',
],
];
}
}