function ConfigTest::testSafeStringHandling
@covers ::setData
      
    
@covers ::set
      
    
@covers ::initWithData
      
    
File
- 
              core/
tests/ Drupal/ Tests/ Core/ Config/ ConfigTest.php, line 618  
Class
- ConfigTest
 - Tests the Config.
 
Namespace
Drupal\Tests\Core\ConfigCode
public function testSafeStringHandling() : void {
  // Safe strings are cast when using ::set().
  $safe_string = Markup::create('bar');
  $this->config
    ->set('foo', $safe_string);
  $this->assertSame('bar', $this->config
    ->get('foo'));
  $this->config
    ->set('foo', [
    'bar' => $safe_string,
  ]);
  $this->assertSame('bar', $this->config
    ->get('foo.bar'));
  // Safe strings are cast when using ::setData().
  $this->config
    ->setData([
    'bar' => $safe_string,
  ]);
  $this->assertSame('bar', $this->config
    ->get('bar'));
  // Safe strings are not cast when using ::initWithData().
  $this->config
    ->initWithData([
    'bar' => $safe_string,
  ]);
  $this->assertSame($safe_string, $this->config
    ->get('bar'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.