PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/core/modules/system/src/Tests/System/SystemAuthorizeTest.php

https://gitlab.com/geeta7/drupal
PHP | 65 lines | 23 code | 9 blank | 33 comment | 0 complexity | 175891bbd9c1e4cded27e0fc118c91b4 MD5 | raw file
  1. <?php
  2. /**
  3. * @file
  4. * Contains \Drupal\system\Tests\System\SystemAuthorizeTest.
  5. */
  6. namespace Drupal\system\Tests\System;
  7. use Drupal\simpletest\WebTestBase;
  8. /**
  9. * Tests the authorize.php script and related API.
  10. *
  11. * @group system
  12. */
  13. class SystemAuthorizeTest extends WebTestBase {
  14. /**
  15. * Modules to enable.
  16. *
  17. * @var array
  18. */
  19. public static $modules = array('system_test');
  20. protected function setUp() {
  21. parent::setUp();
  22. // Create an administrator user.
  23. $this->drupalLogin ($this->drupalCreateUser(array('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. 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. function testFileTransferHooks() {
  43. $page_title = $this->randomMachineName(16);
  44. $this->drupalGetAuthorizePHP($page_title);
  45. $this->assertTitle(strtr('@title | Drupal', array('@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. }