YamlTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 = ['lorem' => 'ipsum', 'dolor' => 'sit'];
  18. $yml = Yaml::dump($data);
  19. $parsed = Yaml::parse($yml);
  20. $this->assertEquals($data, $parsed);
  21. }
  22. public function testZeroIndentationThrowsException()
  23. {
  24. $this->expectException('InvalidArgumentException');
  25. $this->expectExceptionMessage('The indentation must be greater than zero');
  26. Yaml::dump(['lorem' => 'ipsum', 'dolor' => 'sit'], 2, 0);
  27. }
  28. public function testNegativeIndentationThrowsException()
  29. {
  30. $this->expectException('InvalidArgumentException');
  31. $this->expectExceptionMessage('The indentation must be greater than zero');
  32. Yaml::dump(['lorem' => 'ipsum', 'dolor' => 'sit'], 2, -4);
  33. }
  34. }