diff --git a/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php b/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php index bf868db..fefb9d1e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php @@ -33,8 +33,8 @@ public static function getInfo() { * Confirms that we can acquire and release locks in two parallel requests. */ public function testLockAcquire() { - $lock_acquired = 'TRUE: Lock successfully acquired in system_test_lock_acquire()'; - $lock_not_acquired = 'FALSE: Lock not acquired in system_test_lock_acquire()'; + $lock_acquired = 'TRUE: Lock successfully acquired in \Drupal\system_test\Controller\SystemTestController::lockAcquire()'; + $lock_not_acquired = 'FALSE: Lock not acquired in \Drupal\system_test\Controller\SystemTestController::lockAcquire()'; $this->assertTrue(lock()->acquire('system_test_lock_acquire'), 'Lock acquired by this request.', 'Lock'); $this->assertTrue(lock()->acquire('system_test_lock_acquire'), 'Lock extended by this request.', 'Lock'); lock()->release('system_test_lock_acquire'); @@ -59,8 +59,8 @@ public function testLockAcquire() { $this->assertFalse(lock()->acquire('system_test_lock_acquire'), 'Lock cannot be extended by this request.', 'Lock'); // Check the shut-down function. - $lock_acquired_exit = 'TRUE: Lock successfully acquired in system_test_lock_exit()'; - $lock_not_acquired_exit = 'FALSE: Lock not acquired in system_test_lock_exit()'; + $lock_acquired_exit = 'TRUE: Lock successfully acquired in \Drupal\system_test\Controller\SystemTestController::lockExit()'; + $lock_not_acquired_exit = 'FALSE: Lock not acquired in \Drupal\system_test\Controller\SystemTestController::lockExit()'; $this->drupalGet('system-test/lock-exit'); $this->assertText($lock_acquired_exit, 'Lock acquired by the other request before exit.', 'Lock'); $this->assertTrue(lock()->acquire('system_test_lock_exit'), 'Lock acquired by this request after the other request exits.', 'Lock'); diff --git a/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php index 058aabe..e613c5f 100644 --- a/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php +++ b/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php @@ -8,6 +8,7 @@ namespace Drupal\system_test\Controller; use Drupal\Core\Controller\ControllerBase; +use Symfony\Component\HttpFoundation\Response; /** * Controller routines for system_test routes. @@ -25,17 +26,31 @@ public function mainContentFallback() { } /** - * @todo Remove system_test_lock_acquire(). + * Try to acquire a named lock and report the outcome. */ public function lockAcquire() { - return system_test_lock_acquire(); + if (\Drupal::lock()->acquire('system_test_lock_exit', 900)) { + echo 'TRUE: Lock successfully acquired in \Drupal\system_test\Controller\SystemTestController::lockExit()'; + // The shut-down function should release the lock. + exit(); + } + else { + return 'FALSE: Lock not acquired in \Drupal\system_test\Controller\SystemTestController::lockExit()'; + } } /** - * @todo Remove system_test_lock_exit(). + * Try to acquire a specific lock, and then exit. */ public function lockExit() { - return system_test_lock_exit(); + if (\Drupal::lock()->acquire('system_test_lock_exit', 900)) { + echo 'TRUE: Lock successfully acquired in \Drupal\system_test\Controller\SystemTestController::lockExit()'; + // The shut-down function should release the lock. + exit(); + } + else { + return 'FALSE: Lock not acquired in \Drupal\system_test\Controller\SystemTestController::lockExit()'; + } } /** @@ -50,10 +65,14 @@ function system_test_cache_tags_page() { } /** - * @todo Remove system_test_authorize_init_page(). + * Initialize authorize.php during testing. + * + * @see system_authorized_init(). */ public function authorizeInit($page_title) { - return 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); } /** @@ -64,17 +83,18 @@ public function variableGet() { } /** - * @todo Remove system_test_set_header(). + * Sets a header. */ - public function setHeader() { - return system_test_set_header(); + public function setHeader(Response $response = NULL) { + $response->headers->set($_GET['name'], $_GET['value']); + return t('The following header was set: %name: %value', array('%name' => $_GET['name'], '%value' => $_GET['value'])); } /** - * @todo Remove system_test_page_shutdown_functions(). + * A simple page callback which adds a register shutdown function. */ public function shutdownFunctions($arg1, $arg2) { - system_test_page_shutdown_functions($arg1, $arg2); + drupal_register_shutdown_function('_system_test_first_shutdown_function', $arg1, $arg2); } } 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 56ae206..fd44872 100644 --- a/core/modules/system/tests/modules/system_test/system_test.module +++ b/core/modules/system/tests/modules/system_test/system_test.module @@ -71,37 +71,6 @@ function system_test_system_info_alter(&$info, $file, $type) { } /** - * Try to acquire a named lock and report the outcome. - * - * @deprecated \Drupal\system_test\Controller\SystemTestController::lockAcquire() - */ -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. - * - * @deprecated \Drupal\system_test\Controller\SystemTestController::lockExit() - */ -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) { @@ -174,19 +143,6 @@ function system_test_filetransfer_info() { } /** - * Page callback to initialize authorize.php during testing. - * - * @see system_authorized_init(). - * - * @deprecated \Drupal\system_test\Controller\SystemTestController::authorizeInit() - */ -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); -} - -/** * Implements hook_module_preinstall(). */ function system_test_module_preinstall($module) {