3 namespace Drupal\Tests\system\Functional\System;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests the authorize.php script and related API.
12 class SystemAuthorizeTest extends BrowserTestBase {
19 public static $modules = ['system_test'];
21 protected function setUp() {
24 // Create an administrator user.
25 $this->drupalLogin($this->drupalCreateUser(['administer software updates']));
29 * Helper function to initialize authorize.php and load it via drupalGet().
31 * Initializing authorize.php needs to happen in the child Drupal
32 * installation, not the parent. So, we visit a menu callback provided by
33 * system_test.module which calls system_authorized_init() to initialize the
34 * $_SESSION inside the test site, not the framework site. This callback
35 * redirects to authorize.php when it's done initializing.
37 * @see system_authorized_init()
39 public function drupalGetAuthorizePHP($page_title = 'system-test-auth') {
40 $this->drupalGet('system-test/authorize-init/' . $page_title);
44 * Tests the FileTransfer hooks
46 public function testFileTransferHooks() {
47 $page_title = $this->randomMachineName(16);
48 $this->drupalGetAuthorizePHP($page_title);
49 $this->assertTitle(strtr('@title | Drupal', ['@title' => $page_title]), 'authorize.php page title is correct.');
50 $this->assertNoText('It appears you have reached this page in error.');
51 $this->assertText('To continue, provide your server connection details');
52 // Make sure we see the new connection method added by system_test.
53 $this->assertRaw('System Test FileTransfer');
54 // Make sure the settings form callback works.
55 $this->assertText('System Test Username');
56 // Test that \Drupal\Core\Render\BareHtmlPageRenderer adds assets as
57 // expected to the first page of the authorize.php script.
58 $this->assertRaw('core/misc/states.js');