YamlTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Yaml\Tests;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Yaml\Yaml;
  13. class YamlTest extends TestCase
  14. {
  15. public function testParseAndDump()
  16. {
  17. $data = array('lorem' => 'ipsum', 'dolor' => 'sit');
  18. $yml = Yaml::dump($data);
  19. $parsed = Yaml::parse($yml);
  20. $this->assertEquals($data, $parsed);
  21. }
  22. /**
  23. * @expectedException \InvalidArgumentException
  24. * @expectedExceptionMessage The indentation must be greater than zero
  25. */
  26. public function testZeroIndentationThrowsException()
  27. {
  28. Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, 0);
  29. }
  30. /**
  31. * @expectedException \InvalidArgumentException
  32. * @expectedExceptionMessage The indentation must be greater than zero
  33. */
  34. public function testNegativeIndentationThrowsException()
  35. {
  36. Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, -4);
  37. }
  38. }