class YamlTest

Same name in this branch
  1. 9 core/tests/Drupal/Tests/Component/Serialization/YamlTest.php \Drupal\Tests\Component\Serialization\YamlTest
Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Component/Serialization/YamlTest.php \Drupal\Tests\Component\Serialization\YamlTest
  2. 10 core/tests/Drupal/Tests/Component/Serialization/YamlTest.php \Drupal\Tests\Component\Serialization\YamlTest
  3. 8.9.x core/tests/Drupal/Tests/Core/Serialization/YamlTest.php \Drupal\Tests\Core\Serialization\YamlTest
  4. 8.9.x core/tests/Drupal/Tests/Component/Serialization/YamlTest.php \Drupal\Tests\Component\Serialization\YamlTest

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

Hierarchy

Expanded class hierarchy of YamlTest

File

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

Namespace

Drupal\Tests\Core\Serialization
View source
class YamlTest extends UnitTestCase {
  
  /**
   * Tests that the overridden serializer is called.
   *
   * @covers ::getSerializer
   * @runInSeparateProcess
   */
  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([]);
  }

}

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