diff --git a/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTest.php b/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTest.php new file mode 100644 index 0000000..e153b94 --- /dev/null +++ b/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTest.php @@ -0,0 +1,89 @@ + $request->server->get('PHP_AUTH_USER'))); + $output .= t('$_SERVER[\'PHP_AUTH_PW\'] is @password.', array('@password' => $request->server->get('PHP_AUTH_PW'))); + return $output; + } + + /** + * Try to acquire a named lock and report the outcome. + */ + public function lockAcquire() { + if (lock()->acquire('system_test_lock_acquire')) { + lock()->release('system_test_lock_acquire'); + return 'TRUE: Lock successfully acquired in system_test_lock_acquire()'; + } + else { + return 'FALSE: Lock not acquired in system_test_lock_acquire()'; + } + } + + /** + * Try to acquire a specific lock, and then exit. + */ + public function lockExit() { + if (lock()->acquire('system_test_lock_exit', 900)) { + echo 'TRUE: Lock successfully acquired in system_test_lock_exit()'; + // The shut-down function should release the lock. + exit(); + } + else { + return 'FALSE: Lock not acquired in system_test_lock_exit()'; + } + } + + /** + * Menu callback to test main content fallback(). + */ + public function mainContentFallback() { + return t('Content to test main content fallback'); + } + + /** + * A simple page callback which adds a register shutdown function. + */ + public function pageShutdownFunctions($arg1, $arg2) { + drupal_register_shutdown_function('_system_test_first_shutdown_function', $arg1, $arg2); + } + + public function setHeader(Request $request) { + $name = $request->query->get('name'); + $value = $request->query->get('value'); + $response = new Response; + $response->headers->set($name, $value); + drupal_add_http_header($_GET['name'], $_GET['value']); + $content = t('The following header was set: %name: %value', array('%name' => $name, '%value' => $value)); + $response->setContent($content); + return $response; + } + +} diff --git a/core/modules/system/tests/modules/system_test/system_test.module b/core/modules/system/tests/modules/system_test/system_test.module index ea10a04..568fb9e 100644 --- a/core/modules/system/tests/modules/system_test/system_test.module +++ b/core/modules/system/tests/modules/system_test/system_test.module @@ -6,22 +6,6 @@ * Implements hook_menu(). */ function system_test_menu() { - $items['system-test/auth'] = array( - 'page callback' => 'system_test_basic_auth_page', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['system-test/authorize-init/%'] = array( - 'page callback' => 'system_test_authorize_init_page', - 'page arguments' => array(2), - 'access arguments' => array('administer software updates'), - 'type' => MENU_CALLBACK, - ); - $items['system-test/set-header'] = array( - 'page callback' => 'system_test_set_header', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK, - ); $items['system-test/variable-get'] = array( 'title' => 'Variable Get', 'page callback' => 'variable_get', @@ -30,62 +14,9 @@ function system_test_menu() { 'type' => MENU_CALLBACK, ); - $items['system-test/lock-acquire'] = array( - 'title' => 'Lock acquire', - 'page callback' => 'system_test_lock_acquire', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['system-test/lock-exit'] = array( - 'title' => 'Lock acquire then exit', - 'page callback' => 'system_test_lock_exit', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['system-test/main-content-handling'] = array( - 'title' => 'Test main content handling', - 'page callback' => 'system_test_main_content_fallback', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['system-test/main-content-fallback'] = array( - 'title' => 'Test main content fallback', - 'page callback' => 'system_test_main_content_fallback', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['system-test/main-content-duplication'] = array( - 'title' => 'Test main content duplication', - 'page callback' => 'system_test_main_content_fallback', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - - $items['system-test/shutdown-functions'] = array( - 'title' => 'Test main content duplication', - 'page callback' => 'system_test_page_shutdown_functions', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - return $items; } -function system_test_basic_auth_page() { - $output = t('$_SERVER[\'PHP_AUTH_USER\'] is @username.', array('@username' => $_SERVER['PHP_AUTH_USER'])); - $output .= t('$_SERVER[\'PHP_AUTH_PW\'] is @password.', array('@password' => $_SERVER['PHP_AUTH_PW'])); - return $output; -} - -function system_test_set_header() { - drupal_add_http_header($_GET['name'], $_GET['value']); - return t('The following header was set: %name: %value', array('%name' => $_GET['name'], '%value' => $_GET['value'])); -} - /** * Implements hook_modules_installed(). */ @@ -167,33 +98,6 @@ function system_test_system_info_alter(&$info, $file, $type) { } /** - * Try to acquire a named lock and report the outcome. - */ -function system_test_lock_acquire() { - if (lock()->acquire('system_test_lock_acquire')) { - lock()->release('system_test_lock_acquire'); - return 'TRUE: Lock successfully acquired in system_test_lock_acquire()'; - } - else { - return 'FALSE: Lock not acquired in system_test_lock_acquire()'; - } -} - -/** - * Try to acquire a specific lock, and then exit. - */ -function system_test_lock_exit() { - if (lock()->acquire('system_test_lock_exit', 900)) { - echo 'TRUE: Lock successfully acquired in system_test_lock_exit()'; - // The shut-down function should release the lock. - exit(); - } - else { - return 'FALSE: Lock not acquired in system_test_lock_exit()'; - } -} - -/** * Implements hook_page_build(). */ function system_test_page_build(&$page) { @@ -219,20 +123,6 @@ function system_test_page_build(&$page) { } /** - * Menu callback to test main content fallback(). - */ -function system_test_main_content_fallback() { - return t('Content to test main content fallback'); -} - -/** - * A simple page callback which adds a register shutdown function. - */ -function system_test_page_shutdown_functions($arg1, $arg2) { - drupal_register_shutdown_function('_system_test_first_shutdown_function', $arg1, $arg2); -} - -/** * Dummy shutdown function which registers another shutdown function. */ function _system_test_first_shutdown_function($arg1, $arg2) { @@ -270,13 +160,3 @@ function system_test_filetransfer_info() { ); } -/** - * Page callback to initialize authorize.php during testing. - * - * @see system_authorized_init(). - */ -function system_test_authorize_init_page($page_title) { - $authorize_url = $GLOBALS['base_url'] . '/core/authorize.php'; - system_authorized_init('system_test_authorize_run', drupal_get_path('module', 'system_test') . '/system_test.module', array(), $page_title); - return new RedirectResponse($authorize_url); -} diff --git a/core/modules/system/tests/modules/system_test/system_test.routing.yml b/core/modules/system/tests/modules/system_test/system_test.routing.yml index 1be2566..fa855ba 100644 --- a/core/modules/system/tests/modules/system_test/system_test.routing.yml +++ b/core/modules/system/tests/modules/system_test/system_test.routing.yml @@ -5,3 +5,66 @@ system_test.page_cache_accept_header: requirements: _access: 'TRUE' +system_test_authorize_init_page: + pattern: '/system-test/authorize-init/{page_title}' + defaults: + _controller: '\Drupal\system_test\Controller\SystemTest::authorizeInitPage' + requirements: + _access: 'TRUE' + +system_test_basic_auth_page: + pattern: '/system-test/auth' + defaults: + _controller: '\Drupal\system_test\Controller\SystemTest::basicAuthPage' + requirements: + _access: 'TRUE' + +system_test_lock_acquire: + pattern: '/system-test/lock-acquire' + defaults: + _controller: '\Drupal\system_test\Controller\SystemTest::lockAcquire' + requirements: + _access: 'TRUE' + +system_test_lock_exit: + pattern: '/system-test/lock-exit' + defaults: + _controller: '\Drupal\system_test\Controller\SystemTest::lockExit' + requirements: + _access: 'TRUE' + +system_test_main_content_handling: + pattern: '/system-test/main-content-handling' + defaults: + _controller: '\Drupal\system_test\Controller\SystemTest::mainContentFallback' + requirements: + _access: 'TRUE' + +system_test_main_content_fallback: + pattern: '/system-test/main-content-fallback' + defaults: + _controller: '\Drupal\system_test\Controller\SystemTest::mainContentFallback' + requirements: + _access: 'TRUE' + +system_test_main_content_duplication: + pattern: '/system-test/main-content-duplication' + defaults: + _controller: '\Drupal\system_test\Controller\SystemTest::mainContentFallback' + requirements: + _access: 'TRUE' + +system_test_shutdown_functions: + pattern: '/system-test/shutdown-functions/{arg1}/{arg2}' + defaults: + _controller: '\Drupal\system_test\Controller\SystemTest::pageShutdownFunctions' + requirements: + _access: 'TRUE' + +system_test_set_header: + pattern: '/system-test/set-header' + defaults: + _controller: '\Drupal\system_test\Controller\SystemTest::setHeader' + requirements: + _access: 'TRUE' +