暂无描述

YamlTest.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 Symfony\Component\Yaml\Yaml;
  12. class YamlTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testParseAndDump()
  15. {
  16. $data = array('lorem' => 'ipsum', 'dolor' => 'sit');
  17. $yml = Yaml::dump($data);
  18. $parsed = Yaml::parse($yml);
  19. $this->assertEquals($data, $parsed);
  20. }
  21. /**
  22. * @expectedException \InvalidArgumentException
  23. * @expectedExceptionMessage The indentation must be greater than zero
  24. */
  25. public function testZeroIndentationThrowsException()
  26. {
  27. Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, 0);
  28. }
  29. /**
  30. * @expectedException \InvalidArgumentException
  31. * @expectedExceptionMessage The indentation must be greater than zero
  32. */
  33. public function testNegativeIndentationThrowsException()
  34. {
  35. Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, -4);
  36. }
  37. }