diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php index 90327f9..b0d10ec 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php @@ -61,7 +61,7 @@ class BlockCacheTest extends WebTestBase { // Enable our test block. Set some content for it to display. $current_content = $this->randomName(); - variable_set('block_test_content', $current_content); + state()->set('block_test_content', $current_content); $this->drupalLogin($this->normal_user); $this->drupalGet(''); $this->assertText($current_content, t('Block content displays.')); @@ -69,7 +69,7 @@ class BlockCacheTest extends WebTestBase { // Change the content, but the cached copy should still be served. $old_content = $current_content; $current_content = $this->randomName(); - variable_set('block_test_content', $current_content); + state()->set('block_test_content', $current_content); $this->drupalGet(''); $this->assertText($old_content, t('Block is served from the cache.')); @@ -82,7 +82,7 @@ class BlockCacheTest extends WebTestBase { // Test whether the cached data is served for the correct users. $old_content = $current_content; $current_content = $this->randomName(); - variable_set('block_test_content', $current_content); + state()->set('block_test_content', $current_content); $this->drupalLogout(); $this->drupalGet(''); $this->assertNoText($old_content, t('Anonymous user does not see content cached per-role for normal user.')); @@ -106,14 +106,14 @@ class BlockCacheTest extends WebTestBase { function testCacheGlobal() { $this->setCacheMode(DRUPAL_CACHE_GLOBAL); $current_content = $this->randomName(); - variable_set('block_test_content', $current_content); + state()->set('block_test_content', $current_content); $this->drupalGet(''); $this->assertText($current_content, t('Block content displays.')); $old_content = $current_content; $current_content = $this->randomName(); - variable_set('block_test_content', $current_content); + state()->set('block_test_content', $current_content); $this->drupalLogout(); $this->drupalGet('user'); @@ -126,7 +126,7 @@ class BlockCacheTest extends WebTestBase { function testNoCache() { $this->setCacheMode(DRUPAL_NO_CACHE); $current_content = $this->randomName(); - variable_set('block_test_content', $current_content); + state()->set('block_test_content', $current_content); // If DRUPAL_NO_CACHE has no effect, the next request would be cached. $this->drupalGet(''); @@ -134,7 +134,7 @@ class BlockCacheTest extends WebTestBase { // A cached copy should not be served. $current_content = $this->randomName(); - variable_set('block_test_content', $current_content); + state()->set('block_test_content', $current_content); $this->drupalGet(''); $this->assertText($current_content, t('DRUPAL_NO_CACHE prevents blocks from being cached.')); } @@ -145,7 +145,7 @@ class BlockCacheTest extends WebTestBase { function testCachePerUser() { $this->setCacheMode(DRUPAL_CACHE_PER_USER); $current_content = $this->randomName(); - variable_set('block_test_content', $current_content); + state()->set('block_test_content', $current_content); $this->drupalLogin($this->normal_user); $this->drupalGet(''); @@ -153,7 +153,7 @@ class BlockCacheTest extends WebTestBase { $old_content = $current_content; $current_content = $this->randomName(); - variable_set('block_test_content', $current_content); + state()->set('block_test_content', $current_content); $this->drupalGet(''); $this->assertText($old_content, t('Block is served from per-user cache.')); @@ -173,14 +173,14 @@ class BlockCacheTest extends WebTestBase { function testCachePerPage() { $this->setCacheMode(DRUPAL_CACHE_PER_PAGE); $current_content = $this->randomName(); - variable_set('block_test_content', $current_content); + state()->set('block_test_content', $current_content); $this->drupalGet('node'); $this->assertText($current_content, t('Block content displays on the node page.')); $old_content = $current_content; $current_content = $this->randomName(); - variable_set('block_test_content', $current_content); + state()->set('block_test_content', $current_content); $this->drupalGet('user'); $this->assertNoText($old_content, t('Block content cached for the node page does not show up for the user page.')); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php index f98da2b..e9e703e 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php @@ -401,7 +401,7 @@ class BlockTest extends WebTestBase { $this->assertEqual($current_caching, DRUPAL_CACHE_PER_ROLE, t('Test block cache mode defaults to DRUPAL_CACHE_PER_ROLE.')); // Disable caching for this block. - variable_set('block_test_caching', DRUPAL_NO_CACHE); + state()->set('block_test_caching', DRUPAL_NO_CACHE); // Flushing all caches should call _block_rehash(). $this->resetAll(); // Verify that the database is updated with the new caching mode. diff --git a/core/modules/block/tests/block_test.module b/core/modules/block/tests/block_test.module index 5e06d5c..1d2e74b 100644 --- a/core/modules/block/tests/block_test.module +++ b/core/modules/block/tests/block_test.module @@ -19,7 +19,7 @@ function block_test_system_theme_info() { function block_test_block_info() { $blocks['test_cache'] = array( 'info' => t('Test block caching'), - 'cache' => variable_get('block_test_caching', DRUPAL_CACHE_PER_ROLE), + 'cache' => state()->get('block_test_caching') ?: DRUPAL_CACHE_PER_ROLE, ); $blocks['test_html_id'] = array( @@ -32,5 +32,5 @@ function block_test_block_info() { * Implements hook_block_view(). */ function block_test_block_view($delta = 0) { - return array('content' => variable_get('block_test_content', '')); + return array('content' => state()->get('block_test_content') ?: ''); } diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php index 516ad58..e6464e1 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php @@ -78,7 +78,7 @@ class TranslationTest extends FieldTestBase { field_test_entity_info_translatable('test_entity', TRUE); // Test hook_field_languages() invocation on a translatable field. - variable_set('field_test_field_available_languages_alter', TRUE); + state()->set('field_test_field_available_languages_alter', TRUE); $langcodes = field_content_languages(); $available_langcodes = field_available_languages($this->entity_type, $this->field); foreach ($available_langcodes as $delta => $langcode) { @@ -330,7 +330,7 @@ class TranslationTest extends FieldTestBase { $this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_langcode, t('The display language for the (single) field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode))); // Test field_language() basic behavior without language fallback. - variable_set('field_test_language_fallback', FALSE); + state()->set('field_test_language_fallback', FALSE); $entity->{$this->field_name}[$requested_langcode] = mt_rand(1, 127); drupal_static_reset('field_language'); $display_langcode = field_language($entity_type, $entity, $this->field_name, $requested_langcode); diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc index 4819b3f..c25df2e 100644 --- a/core/modules/field/tests/modules/field_test/field_test.entity.inc +++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc @@ -12,7 +12,7 @@ use Drupal\field_test\TestEntity; * Implements hook_entity_info(). */ function field_test_entity_info() { - $bundles = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle'))); + $bundles = state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle')); $test_entity_modes = array( 'full' => array( 'label' => t('Full object'), @@ -179,9 +179,9 @@ function field_test_entity_info_translatable($entity_type = NULL, $translatable * name will be used. */ function field_test_create_bundle($bundle, $text = NULL) { - $bundles = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle'))); + $bundles = state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle')); $bundles += array($bundle => array('label' => $text ? $text : $bundle)); - variable_set('field_test_bundles', $bundles); + state()->set('field_test_bundles', $bundles); $info = field_test_entity_info(); foreach ($info as $type => $type_info) { @@ -198,10 +198,10 @@ function field_test_create_bundle($bundle, $text = NULL) { * The new machine-readable name of the bundle. */ function field_test_rename_bundle($bundle_old, $bundle_new) { - $bundles = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle'))); + $bundles = state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle')); $bundles[$bundle_new] = $bundles[$bundle_old]; unset($bundles[$bundle_old]); - variable_set('field_test_bundles', $bundles); + state()->set('field_test_bundles', $bundles); $info = field_test_entity_info(); foreach ($info as $type => $type_info) { @@ -216,9 +216,9 @@ function field_test_rename_bundle($bundle_old, $bundle_new) { * The machine-readable name of the bundle to delete. */ function field_test_delete_bundle($bundle) { - $bundles = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle'))); + $bundles = state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle')); unset($bundles[$bundle]); - variable_set('field_test_bundles', $bundles); + state()->set('field_test_bundles', $bundles); $info = field_test_entity_info(); foreach ($info as $type => $type_info) { diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index 6dfbb15..61f63e2 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -103,7 +103,7 @@ function field_test_field_test_op_multiple($entity_type, $entities, $field, $ins * Implements hook_field_available_languages_alter(). */ function field_test_field_available_languages_alter(&$langcodes, $context) { - if (variable_get('field_test_field_available_languages_alter', FALSE)) { + if (state()->get('field_test_field_available_languages_alter')) { // Add an unavailable language code. $langcodes[] = 'xx'; // Remove an available language code. @@ -116,7 +116,7 @@ function field_test_field_available_languages_alter(&$langcodes, $context) { * Implements hook_field_language_alter(). */ function field_test_field_language_alter(&$display_langcode, $context) { - if (variable_get('field_test_language_fallback', TRUE)) { + if (state()->get('field_test_language_fallback') ?: TRUE) { field_language_fallback($display_langcode, $context['entity'], $context['langcode']); } } diff --git a/core/modules/field/tests/modules/field_test/field_test.storage.inc b/core/modules/field/tests/modules/field_test/field_test.storage.inc index ffc919e..39db87f 100644 --- a/core/modules/field/tests/modules/field_test/field_test.storage.inc +++ b/core/modules/field/tests/modules/field_test/field_test.storage.inc @@ -70,10 +70,10 @@ function field_test_field_storage_details_alter(&$details, $field) { */ function _field_test_storage_data($data = NULL) { if (!isset($data)) { - return variable_get('field_test_storage_data', array()); + return state()->get('field_test_storage_data') ?: array(); } else { - variable_set('field_test_storage_data', $data); + state()->set('field_test_storage_data', $data); } } diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module index 46b8604..c1fb1e0 100644 --- a/core/modules/file/tests/file_test/file_test.module +++ b/core/modules/file/tests/file_test/file_test.module @@ -153,14 +153,14 @@ function file_test_reset() { 'move' => array(), 'delete' => array(), ); - variable_set('file_test_results', $results); + state()->set('file_test_results', $results); // These hooks will return these values, see file_test_set_return(). $return = array( 'validate' => array(), 'download' => NULL, ); - variable_set('file_test_return', $return); + state()->set('file_test_return', $return); } /** @@ -178,7 +178,7 @@ function file_test_reset() { * @see file_test_reset() */ function file_test_get_calls($op) { - $results = variable_get('file_test_results', array()); + $results = state()->get('file_test_results') ?: array(); return $results[$op]; } @@ -191,7 +191,7 @@ function file_test_get_calls($op) { * passed to each call. */ function file_test_get_all_calls() { - return variable_get('file_test_results', array()); + return state()->get('file_test_results') ?: array(); } /** @@ -207,9 +207,9 @@ function file_test_get_all_calls() { * @see file_test_reset() */ function _file_test_log_call($op, $args) { - $results = variable_get('file_test_results', array()); + $results = state()->get('file_test_results') ?: array(); $results[$op][] = $args; - variable_set('file_test_results', $results); + state()->set('file_test_results', $results); } /** @@ -225,7 +225,7 @@ function _file_test_log_call($op, $args) { * @see file_test_reset() */ function _file_test_get_return($op) { - $return = variable_get('file_test_return', array($op => NULL)); + $return = state()->get('file_test_return') ?: array($op => NULL); return $return[$op]; } @@ -241,9 +241,9 @@ function _file_test_get_return($op) { * @see file_test_reset() */ function file_test_set_return($op, $value) { - $return = variable_get('file_test_return', array()); + $return = state()->get('file_test_return') ?: array(); $return[$op] = $value; - variable_set('file_test_return', $return); + state()->set('file_test_return', $return); } /** diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php index aa6774b..0e3db79 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php @@ -42,8 +42,8 @@ class LanguageNegotiationInfoTest extends WebTestBase { */ function testInfoAlterations() { // Enable language type/negotiation info alterations. - variable_set('language_test_language_types', TRUE); - variable_set('language_test_language_negotiation_info', TRUE); + state()->set('language_test_language_types', TRUE); + state()->set('language_test_language_negotiation_info', TRUE); $this->languageNegotiationUpdate(); // Check that fixed language types are properly configured without the need @@ -52,7 +52,7 @@ class LanguageNegotiationInfoTest extends WebTestBase { // Make the content language type configurable by updating the language // negotiation settings with the proper flag enabled. - variable_set('language_test_content_language_type', TRUE); + state()->set('language_test_content_language_type', TRUE); $this->languageNegotiationUpdate(); $type = LANGUAGE_TYPE_CONTENT; $language_types = variable_get('language_types', language_types_get_default()); @@ -73,7 +73,7 @@ class LanguageNegotiationInfoTest extends WebTestBase { // Remove the interface language negotiation method by updating the language // negotiation settings with the proper flag enabled. - variable_set('language_test_language_negotiation_info_alter', TRUE); + state()->set('language_test_language_negotiation_info_alter', TRUE); $this->languageNegotiationUpdate(); $negotiation = variable_get("language_negotiation_$type", array()); $this->assertFalse(isset($negotiation[$interface_method_id]), t('Interface language negotiation method removed from the stored settings.')); @@ -93,7 +93,7 @@ class LanguageNegotiationInfoTest extends WebTestBase { // Check language negotiation results. $this->drupalGet(''); - $last = variable_get('language_test_language_negotiation_last', array()); + $last = state()->get('language_test_language_negotiation_last') ?: array(); foreach (language_types_get_all() as $type) { $langcode = $last[$type]; $value = $type == LANGUAGE_TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en'; diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php index 0b87a09..e14b13f 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php @@ -343,7 +343,7 @@ class LanguageUILanguageNegotiationTest extends WebTestBase { variable_set('language_negotiation_url_part', $test['language_negotiation_url_part']); } if (!empty($test['language_test_domain'])) { - variable_set('language_test_domain', $test['language_test_domain']); + state()->set('language_test_domain', $test['language_test_domain']); } $this->drupalGet($test['path'], array(), $test['http_header']); $this->assertText($test['expect'], $test['message']); diff --git a/core/modules/language/tests/language_test.module b/core/modules/language/tests/language_test.module index be0a8c0..5d4829f 100644 --- a/core/modules/language/tests/language_test.module +++ b/core/modules/language/tests/language_test.module @@ -12,8 +12,8 @@ * the HTTP_HOST here */ function language_test_boot() { - if (variable_get('language_test_domain')) { - $_SERVER['HTTP_HOST'] = variable_get('language_test_domain'); + if (state()->get('language_test_domain')) { + $_SERVER['HTTP_HOST'] = state()->get('language_test_domain'); } } @@ -48,7 +48,7 @@ function language_test_language_types_info() { * Implements hook_language_types_info_alter(). */ function language_test_language_types_info_alter(array &$language_types) { - if (variable_get('language_test_content_language_type', FALSE)) { + if (state()->get('language_test_content_language_type')) { unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']); } } @@ -57,7 +57,7 @@ function language_test_language_types_info_alter(array &$language_types) { * Implements hook_language_negotiation_info(). */ function language_test_language_negotiation_info() { - if (variable_get('language_test_language_negotiation_info', FALSE)) { + if (state()->get('language_test_language_negotiation_info')) { $info = array( 'callbacks' => array( 'negotiation' => 'language_test_language_negotiation_method', @@ -84,7 +84,7 @@ function language_test_language_negotiation_info() { * Implements hook_language_negotiation_info_alter(). */ function language_test_language_negotiation_info_alter(array &$negotiation_info) { - if (variable_get('language_test_language_negotiation_info_alter', FALSE)) { + if (state()->get('language_test_language_negotiation_info_alter')) { unset($negotiation_info[LANGUAGE_NEGOTIATION_INTERFACE]); } } @@ -97,7 +97,7 @@ function language_test_store_language_negotiation() { foreach (language_types_get_all() as $type) { $last[$type] = language($type)->langcode; } - variable_set('language_test_language_negotiation_last', $last); + state()->set('language_test_language_negotiation_last', $last); } /** diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleCommentLanguageTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleCommentLanguageTest.php index 6776e31..fa4a26d 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleCommentLanguageTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleCommentLanguageTest.php @@ -51,7 +51,7 @@ class LocaleCommentLanguageTest extends WebTestBase { $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type')); // Enable content language negotiation UI. - variable_set('language_test_content_language_type', TRUE); + state()->set('language_test_content_language_type', TRUE); // Set interface language detection to user and content language detection // to URL. Disable inheritance from interface language to ensure content diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php index f977de5..87a5d32 100644 --- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php +++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php @@ -75,9 +75,9 @@ class OpenIDFunctionalTest extends OpenIDTestBase { $identity = url('openid-test/yadis/xrds/dummy-user', array('absolute' => TRUE, 'fragment' => $this->randomName())); // Tell openid_test.module to respond with this identifier. If the fragment // part is present in the identifier, it should be retained. - variable_set('openid_test_response', array('openid.claimed_id' => $identity)); + state()->set('openid_test_response', array('openid.claimed_id' => $identity)); $this->addIdentity(url('openid-test/yadis/xrds/server', array('absolute' => TRUE)), 2, 'http://specs.openid.net/auth/2.0/identifier_select', $identity); - variable_set('openid_test_response', array()); + state()->set('openid_test_response', array()); // Identifier is the URL of an HTML page that is sent with an HTTP header // that contains the URL of an XRDS document. @@ -92,7 +92,7 @@ class OpenIDFunctionalTest extends OpenIDTestBase { $this->addIdentity('@example*résumé;%25', 2, 'http://example.com/xrds', 'http://example.com/user'); // Make sure that unverified CanonicalID are not trusted. - variable_set('openid_test_canonical_id_status', 'bad value'); + state()->set('openid_test_canonical_id_status', 'bad value'); $this->addIdentity('@example*résumé;%25', 2, FALSE, FALSE); // HTML-based discovery: @@ -138,20 +138,20 @@ class OpenIDFunctionalTest extends OpenIDTestBase { // Use a User-supplied Identity that is the URL of an XRDS document. $identity = url('openid-test/yadis/xrds', array('absolute' => TRUE)); $this->addIdentity($identity); - $response = variable_get('openid_test_hook_openid_response_response'); - $account = variable_get('openid_test_hook_openid_response_account'); + $response = state()->get('openid_test_hook_openid_response_response'); + $account = state()->get('openid_test_hook_openid_response_account'); $this->assertEqual($response['openid.claimed_id'], $identity, t('hook_openid_response() was invoked.')); $this->assertEqual($account->uid, $this->web_user->uid, t('Proper user object passed to hook_openid_response().')); $this->drupalLogout(); // Test logging in via the login block on the front page. - variable_del('openid_test_hook_openid_response_response'); - variable_del('openid_test_hook_openid_response_account'); + state()->del('openid_test_hook_openid_response_response'); + state()->del('openid_test_hook_openid_response_account'); $this->submitLoginForm($identity); $this->assertLink(t('Log out'), 0, t('User was logged in.')); - $response = variable_get('openid_test_hook_openid_response_response'); - $account = variable_get('openid_test_hook_openid_response_account'); + $response = state()->get('openid_test_hook_openid_response_response'); + $account = state()->get('openid_test_hook_openid_response_account'); $this->assertEqual($response['openid.claimed_id'], $identity, t('hook_openid_response() was invoked.')); $this->assertEqual($account->uid, $this->web_user->uid, t('Proper user object passed to hook_openid_response().')); @@ -176,11 +176,11 @@ class OpenIDFunctionalTest extends OpenIDTestBase { // Tell openid_test.module to alter the checkid_setup request. $new_identity = 'http://example.com/' . $this->randomName(); - variable_set('openid_test_identity', $new_identity); - variable_set('openid_test_request_alter', array('checkid_setup' => array('openid.identity' => $new_identity))); + state()->set('openid_test_identity', $new_identity); + state()->set('openid_test_request_alter', array('checkid_setup' => array('openid.identity' => $new_identity))); $this->submitLoginForm($identity); $this->assertLink(t('Log out'), 0, t('User was logged in.')); - $response = variable_get('openid_test_hook_openid_response_response'); + $response = state()->get('openid_test_hook_openid_response_response'); $this->assertEqual($response['openid.identity'], $new_identity, t('hook_openid_request_alter() were invoked.')); } @@ -278,7 +278,7 @@ class OpenIDFunctionalTest extends OpenIDTestBase { */ function addIdentity($identity, $version = 2, $local_id = 'http://example.com/xrds', $claimed_id = NULL) { // Tell openid_test.module to only accept this OP-Local Identifier. - variable_set('openid_test_identity', $local_id); + state()->set('openid_test_identity', $local_id); $edit = array('openid_identifier' => $identity); $this->drupalPost('user/' . $this->web_user->uid . '/openid', $edit, t('Add an OpenID')); @@ -328,14 +328,14 @@ class OpenIDFunctionalTest extends OpenIDTestBase { // Identifier, we insert the same identifier also to the provider response, // but provider could further change the Claimed ID actually (e.g. it could // add unique fragment). - variable_set('openid_test_redirect_url', $identity); - variable_set('openid_test_response', array('openid.claimed_id' => $identity)); + state()->set('openid_test_redirect_url', $identity); + state()->set('openid_test_response', array('openid.claimed_id' => $identity)); $this->addIdentity(url('openid-test/redirect/' . $redirects, array('absolute' => TRUE)), $version, $local_id, $claimed_id); // Clean up. - variable_del('openid_test_redirect_url'); - variable_del('openid_test_response'); + state()->del('openid_test_redirect_url'); + state()->del('openid_test_response'); } /** @@ -346,12 +346,12 @@ class OpenIDFunctionalTest extends OpenIDTestBase { $identity = url('openid-test/yadis/xrds', array('absolute' => TRUE)); // Respond with an invalid signature. - variable_set('openid_test_response', array('openid.sig' => 'this-is-an-invalid-signature')); + state()->set('openid_test_response', array('openid.sig' => 'this-is-an-invalid-signature')); $this->submitLoginForm($identity); $this->assertRaw('OpenID login failed.'); // Do not sign the mandatory field openid.assoc_handle. - variable_set('openid_test_response', array('openid.signed' => 'op_endpoint,claimed_id,identity,return_to,response_nonce')); + state()->set('openid_test_response', array('openid.signed' => 'op_endpoint,claimed_id,identity,return_to,response_nonce')); $this->submitLoginForm($identity); $this->assertRaw('OpenID login failed.'); @@ -370,7 +370,7 @@ class OpenIDFunctionalTest extends OpenIDTestBase { 'openid.signed' => implode(',', $keys_to_sign), ); $response['openid.sig'] = _openid_signature($association, $response, $keys_to_sign); - variable_set('openid_test_response', $response); + state()->set('openid_test_response', $response); $this->submitLoginForm($identity); $this->assertNoRaw('OpenID login failed.'); $this->assertFieldByName('name', '', t('No username was supplied by provider.')); @@ -382,7 +382,7 @@ class OpenIDFunctionalTest extends OpenIDTestBase { 'openid.sreg.nickname' => 'john', 'openid.sreg.email' => 'john@example.com', ); - variable_set('openid_test_response', $response); + state()->set('openid_test_response', $response); $this->submitLoginForm($identity); $this->assertNoRaw('OpenID login failed.'); $this->assertFieldByName('name', 'john', t('Username was supplied by provider.')); diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php index d556309..3dcaa57 100644 --- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php +++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php @@ -45,7 +45,7 @@ class OpenIDRegistrationTest extends OpenIDTestBase { variable_set('date_default_timezone', 'Europe/Brussels'); // Tell openid_test.module to respond with these SREG fields. - variable_set('openid_test_response', array( + state()->set('openid_test_response', array( 'openid.sreg.nickname' => 'john', 'openid.sreg.email' => 'john@example.com', 'openid.sreg.language' => 'pt-BR', @@ -102,7 +102,7 @@ class OpenIDRegistrationTest extends OpenIDTestBase { variable_set('date_default_timezone', 'Europe/Brussels'); // Tell openid_test.module to respond with these SREG fields. - variable_set('openid_test_response', array( + state()->set('openid_test_response', array( 'openid.sreg.nickname' => 'john', 'openid.sreg.email' => 'john@example.com', 'openid.sreg.language' => 'pt-BR', @@ -144,7 +144,7 @@ class OpenIDRegistrationTest extends OpenIDTestBase { // Tell openid_test.module to respond with these SREG fields. $web_user = $this->drupalCreateUser(array()); - variable_set('openid_test_response', array( + state()->set('openid_test_response', array( 'openid.sreg.nickname' => $web_user->name, 'openid.sreg.email' => 'mail@invalid#', 'openid.sreg.timezone' => 'Foo/Bar', @@ -158,11 +158,11 @@ class OpenIDRegistrationTest extends OpenIDTestBase { $this->assertRaw(t('Account registration using the information provided by your OpenID provider failed due to the reasons listed below. Complete the registration by filling out the form below. If you already have an account, you can log in now and add your OpenID under "My account".', array('@login' => url('user/login'))), t('User was asked to complete the registration process manually.')); $this->assertRaw(t('The name %name is already taken.', array('%name' => $web_user->name)), t('Form validation error for username was displayed.')); $this->assertRaw(t('The e-mail address %mail is not valid.', array('%mail' => 'mail@invalid#')), t('Form validation error for e-mail address was displayed.')); - $this->assertTrue(variable_get('openid_test_hook_openid_response_response'), t('hook_openid_response() was invoked.')); - $this->assertFalse(variable_get('openid_test_hook_openid_response_account', TRUE), t('No user object passed to hook_openid_response().')); + $this->assertTrue(state()->get('openid_test_hook_openid_response_response') ?: t('hook_openid_response() was invoked.')); + $this->assertFalse(state()->get('openid_test_hook_openid_response_account') ?: TRUE, t('No user object passed to hook_openid_response().')); // Enter username and e-mail address manually. - variable_del('openid_test_hook_openid_response_response'); + state()->del('openid_test_hook_openid_response_response'); $edit = array('name' => 'john', 'mail' => 'john@example.com'); $this->drupalPost(NULL, $edit, t('Create new account')); $this->assertRaw(t('Once you have verified your e-mail address, you may log in via OpenID.'), t('User was asked to verify e-mail address.')); @@ -176,7 +176,7 @@ class OpenIDRegistrationTest extends OpenIDTestBase { // Follow the one-time login that was sent in the welcome e-mail. $this->drupalGet($reset_url); $this->drupalPost(NULL, array(), t('Log in')); - $this->assertFalse(variable_get('openid_test_hook_openid_response_response'), t('hook_openid_response() was not invoked.')); + $this->assertFalse(state()->get('openid_test_hook_openid_response_response') ?: t('hook_openid_response() was not invoked.')); // The user is taken to user/%uid/edit. $this->assertFieldByName('mail', 'john@example.com', t('User was registered with right e-mail address.')); @@ -233,7 +233,7 @@ class OpenIDRegistrationTest extends OpenIDTestBase { variable_set('date_default_timezone', 'Europe/Brussels'); // Tell openid_test.module to respond with these AX fields. - variable_set('openid_test_response', array( + state()->set('openid_test_response', array( 'openid.ns.ext123' => 'http://openid.net/srv/ax/1.0', 'openid.ext123.type.mail456' => 'http://axschema.org/contact/email', 'openid.ext123.value.mail456' => 'john@example.com', diff --git a/core/modules/openid/tests/openid_test.module b/core/modules/openid/tests/openid_test.module index 89f3ddf..f40ad12 100644 --- a/core/modules/openid/tests/openid_test.module +++ b/core/modules/openid/tests/openid_test.module @@ -104,7 +104,7 @@ function openid_test_yadis_xrds() { $output = ' - + xri://@ http://example.com/user @@ -222,12 +222,12 @@ function openid_test_endpoint() { */ function openid_test_redirect($count = 0) { if ($count == 0) { - $url = variable_get('openid_test_redirect_url', ''); + $url = state()->get('openid_test_redirect_url') ?: ''; } else { $url = url('openid-test/redirect/' . --$count, array('absolute' => TRUE)); } - $http_response_code = variable_get('openid_test_redirect_http_reponse_code', 301); + $http_response_code = state()->get('openid_test_redirect_http_reponse_code') ?: 301; return new RedirectResponse($url, $http_response_code); } @@ -299,9 +299,9 @@ function _openid_test_endpoint_associate() { function _openid_test_endpoint_authenticate() { module_load_include('inc', 'openid'); - $expected_identity = variable_get('openid_test_identity'); + $expected_identity = state()->get('openid_test_identity'); if ($expected_identity && $_REQUEST['openid_identity'] != $expected_identity) { - $response = variable_get('openid_test_response', array()) + array( + $response = state()->get('openid_test_response') ?: array() + array( 'openid.ns' => OPENID_NS_2_0, 'openid.mode' => 'error', 'openid.error' => 'Unexpted identity', @@ -313,7 +313,7 @@ function _openid_test_endpoint_authenticate() { $nonce = _openid_nonce(); // Generate response containing the user's identity. - $response = variable_get('openid_test_response', array()) + array( + $response = state()->get('openid_test_response') ?: array() + array( 'openid.ns' => OPENID_NS_2_0, 'openid.mode' => 'id_res', 'openid.op_endpoint' => url('openid-test/endpoint', array('absolute' => TRUE)), @@ -353,7 +353,7 @@ function _openid_test_endpoint_authenticate() { * Implements hook_openid_request_alter(). */ function openid_test_openid_request_alter(&$request, $service) { - $parameters = variable_get('openid_test_request_alter', array()); + $parameters = state()->get('openid_test_request_alter') ?: array(); if (isset($parameters[$request['openid.mode']])) { $request = $parameters[$request['openid.mode']] + $request; } @@ -363,6 +363,6 @@ function openid_test_openid_request_alter(&$request, $service) { * Implements hook_openid_response(). */ function openid_test_openid_response($response, $account) { - variable_set('openid_test_hook_openid_response_response', $response); - variable_set('openid_test_hook_openid_response_account', $account ? $account : FALSE); + state()->set('openid_test_hook_openid_response_response', $response); + state()->set('openid_test_hook_openid_response_account', $account ? $account : FALSE); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.php index 9350243..362b617 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.php @@ -35,8 +35,8 @@ class VariableTest extends WebTestBase { function testVariable() { // Setting and retrieving values. $variable = $this->randomName(); - variable_set('simpletest_bootstrap_variable_test', $variable); - $this->assertIdentical($variable, variable_get('simpletest_bootstrap_variable_test'), t('Setting and retrieving values')); + state()->set('simpletest_bootstrap_variable_test', $variable); + $this->assertIdentical($variable, state()->get('simpletest_bootstrap_variable_test') ?: t('Setting and retrieving values')); // Make sure the variable persists across multiple requests. $this->drupalGet('system-test/variable-get'); @@ -44,8 +44,8 @@ class VariableTest extends WebTestBase { // Deleting variables. $default_value = $this->randomName(); - variable_del('simpletest_bootstrap_variable_test'); - $variable = variable_get('simpletest_bootstrap_variable_test', $default_value); + state()->del('simpletest_bootstrap_variable_test'); + $variable = state()->get('simpletest_bootstrap_variable_test') ?: $default_value; $this->assertIdentical($variable, $default_value, t('Deleting variables')); } @@ -54,10 +54,10 @@ class VariableTest extends WebTestBase { */ function testVariableDefaults() { // Tests passing nothing through to the default. - $this->assertIdentical(NULL, variable_get('simpletest_bootstrap_variable_test'), t('Variables are correctly defaulting to NULL.')); + $this->assertIdentical(NULL, state()->get('simpletest_bootstrap_variable_test'), t('Variables are correctly defaulting to NULL.')); // Tests passing 5 to the default parameter. - $this->assertIdentical(5, variable_get('simpletest_bootstrap_variable_test', 5), t('The default variable parameter is passed through correctly.')); + $this->assertIdentical(5, state()->get('simpletest_bootstrap_variable_test') ?: 5, t('The default variable parameter is passed through correctly.')); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php index 2af085b..aa9155c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php @@ -32,7 +32,8 @@ class EntityApiInfoTest extends WebTestBase { // Change the label of the test entity type and make sure changes appear // after flushing caches. - variable_set('entity_cache_test_label', 'New label.'); + state()->set('entity_cache_test_label', 'New label.'); + $this->resetAll(); $info = entity_get_info('entity_cache_test'); $this->assertEqual($info['label'], 'New label.', 'New label appears in entity info.'); @@ -50,7 +51,7 @@ class EntityApiInfoTest extends WebTestBase { */ function testEntityInfoCacheWatchdog() { module_enable(array('entity_cache_test')); - $info = variable_get('entity_cache_test'); + $info = state()->get('entity_cache_test'); $this->assertEqual($info['label'], 'Entity Cache Test', 'Entity info label is correct.'); $this->assertEqual($info['controller class'], 'Drupal\Core\Entity\DatabaseStorageController', 'Entity controller class info is correct.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index 2036d23..c8075d6 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -37,7 +37,7 @@ class EntityTranslationFormTest extends WebTestBase { function setUp() { parent::setUp(); // Enable translations for the test entity type. - variable_set('entity_test_translation', TRUE); + state()->set('entity_test_translation', TRUE); // Create test languages. $this->langcodes = array(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index 805d52c..4f92f3b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -37,7 +37,7 @@ class EntityTranslationTest extends WebTestBase { function setUp() { parent::setUp(); // Enable translations for the test entity type. - variable_set('entity_test_translation', TRUE); + state()->set('entity_test_translation', TRUE); // Create a translatable test field. $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); diff --git a/core/modules/system/lib/Drupal/system/Tests/File/UrlRewritingTest.php b/core/modules/system/lib/Drupal/system/Tests/File/UrlRewritingTest.php index 5422f90..44dbf2e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/UrlRewritingTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/UrlRewritingTest.php @@ -35,7 +35,7 @@ class UrlRewritingTest extends FileTestBase { // Drupal core, a module or a theme, for example a JavaScript file). // Test alteration of file URLs to use a CDN. - variable_set('file_test_hook_file_url_alter', 'cdn'); + state()->set('file_test_hook_file_url_alter', 'cdn'); $filepath = 'core/misc/jquery.js'; $url = file_create_url($filepath); $this->assertEqual(FILE_URL_TEST_CDN_1 . '/' . $filepath, $url, t('Correctly generated a CDN URL for a shipped file.')); @@ -44,7 +44,7 @@ class UrlRewritingTest extends FileTestBase { $this->assertEqual(FILE_URL_TEST_CDN_2 . '/' . $filepath, $url, t('Correctly generated a CDN URL for a shipped file.')); // Test alteration of file URLs to use root-relative URLs. - variable_set('file_test_hook_file_url_alter', 'root-relative'); + state()->set('file_test_hook_file_url_alter', 'root-relative'); $filepath = 'core/misc/jquery.js'; $url = file_create_url($filepath); $this->assertEqual(base_path() . '/' . $filepath, $url, t('Correctly generated a root-relative URL for a shipped file.')); @@ -53,7 +53,7 @@ class UrlRewritingTest extends FileTestBase { $this->assertEqual(base_path() . '/' . $filepath, $url, t('Correctly generated a root-relative URL for a shipped file.')); // Test alteration of file URLs to use protocol-relative URLs. - variable_set('file_test_hook_file_url_alter', 'protocol-relative'); + state()->set('file_test_hook_file_url_alter', 'protocol-relative'); $filepath = 'core/misc/jquery.js'; $url = file_create_url($filepath); $this->assertEqual('/' . base_path() . '/' . $filepath, $url, t('Correctly generated a protocol-relative URL for a shipped file.')); @@ -69,20 +69,20 @@ class UrlRewritingTest extends FileTestBase { // Test generating an URL to a created file. // Test alteration of file URLs to use a CDN. - variable_set('file_test_hook_file_url_alter', 'cdn'); + state()->set('file_test_hook_file_url_alter', 'cdn'); $uri = $this->createUri(); $url = file_create_url($uri); $public_directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(); $this->assertEqual(FILE_URL_TEST_CDN_2 . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, t('Correctly generated a CDN URL for a created file.')); // Test alteration of file URLs to use root-relative URLs. - variable_set('file_test_hook_file_url_alter', 'root-relative'); + state()->set('file_test_hook_file_url_alter', 'root-relative'); $uri = $this->createUri(); $url = file_create_url($uri); $this->assertEqual(base_path() . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, t('Correctly generated a root-relative URL for a created file.')); // Test alteration of file URLs to use a protocol-relative URLs. - variable_set('file_test_hook_file_url_alter', 'protocol-relative'); + state()->set('file_test_hook_file_url_alter', 'protocol-relative'); $uri = $this->createUri(); $url = file_create_url($uri); $this->assertEqual('/' . base_path() . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, t('Correctly generated a protocol-relative URL for a created file.')); diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php index 42e81b1..1320848 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php @@ -225,7 +225,7 @@ class RouterTest extends WebTestBase { function testHookCustomTheme() { // Trigger hook_custom_theme() to dynamically request the Stark theme for // the requested page. - variable_set('menu_test_hook_custom_theme_name', 'stark'); + state()->set('menu_test_hook_custom_theme_name', 'stark'); theme_enable(array('stark', 'seven')); // Visit a page that does not implement a theme callback. The above request @@ -241,7 +241,7 @@ class RouterTest extends WebTestBase { function testThemeCallbackHookCustomTheme() { // Trigger hook_custom_theme() to dynamically request the Stark theme for // the requested page. - variable_set('menu_test_hook_custom_theme_name', 'stark'); + state()->set('menu_test_hook_custom_theme_name', 'stark'); theme_enable(array('stark', 'seven')); // The menu "theme callback" should take precedence over a value set in diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php index cf96b86..9ddd75e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php @@ -88,12 +88,12 @@ class TrailTest extends MenuTestBase { ); // Test the tree generation for the Navigation menu. - variable_del('menu_test_menu_tree_set_path'); + state()->del('menu_test_menu_tree_set_path'); $this->assertBreadcrumb('menu-test/menu-trail', $breadcrumb, t('Menu trail - Case 1'), $tree); // Override the active trail for the Management tree; it should not affect // the Navigation tree. - variable_set('menu_test_menu_tree_set_path', $test_menu_path); + state()->set('menu_test_menu_tree_set_path', $test_menu_path); $this->assertBreadcrumb('menu-test/menu-trail', $breadcrumb, t('Menu trail - Case 1'), $tree); $breadcrumb = $config + array( @@ -114,12 +114,12 @@ class TrailTest extends MenuTestBase { ); // Test the tree generation for the Management menu. - variable_del('menu_test_menu_tree_set_path'); + state()->del('menu_test_menu_tree_set_path'); $this->assertBreadcrumb('admin/config/development/menu-trail', $breadcrumb, t('Menu trail - Case 2'), $tree); // Override the active trail for the Management tree; it should affect the // breadcrumbs and Management tree. - variable_set('menu_test_menu_tree_set_path', $test_menu_path); + state()->set('menu_test_menu_tree_set_path', $test_menu_path); $this->assertBreadcrumb('admin/config/development/menu-trail', $override_breadcrumb, t('Menu trail - Case 2'), $override_tree); } @@ -171,13 +171,13 @@ class TrailTest extends MenuTestBase { foreach (array(403, 404) as $status_code) { // Before visiting the page, trigger the code in the menu_test module // that will record the active trail (so we can check it in this test). - variable_set('menu_test_record_active_trail', TRUE); + state()->set('menu_test_record_active_trail', TRUE); $this->drupalGet($paths[$status_code]); $this->assertResponse($status_code); // Check that the initial trail (during the Drupal bootstrap) matches // what we expect. - $initial_trail = variable_get('menu_test_active_trail_initial', array()); + $initial_trail = state()->get('menu_test_active_trail_initial') ?: array(); $this->assertEqual(count($initial_trail), count($expected_trail[$status_code]['initial']), t('The initial active trail for a @status_code page contains the expected number of items (expected: @expected, found: @found).', array( '@status_code' => $status_code, '@expected' => count($expected_trail[$status_code]['initial']), diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php index 7e0c5e9..a3a454e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php @@ -132,7 +132,7 @@ class DependencyTest extends ModuleTestBase { module_enable(array('module_test'), FALSE); $this->resetAll(); $this->assertModules(array('module_test'), TRUE); - variable_set('dependency_test', 'dependency'); + state()->set('dependency_test', 'dependency'); // module_test creates a dependency chain: // - forum depends on taxonomy, comment, and poll (via module_test) // - taxonomy depends on options @@ -156,7 +156,7 @@ class DependencyTest extends ModuleTestBase { $this->assertModules(array('forum', 'poll', 'php', 'comment', 'taxonomy', 'options'), TRUE); // Check the actual order which is saved by module_test_modules_enabled(). - $this->assertIdentical(variable_get('test_module_enable_order', array()), $expected_order); + $this->assertIdentical(state()->get('test_module_enable_order') ?: array(), $expected_order); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php index 8afe33b..5613971 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php @@ -60,7 +60,7 @@ class EnableDisableTest extends ModuleTestBase { // Set a variable so that the hook implementations in system_test.module // will display messages via drupal_set_message(). - variable_set('test_verbose_module_hooks', TRUE); + state()->set('test_verbose_module_hooks', TRUE); // Go through each module in the list and try to enable it (unless it was // already enabled automatically due to a dependency). diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php index 8468185..fcc6134 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php @@ -1,4 +1,4 @@ -set('dependency_test', 'missing dependency'); drupal_static_reset('system_rebuild_module_data'); $result = module_enable(array('forum')); $this->assertFalse($result, t('module_enable() returns FALSE if dependencies are missing.')); @@ -171,7 +171,7 @@ class ModuleApiTest extends WebTestBase { // Now, fix the missing dependency. Forum module depends on poll, but poll // depends on the PHP module. module_enable() should work. - variable_set('dependency_test', 'dependency'); + state()->set('dependency_test', 'dependency'); drupal_static_reset('system_rebuild_module_data'); $result = module_enable(array('forum')); $this->assertTrue($result, t('module_enable() returns the correct value.')); @@ -180,7 +180,7 @@ class ModuleApiTest extends WebTestBase { // Verify that the original module was installed. $this->assertTrue(module_exists('forum'), t('Module installation with unlisted dependencies succeeded.')); // Finally, verify that the modules were enabled in the correct order. - $this->assertEqual(variable_get('test_module_enable_order', array()), array('php', 'poll', 'forum'), t('Modules were enabled in the correct order by module_enable().')); + $this->assertEqual(state()->get('test_module_enable_order') ?: array(), array('php', 'poll', 'forum'), t('Modules were enabled in the correct order by module_enable().')); // Now, disable the PHP module. Both forum and poll should be disabled as // well, in the correct order. @@ -234,7 +234,7 @@ class ModuleApiTest extends WebTestBase { // php module. But, this time do it with poll module declaring a dependency // on a specific version of php module in its info file. Make sure that // module_enable() still works. - variable_set('dependency_test', 'version dependency'); + state()->set('dependency_test', 'version dependency'); drupal_static_reset('system_rebuild_module_data'); $result = module_enable(array('forum')); $this->assertTrue($result, t('module_enable() returns the correct value.')); @@ -243,7 +243,7 @@ class ModuleApiTest extends WebTestBase { // Verify that the original module was installed. $this->assertTrue(module_exists('forum'), t('Module installation with version dependencies succeeded.')); // Finally, verify that the modules were enabled in the correct order. - $enable_order = variable_get('test_module_enable_order', array()); + $enable_order = state()->get('test_module_enable_order') ?: array(); $php_position = array_search('php', $enable_order); $poll_position = array_search('poll', $enable_order); $forum_position = array_search('forum', $enable_order); diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php index e328712..1610448 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php @@ -62,7 +62,7 @@ class VersionTest extends ModuleTestBase { // Testing extra version. Incompatible. 'common_test (>2.4-rc0)', ); - variable_set('dependencies', $dependencies); + state()->set('dependencies', $dependencies); $n = count($dependencies); for ($i = 0; $i < $n; $i++) { $this->drupalGet('admin/modules'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/SaveTest.php b/core/modules/system/lib/Drupal/system/Tests/Path/SaveTest.php index f017230..ab92631 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Path/SaveTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Path/SaveTest.php @@ -56,7 +56,7 @@ class SaveTest extends WebTestBase { // Test to see if the original alias is available to modules during // hook_path_update(). - $results = variable_get('path_test_results', array()); + $results = state()->get('path_test_results') ?: array(); $this->assertIdentical($results['hook_path_update']['original']['alias'], $path_original['alias'], t('Old path alias available to modules during hook_path_update.')); $this->assertIdentical($results['hook_path_update']['original']['source'], $path_original['source'], t('Old path alias available to modules during hook_path_update.')); } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php index ebdb103..09d53d5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php @@ -90,12 +90,12 @@ class CronRunTest extends WebTestBase { * Make sure exceptions thrown on hook_cron() don't affect other modules. */ function testCronExceptions() { - variable_del('common_test_cron'); + state()->del('common_test_cron'); // The common_test module throws an exception. If it isn't caught, the tests // won't finish successfully. // The common_test_cron_helper module sets the 'common_test_cron' variable. $this->cronRun(); - $result = variable_get('common_test_cron'); + $result = state()->get('common_test_cron'); $this->assertEqual($result, 'success', t('Cron correctly handles exceptions thrown during hook_cron() invocations.')); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php b/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php index d620cce..e730a4e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php @@ -40,7 +40,7 @@ class FrontPageTest extends WebTestBase { // Configure 'node' as front page. config('system.site')->set('page.front', 'node')->save(); // Enable front page logging in system_test.module. - variable_set('front_page_output', 1); + state()->set('front_page_output', 1); } /** diff --git a/core/modules/system/tests/modules/batch_test/batch_test.module b/core/modules/system/tests/modules/batch_test/batch_test.module index 1200e76..e8c7e39 100644 --- a/core/modules/system/tests/modules/batch_test/batch_test.module +++ b/core/modules/system/tests/modules/batch_test/batch_test.module @@ -502,12 +502,12 @@ function _batch_test_theme_callback() { */ function batch_test_stack($data = NULL, $reset = FALSE) { if ($reset) { - variable_del('batch_test_stack'); + state()->delete('batch_test_stack'); } if (!isset($data)) { - return variable_get('batch_test_stack', array()); + return state()->get('batch_test_stack') ?: array(); } - $stack = variable_get('batch_test_stack', array()); + $stack = state()->get('batch_test_stack') ?: array(); $stack[] = $data; - variable_set('batch_test_stack', $stack); + state()->set('batch_test_stack', $stack); } diff --git a/core/modules/system/tests/modules/common_test_cron_helper/common_test_cron_helper.module b/core/modules/system/tests/modules/common_test_cron_helper/common_test_cron_helper.module index 94a2b2c..2a8100f 100644 --- a/core/modules/system/tests/modules/common_test_cron_helper/common_test_cron_helper.module +++ b/core/modules/system/tests/modules/common_test_cron_helper/common_test_cron_helper.module @@ -13,5 +13,5 @@ * @see common_test_cron() */ function common_test_cron_helper_cron() { - variable_set('common_test_cron', 'success'); + state()->set('common_test_cron', 'success'); } diff --git a/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module b/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module index 5ae9ecc..ed60fe8 100644 --- a/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module +++ b/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module @@ -22,6 +22,6 @@ function entity_cache_test_watchdog($log_entry) { $info = entity_get_info('entity_cache_test'); // Store the information in a system variable to analyze it later in the // test case. - variable_set('entity_cache_test', $info); + state()->set('entity_cache_test', $info); } } diff --git a/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module b/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module index 2d4b3be..16a452d 100644 --- a/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module +++ b/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module @@ -11,7 +11,7 @@ function entity_cache_test_dependency_entity_info() { return array( 'entity_cache_test' => array( - 'label' => variable_get('entity_cache_test_label', 'Entity Cache Test'), + 'label' => state()->get('entity_cache_test_label') ?: 'Entity Cache Test', ), ); } diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index d2dc67e..cf4037e 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -24,7 +24,7 @@ function entity_test_entity_info() { ), ); // Optionally specify a translation handler for testing translations. - if (variable_get('entity_test_translation')) { + if (state()->get('entity_test_translation')) { $items['entity_test']['translation']['entity_test'] = TRUE; } return $items; diff --git a/core/modules/system/tests/modules/image_test/image_test.module b/core/modules/system/tests/modules/image_test/image_test.module index de640f0..10e93fa 100644 --- a/core/modules/system/tests/modules/image_test/image_test.module +++ b/core/modules/system/tests/modules/image_test/image_test.module @@ -37,7 +37,7 @@ function image_test_reset() { 'crop' => array(), 'desaturate' => array(), ); - variable_set('image_test_results', $results); + state()->set('image_test_results', $results); } /** @@ -50,7 +50,7 @@ function image_test_reset() { * passed to each call. */ function image_test_get_all_calls() { - return variable_get('image_test_results', array()); + return state()->get('image_test_results') ?: array(); } /** @@ -66,9 +66,9 @@ function image_test_get_all_calls() { * @see image_test_reset() */ function _image_test_log_call($op, $args) { - $results = variable_get('image_test_results', array()); + $results = state()->get('image_test_results') ?: array(); $results[$op][] = $args; - variable_set('image_test_results', $results); + state->set('image_test_results', $results); } /** diff --git a/core/modules/system/tests/modules/menu_test/menu_test.module b/core/modules/system/tests/modules/menu_test/menu_test.module index 8f24a4f..974bf15 100644 --- a/core/modules/system/tests/modules/menu_test/menu_test.module +++ b/core/modules/system/tests/modules/menu_test/menu_test.module @@ -394,7 +394,7 @@ function menu_test_callback() { * Callback that test menu_test_menu_tree_set_path(). */ function menu_test_menu_trail_callback() { - $menu_path = variable_get('menu_test_menu_tree_set_path', array()); + $menu_path = state()->get('menu_test_menu_tree_set_path') ?: array(); if (!empty($menu_path)) { menu_tree_set_path($menu_path['menu_name'], $menu_path['path']); } @@ -408,8 +408,8 @@ function menu_test_init() { // When requested by one of the MenuTrailTestCase tests, record the initial // active trail during Drupal's bootstrap (before the user is redirected to a // custom 403 or 404 page). See menu_test_custom_403_404_callback(). - if (variable_get('menu_test_record_active_trail', FALSE)) { - variable_set('menu_test_active_trail_initial', menu_get_active_trail()); + if (state()->get('menu_test_record_active_trail')) { + state()->set('menu_test_active_trail_initial', menu_get_active_trail()); } } @@ -420,7 +420,7 @@ function menu_test_custom_403_404_callback() { // When requested by one of the MenuTrailTestCase tests, record the final // active trail now that the user has been redirected to the custom 403 or // 404 page. See menu_test_init(). - if (variable_get('menu_test_record_active_trail', FALSE)) { + if (state()->get('menu_test_record_active_trail')) { variable_set('menu_test_active_trail_final', menu_get_active_trail()); } @@ -487,7 +487,7 @@ function menu_test_custom_theme() { // If an appropriate variable has been set in the database, request the theme // that is stored there. Otherwise, do not attempt to dynamically set the // theme. - if ($theme = variable_get('menu_test_hook_custom_theme_name', FALSE)) { + if ($theme = state()->get('menu_test_hook_custom_theme_name')) { return $theme; } } diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module index 69e5bfe..81dcc52 100644 --- a/core/modules/system/tests/modules/module_test/module_test.module +++ b/core/modules/system/tests/modules/module_test/module_test.module @@ -15,7 +15,7 @@ function module_test_permission() { * Manipulate module dependencies to test dependency chains. */ function module_test_system_info_alter(&$info, $file, $type) { - if (variable_get('dependency_test', FALSE) == 'missing dependency') { + if (state()->get('dependency_test')) == 'missing dependency') { if ($file->name == 'forum') { // Make forum module depend on poll. $info['dependencies'][] = 'poll'; @@ -25,7 +25,7 @@ function module_test_system_info_alter(&$info, $file, $type) { $info['dependencies'][] = 'foo'; } } - elseif (variable_get('dependency_test', FALSE) == 'dependency') { + elseif (state()->get('dependency_test')) == 'dependency') { if ($file->name == 'forum') { // Make the forum module depend on poll. $info['dependencies'][] = 'poll'; @@ -35,7 +35,7 @@ function module_test_system_info_alter(&$info, $file, $type) { $info['dependencies'][] = 'php'; } } - elseif (variable_get('dependency_test', FALSE) == 'version dependency') { + elseif (state()->get('dependency_test')) == 'version dependency') { if ($file->name == 'forum') { // Make the forum module depend on poll. $info['dependencies'][] = 'poll'; @@ -155,7 +155,7 @@ function module_test_class_loading() { function module_test_modules_enabled($modules) { // Record the ordered list of modules that were passed in to this hook so we // can check that the modules were enabled in the correct sequence. - variable_set('test_module_enable_order', $modules); + state()->set('test_module_enable_order', $modules); } /** diff --git a/core/modules/system/tests/modules/path_test/path_test.module b/core/modules/system/tests/modules/path_test/path_test.module index 0111675..d5c1133 100644 --- a/core/modules/system/tests/modules/path_test/path_test.module +++ b/core/modules/system/tests/modules/path_test/path_test.module @@ -9,14 +9,14 @@ * Resets the path test results. */ function path_test_reset() { - variable_set('path_test_results', array()); + state()->set('path_test_results', array()); } /** * Implements hook_path_update(). */ function path_test_path_update($path) { - $results = variable_get('path_test_results', array()); + $results = state()->get('path_test_results') ?: array(); $results['hook_path_update'] = $path; - variable_set('path_test_results', $results); + state()->set('path_test_results', $results); } 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 4949aec..9124573 100644 --- a/core/modules/system/tests/modules/system_test/system_test.module +++ b/core/modules/system/tests/modules/system_test/system_test.module @@ -177,7 +177,7 @@ function system_test_redirect_invalid_scheme() { * Implements hook_modules_installed(). */ function system_test_modules_installed($modules) { - if (variable_get('test_verbose_module_hooks')) { + if (state()->get('test_verbose_module_hooks')) { foreach ($modules as $module) { drupal_set_message(t('hook_modules_installed fired for @module', array('@module' => $module))); } @@ -188,7 +188,7 @@ function system_test_modules_installed($modules) { * Implements hook_modules_enabled(). */ function system_test_modules_enabled($modules) { - if (variable_get('test_verbose_module_hooks')) { + if (state()->get('test_verbose_module_hooks')) { foreach ($modules as $module) { drupal_set_message(t('hook_modules_enabled fired for @module', array('@module' => $module))); } @@ -199,7 +199,7 @@ function system_test_modules_enabled($modules) { * Implements hook_modules_disabled(). */ function system_test_modules_disabled($modules) { - if (variable_get('test_verbose_module_hooks')) { + if (state()->get('test_verbose_module_hooks')) { foreach ($modules as $module) { drupal_set_message(t('hook_modules_disabled fired for @module', array('@module' => $module))); } @@ -210,7 +210,7 @@ function system_test_modules_disabled($modules) { * Implements hook_modules_uninstalled(). */ function system_test_modules_uninstalled($modules) { - if (variable_get('test_verbose_module_hooks')) { + if (state()->get('test_verbose_module_hooks')) { foreach ($modules as $module) { drupal_set_message(t('hook_modules_uninstalled fired for @module', array('@module' => $module))); } @@ -229,7 +229,7 @@ function system_test_boot() { */ function system_test_init() { // Used by FrontPageTestCase to get the results of drupal_is_front_page(). - if (variable_get('front_page_output', 0) && drupal_is_front_page()) { + if (state()->get('front_page_output') && drupal_is_front_page()) { drupal_set_message(t('On front page.')); } } @@ -247,11 +247,11 @@ function system_test_exit() { function system_test_system_info_alter(&$info, $file, $type) { // We need a static otherwise the last test will fail to alter common_test. static $test; - if (($dependencies = variable_get('dependencies', array())) || $test) { + if (($dependencies = state()->get('dependencies') ?: array())) || $test) { if ($file->name == 'module_test') { $info['hidden'] = FALSE; $info['dependencies'][] = array_shift($dependencies); - variable_set('dependencies', $dependencies); + state()->set('dependencies', $dependencies); $test = TRUE; } if ($file->name == 'common_test') { diff --git a/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php b/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php index 572cd18..7c5748f 100644 --- a/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php +++ b/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php @@ -48,12 +48,12 @@ class XmlRpcMessagesTest extends WebTestBase { */ protected function testAlterListMethods() { // Ensure xmlrpc_test_xmlrpc_alter() is disabled and retrieve regular list of methods. - variable_set('xmlrpc_test_xmlrpc_alter', FALSE); + state()->set('xmlrpc_test_xmlrpc_alter', FALSE); $url = url('xmlrpc.php', array('absolute' => TRUE)); $methods1 = xmlrpc($url, array('system.listMethods' => array())); // Enable the alter hook and retrieve the list of methods again. - variable_set('xmlrpc_test_xmlrpc_alter', TRUE); + state()->set('xmlrpc_test_xmlrpc_alter', TRUE); $methods2 = xmlrpc($url, array('system.listMethods' => array())); $diff = array_diff($methods1, $methods2); diff --git a/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module b/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module index db8f113..b2ada57 100644 --- a/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module +++ b/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module @@ -68,7 +68,7 @@ function xmlrpc_test_xmlrpc() { * Hide (or not) the system.methodSignature() service depending on a variable. */ function xmlrpc_test_xmlrpc_alter(&$services) { - if (variable_get('xmlrpc_test_xmlrpc_alter', FALSE)) { + if (state()->get('xmlrpc_test_xmlrpc_alter')) { $remove = NULL; foreach ($services as $key => $value) { if (!is_array($value)) {