Pull merge.
[yaffs-website] / vendor / symfony / yaml / Tests / Command / LintCommandTest.php
index ce6ad480cf2b6e1e0c7c09fa145a3ead5b813574..a5baf234ef3dfa05258814ad2d43daf6e42bfb26 100644 (file)
 namespace Symfony\Component\Yaml\Tests\Command;
 
 use PHPUnit\Framework\TestCase;
-use Symfony\Component\Yaml\Command\LintCommand;
 use Symfony\Component\Console\Application;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Tester\CommandTester;
+use Symfony\Component\Yaml\Command\LintCommand;
 
 /**
  * Tests the YamlLintCommand.
@@ -51,6 +51,33 @@ bar';
         $this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay()));
     }
 
+    public function testConstantAsKey()
+    {
+        $yaml = <<<YAML
+!php/const 'Symfony\Component\Yaml\Tests\Command\Foo::TEST': bar
+YAML;
+        $ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
+        $this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success');
+    }
+
+    public function testCustomTags()
+    {
+        $yaml = <<<YAML
+foo: !my_tag {foo: bar}
+YAML;
+        $ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml), '--parse-tags' => true), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
+        $this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success');
+    }
+
+    public function testCustomTagsError()
+    {
+        $yaml = <<<YAML
+foo: !my_tag {foo: bar}
+YAML;
+        $ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
+        $this->assertSame(1, $ret, 'lint:yaml exits with code 1 in case of error');
+    }
+
     /**
      * @expectedException \RuntimeException
      */
@@ -105,3 +132,8 @@ bar';
         rmdir(sys_get_temp_dir().'/framework-yml-lint-test');
     }
 }
+
+class Foo
+{
+    const TEST = 'foo';
+}