PageRenderTime 47ms CodeModel.GetById 6ms RepoModel.GetById 0ms app.codeStats 0ms

/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php

http://github.com/drupal/drupal
PHP | 66 lines | 24 code | 10 blank | 32 comment | 0 complexity | 7c9bc8a2c56cb3cc2f38db0d8291290e MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. namespace Drupal\Tests\system\Functional\System;
  3. use Drupal\Tests\BrowserTestBase;
  4. /**
  5. * Tests the authorize.php script and related API.
  6. *
  7. * @group system
  8. */
  9. class SystemAuthorizeTest extends BrowserTestBase {
  10. /**
  11. * Modules to enable.
  12. *
  13. * @var array
  14. */
  15. public static $modules = ['system_test'];
  16. /**
  17. * {@inheritdoc}
  18. */
  19. protected $defaultTheme = 'stark';
  20. protected function setUp() {
  21. parent::setUp();
  22. // Create an administrator user.
  23. $this->drupalLogin($this->drupalCreateUser(['administer software updates']));
  24. }
  25. /**
  26. * Helper function to initialize authorize.php and load it via drupalGet().
  27. *
  28. * Initializing authorize.php needs to happen in the child Drupal
  29. * installation, not the parent. So, we visit a menu callback provided by
  30. * system_test.module which calls system_authorized_init() to initialize the
  31. * $_SESSION inside the test site, not the framework site. This callback
  32. * redirects to authorize.php when it's done initializing.
  33. *
  34. * @see system_authorized_init()
  35. */
  36. public function drupalGetAuthorizePHP($page_title = 'system-test-auth') {
  37. $this->drupalGet('system-test/authorize-init/' . $page_title);
  38. }
  39. /**
  40. * Tests the FileTransfer hooks
  41. */
  42. public function testFileTransferHooks() {
  43. $page_title = $this->randomMachineName(16);
  44. $this->drupalGetAuthorizePHP($page_title);
  45. $this->assertTitle(strtr('@title | Drupal', ['@title' => $page_title]), 'authorize.php page title is correct.');
  46. $this->assertNoText('It appears you have reached this page in error.');
  47. $this->assertText('To continue, provide your server connection details');
  48. // Make sure we see the new connection method added by system_test.
  49. $this->assertRaw('System Test FileTransfer');
  50. // Make sure the settings form callback works.
  51. $this->assertText('System Test Username');
  52. // Test that \Drupal\Core\Render\BareHtmlPageRenderer adds assets as
  53. // expected to the first page of the authorize.php script.
  54. $this->assertRaw('core/misc/states.js');
  55. }
  56. }