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.
$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
*/
rmdir(sys_get_temp_dir().'/framework-yml-lint-test');
}
}
+
+class Foo
+{
+ const TEST = 'foo';
+}