Subissue of #1787218: Convert testing variables to state system..
Change the state variables:
front_page_output
image_test_results
path_test_results
simpletest_bootstrap_variable_test
test_module_enable_order
test_verbose_module_hooks
to the state system.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ACF’s picture

Patch attached.

ACF’s picture

Status: Active » Needs review
gdd’s picture

Status: Needs review » Needs work
+++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.phpundefined
@@ -35,8 +35,8 @@ public static function getInfo() {
-    variable_set('simpletest_bootstrap_variable_test', $variable);
-    $this->assertIdentical($variable, variable_get('simpletest_bootstrap_variable_test'), 'Setting and retrieving values');
+    state()->set('system_test.bootstrap_variable_test', $variable);
+    $this->assertIdentical($variable, state()->get('system_test.bootstrap_variable_test'), 'Setting and retrieving values');

@@ -44,8 +44,8 @@ function testVariable() {
-    variable_del('simpletest_bootstrap_variable_test');
-    $variable = variable_get('simpletest_bootstrap_variable_test', $default_value);
+    state()->delete('system_test.bootstrap_variable_test');
+    $variable = state()->get('system_test.bootstrap_variable_test', $default_value);
     $this->assertIdentical($variable, $default_value, 'Deleting variables');

@@ -54,10 +54,10 @@ function testVariable() {
-    $this->assertIdentical(NULL, variable_get('simpletest_bootstrap_variable_test'), 'Variables are correctly defaulting to NULL.');
+    $this->assertIdentical(NULL, state()->get('system_test.bootstrap_variable_test'), 'Variables are correctly defaulting to NULL.');
 
     // Tests passing 5 to the default parameter.
-    $this->assertIdentical(5, variable_get('simpletest_bootstrap_variable_test', 5), 'The default variable parameter is passed through correctly.');
+    $this->assertIdentical(5, state()->get('system_test.bootstrap_variable_test') ?: 5, 'The default variable parameter is passed through correctly.');

We shouldn't actually convert the variable tests. These are specifically to test the variable system and make no sense if converted to the state system. If the variable system does get removed we'll just delete all these tests. I'll remove these from the meta-issue.

+++ b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.phpundefined
@@ -157,7 +157,7 @@ function testModuleEnableOrder() {
-    $this->assertIdentical(variable_get('test_module_enable_order', array()), $expected_order);
+    $this->assertIdentical(state()->get('system_test.module_enable_order'), $expected_order);

All implementations of state()->get() in this patch need to specify a default by doing something along the lines of state()->get('system_test.module_enable_order') ?: array()

+++ b/core/modules/system/tests/modules/system_test/system_test.moduleundefined
@@ -58,8 +58,8 @@ function system_test_menu() {
-    'page callback' => 'variable_get',
-    'page arguments' => array('simpletest_bootstrap_variable_test', NULL),
+    'page callback' => 'state()->get',
+    'page arguments' => array('system_test.bootstrap_variable_test'),

Don't worry about this because state()->get() already returns NULL when the key doesn't exist.

ACF’s picture

Status: Needs work » Needs review
FileSize
9.36 KB

Removed the changes to variable.test and added the defaults.

Status: Needs review » Needs work

The last submitted patch, 1848058-system_to_state-drupal8-4.patch, failed testing.

ACF’s picture

Status: Needs work » Needs review
FileSize
8.93 KB

Remove last link to variable test.

aspilicious’s picture

Status: Needs review » Reviewed & tested by the community

Looks great passes tests

webchick’s picture

Category: feature » task
Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

added issue number