Skip to main content
Rollback to Revision 1
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

As commented, you were missing the save call in the test.

That means that the change is only in the runtime object returned by getEditable()getEditable() and since get()get() and getEditable()getEditable() do not share the static cache, you didn't see the change.

The correct code:

function testCron() {
  $config = \Drupal::service('config.factory')->getEditable('mymodule.settings');
  $config
    ->set('some_setting', 'some value')
    ->set('another_setting', 'another value')
    ->save();
  \Drupal::service('cron')->run();
}

As commented, you were missing the save call in the test.

That means that the change is only in the runtime object returned by getEditable() and since get() and getEditable() do not share the static cache, you didn't see the change.

The correct code:

function testCron() {
  $config = \Drupal::service('config.factory')->getEditable('mymodule.settings');
  $config
    ->set('some_setting', 'some value')
    ->set('another_setting', 'another value')
    ->save();
  \Drupal::service('cron')->run();
}

As commented, you were missing the save call in the test.

That means that the change is only in the runtime object returned by getEditable() and since get() and getEditable() do not share the static cache, you didn't see the change.

Adds the code, highlight, coding standards
Source Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

As commented, you were missing the save call in the test.

That means that the change is only in the runtime object returned by getEditable()getEditable() and since get()get() and getEditable()getEditable() do not share the static cache, you didn't see the change.

The correct code:

function testCron()
  {
    $config = \Drupal::service('config.factory')->getEditable('mymodule.settings');
    $config
        ->set('some_setting', 'some value')
        ->set('another_setting', 'another value')
        ->save();
    \Drupal::service('cron')->run();
}

As commented, you were missing the save call in the test.

That means that the change is only in the runtime object returned by getEditable() and since get() and getEditable() do not share the static cache, you didn't see the change.

The correct code:

function testCron()
 {
    $config = \Drupal::service('config.factory')->getEditable('mymodule.settings');
    $config
        ->set('some_setting', 'some value')
        ->set('another_setting', 'another value')
        ->save();
    \Drupal::service('cron')->run();
}

As commented, you were missing the save call in the test.

That means that the change is only in the runtime object returned by getEditable() and since get() and getEditable() do not share the static cache, you didn't see the change.

The correct code:

function testCron() {
  $config = \Drupal::service('config.factory')->getEditable('mymodule.settings');
  $config
    ->set('some_setting', 'some value')
    ->set('another_setting', 'another value')
    ->save();
  \Drupal::service('cron')->run();
}

As commented, you were missing the save call in the test.

That means that the change is only in the runtime object returned by getEditable() and since get() and getEditable() do not share the static cache, you didn't see the change.

The correct code:

function testCron()
{
    $config = \Drupal::service('config.factory')->getEditable('mymodule.settings');
    $config
        ->set('some_setting', 'some value')
        ->set('another_setting', 'another value')
        ->save();
    \Drupal::service('cron')->run();
}

As commented, you were missing the save call in the test.

That means that the change is only in the runtime object returned by getEditable() and since get() and getEditable() do not share the static cache, you didn't see the change.

As commented, you were missing the save call in the test.

That means that the change is only in the runtime object returned by getEditable() and since get() and getEditable() do not share the static cache, you didn't see the change.

The correct code:

function testCron()
{
    $config = \Drupal::service('config.factory')->getEditable('mymodule.settings');
    $config
        ->set('some_setting', 'some value')
        ->set('another_setting', 'another value')
        ->save();
    \Drupal::service('cron')->run();
}
Source Link
Berdir
  • 83.5k
  • 6
  • 161
  • 207
Loading