PageRenderTime 55ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/core/modules/system/lib/Drupal/system/Tests/System/SystemAuthorizeTest.php

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