function YamlSymfonyTest::testObjectSupportDisabled

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php \Drupal\Tests\Component\Serialization\YamlSymfonyTest::testObjectSupportDisabled()

Ensures that php object support is disabled.

@covers ::encode

File

core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php, line 73

Class

YamlSymfonyTest
Tests the YamlSymfony serialization implementation.

Namespace

Drupal\Tests\Component\Serialization

Code

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

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