function YamlTest::testEncodeObjectSupportDisabled

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Component/Serialization/YamlTest.php \Drupal\Tests\Component\Serialization\YamlTest::testEncodeObjectSupportDisabled()

Ensures that php object support is disabled.

@covers ::encode

File

core/tests/Drupal/Tests/Component/Serialization/YamlTest.php, line 75

Class

YamlTest
Tests the Yaml serialization implementation.

Namespace

Drupal\Tests\Component\Serialization

Code

public function testEncodeObjectSupportDisabled() : void {
  $this->expectException(InvalidDataTypeException::class);
  $this->expectExceptionMessage('Object support when dumping a YAML file has been disabled.');
  $object = new \stdClass();
  $object->foo = 'bar';
  Yaml::encode([
    $object,
  ]);
}

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