ParseExceptionTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\Exception\ParseException;
  12. class ParseExceptionTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testGetMessage()
  15. {
  16. $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
  17. if (PHP_VERSION_ID >= 50400) {
  18. $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
  19. } else {
  20. $message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")';
  21. }
  22. $this->assertEquals($message, $exception->getMessage());
  23. }
  24. public function testGetMessageWithUnicodeInFilename()
  25. {
  26. $exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
  27. if (PHP_VERSION_ID >= 50400) {
  28. $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
  29. } else {
  30. $message = 'Error message in "\u00e4\u00f6\u00fc.yml" at line 42 (near "foo: bar")';
  31. }
  32. $this->assertEquals($message, $exception->getMessage());
  33. }
  34. }