YamlTest.php in Zircon Profile 8.0
File
core/tests/Drupal/Tests/Component/Serialization/YamlTest.php
View source
<?php
namespace Drupal\Tests\Component\Serialization;
use Drupal\Component\Serialization\Yaml;
use Drupal\Tests\UnitTestCase;
class YamlTest extends UnitTestCase {
public function testDecode() {
$yaml = 'foo: bar';
$expected = array(
'foo' => 'bar',
);
$this
->assertSame($expected, Yaml::decode($yaml));
$yaml .= "\n";
$this
->assertSame($expected, Yaml::decode($yaml));
$yaml .= "\n";
$this
->assertSame($expected, Yaml::decode($yaml));
$yaml = "{}\n";
$expected = array();
$this
->assertSame($expected, Yaml::decode($yaml));
$yaml = '';
$this
->assertNULL(Yaml::decode($yaml));
$yaml .= "\n";
$this
->assertNULL(Yaml::decode($yaml));
$yaml .= "\n";
$this
->assertNULL(Yaml::decode($yaml));
}
public function testEncode() {
$decoded = array(
'foo' => 'bar',
);
$this
->assertSame('foo: bar' . "\n", Yaml::encode($decoded));
}
public function testGetFileExtension() {
$this
->assertEquals('yml', Yaml::getFileExtension());
}
}