public function ConfigTest::testSafeStringHandling in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::testSafeStringHandling()
- 10 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest::testSafeStringHandling()
@covers ::setData @covers ::set @covers ::initWithData
File
- core/
tests/ Drupal/ Tests/ Core/ Config/ ConfigTest.php, line 607
Class
- ConfigTest
- Tests the Config.
Namespace
Drupal\Tests\Core\ConfigCode
public function testSafeStringHandling() {
// 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'));
}