You are here

public function YamlSymfonyTest::testObjectSupportDisabled in Drupal 8

Same name and namespace in other branches
  1. 9 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 71

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,
  ]);
}