You are here

public function YamlTest::testGetSerialization in Drupal 10

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Serialization/YamlTest.php \Drupal\Tests\Core\Serialization\YamlTest::testGetSerialization()

Tests that the overridden serializer is called.

@covers ::getSerializer @runInSeparateProcess

File

core/tests/Drupal/Tests/Core/Serialization/YamlTest.php, line 22

Class

YamlTest
@coversDefaultClass \Drupal\Core\Serialization\Yaml @group Serialization

Namespace

Drupal\Tests\Core\Serialization

Code

public function testGetSerialization() {
  new Settings([
    'yaml_parser_class' => YamlParserProxy::class,
  ]);
  $this
    ->assertEquals(YamlParserProxy::class, Settings::get('yaml_parser_class'));
  $mock = $this
    ->getMockBuilder('\\stdClass')
    ->addMethods([
    'encode',
    'decode',
    'getFileExtension',
  ])
    ->getMock();
  $mock
    ->expects($this
    ->once())
    ->method('decode');
  YamlParserProxy::setMock($mock);
  Yaml::decode('---');
  new Settings([]);
}