function SimpleConfigLangcodeTest::testLangcodesAddedToSimpleConfig
Tests that langcodes are added to simple config objects that need them.
File
- 
              core/
modules/ system/ tests/ src/ Functional/ Update/ SimpleConfigLangcodeTest.php, line 29  
Class
- SimpleConfigLangcodeTest
 - @group system @group Update @covers system_post_update_add_langcode_to_all_translatable_config[[api-linebreak]]
 
Namespace
Drupal\Tests\system\Functional\UpdateCode
public function testLangcodesAddedToSimpleConfig() : void {
  /** @var \Drupal\Core\Database\Connection $database */
  $database = $this->container
    ->get(Connection::class);
  // Remove the langcode from `user.mail`, which has translatable values; it
  // should be restored by the update path. We need to change it in the
  // database directly, to avoid running afoul of config validation.
  $data = $this->config('user.mail')
    ->clear('langcode')
    ->getRawData();
  $database->update('config')
    ->fields([
    'data' => serialize($data),
  ])
    ->condition('name', 'user.mail')
    ->execute();
  // Add a langcode to `node.settings`, which has no translatable values; it
  // should be removed by the update path. We need to change it in the
  // database directly, to avoid running afoul of config validation.
  $data = $this->config('node.settings')
    ->set('langcode', 'en')
    ->getRawData();
  $database->update('config')
    ->fields([
    'data' => serialize($data),
  ])
    ->condition('name', 'node.settings')
    ->execute();
  $this->runUpdates();
  $this->assertSame('en', $this->config('user.mail')
    ->get('langcode'));
  $this->assertArrayNotHasKey('langcode', $this->config('node.settings')
    ->getRawData());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.