You are here

class YamlTest in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/yaml/Tests/YamlTest.php \Symfony\Component\Yaml\Tests\YamlTest
  2. 8 core/tests/Drupal/Tests/Component/Serialization/YamlTest.php \Drupal\Tests\Component\Serialization\YamlTest
Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Component/Serialization/YamlTest.php \Drupal\Tests\Component\Serialization\YamlTest

@coversDefaultClass \Drupal\Component\Serialization\Yaml @group Serialization

Hierarchy

  • class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
    • class \Drupal\Tests\Component\Serialization\YamlTest

Expanded class hierarchy of YamlTest

File

core/tests/Drupal/Tests/Component/Serialization/YamlTest.php, line 17
Contains \Drupal\Tests\Component\Serialization\YamlTest.

Namespace

Drupal\Tests\Component\Serialization
View source
class YamlTest extends UnitTestCase {

  /**
   * @covers ::decode
   */
  public function testDecode() {

    // Test that files without line break endings are properly interpreted.
    $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));
  }

  /**
   * @covers ::encode
   */
  public function testEncode() {
    $decoded = array(
      'foo' => 'bar',
    );
    $this
      ->assertSame('foo: bar' . "\n", Yaml::encode($decoded));
  }

  /**
   * @covers ::getFileExtension
   */
  public function testGetFileExtension() {
    $this
      ->assertEquals('yml', Yaml::getFileExtension());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root.
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName protected function Mocks a block with a block plugin.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed in array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUp protected function 259
YamlTest::testDecode public function @covers ::decode
YamlTest::testEncode public function @covers ::encode
YamlTest::testGetFileExtension public function @covers ::getFileExtension