function ConfigCRUDTest::testTrustedDataDeprecation

Same name and namespace in other branches
  1. main core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php \Drupal\KernelTests\Core\Config\ConfigCRUDTest::testTrustedDataDeprecation()

Tests deprecation of trusted data.

@legacy-covers \Drupal\Core\Config\Config::save()

Attributes

#[IgnoreDeprecations]

File

core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php, line 347

Class

ConfigCRUDTest
Tests CRUD operations on configuration objects.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testTrustedDataDeprecation() : void {
  $this->expectUserDeprecationMessage('Calling Drupal\\Core\\Config\\Config::save() with the $has_trusted_data argument is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. There is no replacement. See https://www.drupal.org/node/3348180');
  \Drupal::service('module_installer')->install([
    'config_test',
  ]);
  $name = 'config_test.types';
  $config = $this->config($name);
  // Test that schema type enforcement can be overridden by trusting the data.
  $this->assertSame(99, $config->get('int'));
  $config->set('int', '99')
    ->save(TRUE);
  $this->assertSame('99', $config->get('int'));
  // Test that re-saving without testing the data enforces the schema type.
  $config->save();
  $this->assertSame(99, $config->get('int'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.