Esempio n. 1
0
 public function testGetMessageWithUnicodeInFilename()
 {
     $exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
     if (PHP_VERSION_ID >= 50400) {
         $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
     } else {
         $message = 'Error message in "\\u00e4\\u00f6\\u00fc.yml" at line 42 (near "foo: bar")';
     }
     $this->assertEquals($message, $exception->getMessage());
 }
Esempio n. 2
0
 public function testGetMessage()
 {
     $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
     if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
         $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
     } else {
         $message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")';
     }
     $this->assertEquals($message, $exception->getMessage());
 }
 public function testGetMessageWithUnicodeInFilename()
 {
     $exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
     $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
     $this->assertEquals($message, $exception->getMessage());
 }
Esempio n. 4
0
 /**
  * @param ParseException $exception
  *
  * @return YamlLintError
  */
 public static function fromParseException(ParseException $exception)
 {
     return new YamlLintError(LintError::TYPE_ERROR, $exception->getMessage(), $exception->getParsedFile(), $exception->getParsedLine(), $exception->getSnippet());
 }
Esempio n. 5
0
 /**
  * Casts Symfony's Yaml ParseException to ours.
  *
  * @param YamlParseException $exception
  *
  * @return ParseException
  */
 public static function castFromYaml(YamlParseException $exception)
 {
     $message = static::parseRawMessage($exception->getMessage());
     return new static($message, $exception->getParsedLine(), $exception->getSnippet(), $exception);
 }