name: LintCommandTest class_comment: '# * Tests the YamlLintCommand. # * # * @author Robin Chalas ' dependencies: - name: TestCase type: class source: PHPUnit\Framework\TestCase - name: Application type: class source: Symfony\Component\Console\Application - name: Command type: class source: Symfony\Component\Console\Command\Command - name: OutputInterface type: class source: Symfony\Component\Console\Output\OutputInterface - name: CommandCompletionTester type: class source: Symfony\Component\Console\Tester\CommandCompletionTester - name: CommandTester type: class source: Symfony\Component\Console\Tester\CommandTester - name: LintCommand type: class source: Symfony\Component\Yaml\Command\LintCommand properties: [] methods: - name: testComplete visibility: public parameters: - name: input - name: expectedSuggestions comment: "# * Tests the YamlLintCommand.\n# *\n# * @author Robin Chalas \n\ # */\n# class LintCommandTest extends TestCase\n# {\n# private array $files;\n\ # \n# public function testLintCorrectFile()\n# {\n# $tester = $this->createCommandTester();\n\ # $filename = $this->createFile('foo: bar');\n# \n# $ret = $tester->execute(['filename'\ \ => $filename], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated'\ \ => false]);\n# \n# $this->assertEquals(0, $ret, 'Returns 0 in case of success');\n\ # $this->assertMatchesRegularExpression('/^\\/\\/ OK in /', trim($tester->getDisplay()));\n\ # }\n# \n# public function testLintCorrectFiles()\n# {\n# $tester = $this->createCommandTester();\n\ # $filename1 = $this->createFile('foo: bar');\n# $filename2 = $this->createFile('bar:\ \ baz');\n# \n# $ret = $tester->execute(['filename' => [$filename1, $filename2]],\ \ ['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]);\n\ # \n# $this->assertEquals(0, $ret, 'Returns 0 in case of success');\n# $this->assertMatchesRegularExpression('/^\\\ /\\/ OK in /', trim($tester->getDisplay()));\n# }\n# \n# public function testLintIncorrectFile()\n\ # {\n# $incorrectContent = '\n# foo:\n# bar';\n# $tester = $this->createCommandTester();\n\ # $filename = $this->createFile($incorrectContent);\n# \n# $ret = $tester->execute(['filename'\ \ => $filename], ['decorated' => false]);\n# \n# $this->assertEquals(1, $ret,\ \ 'Returns 1 in case of error');\n# $this->assertStringContainsString('Unable\ \ to parse at line 3 (near \"bar\").', trim($tester->getDisplay()));\n# }\n# \n\ # public function testLintIncorrectFileWithGithubFormat()\n# {\n# $incorrectContent\ \ = <<createCommandTester();\n\ # $filename = $this->createFile($incorrectContent);\n# \n# $tester->execute(['filename'\ \ => $filename, '--format' => 'github'], ['decorated' => false]);\n# \n# self::assertEquals(1,\ \ $tester->getStatusCode(), 'Returns 1 in case of error');\n# self::assertStringMatchesFormat('%A::error\ \ file=%s,line=2,col=0::Unable to parse at line 2 (near \"bar\")%A', trim($tester->getDisplay()));\n\ # }\n# \n# public function testLintAutodetectsGithubActionEnvironment()\n# {\n\ # $prev = getenv('GITHUB_ACTIONS');\n# putenv('GITHUB_ACTIONS');\n# \n# try {\n\ # putenv('GITHUB_ACTIONS=1');\n# \n# $incorrectContent = <<createCommandTester();\n# $filename = $this->createFile($incorrectContent);\n\ # \n# $tester->execute(['filename' => $filename], ['decorated' => false]);\n#\ \ \n# self::assertStringMatchesFormat('%A::error file=%s,line=2,col=0::Unable\ \ to parse at line 2 (near \"bar\")%A', trim($tester->getDisplay()));\n# } finally\ \ {\n# putenv('GITHUB_ACTIONS'.($prev ? \"=$prev\" : ''));\n# }\n# }\n# \n# public\ \ function testConstantAsKey()\n# {\n# $yaml = <<createCommandTester()->execute(['filename'\ \ => $this->createFile($yaml)], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE,\ \ 'decorated' => false]);\n# $this->assertSame(0, $ret, 'lint:yaml exits with\ \ code 0 in case of success');\n# }\n# \n# public function testCustomTags()\n\ # {\n# $yaml = <<createCommandTester()->execute(['filename'\ \ => $this->createFile($yaml), '--parse-tags' => true], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE,\ \ 'decorated' => false]);\n# $this->assertSame(0, $ret, 'lint:yaml exits with\ \ code 0 in case of success');\n# }\n# \n# public function testCustomTagsError()\n\ # {\n# $yaml = <<createCommandTester()->execute(['filename'\ \ => $this->createFile($yaml)], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE,\ \ 'decorated' => false]);\n# $this->assertSame(1, $ret, 'lint:yaml exits with\ \ code 1 in case of error');\n# }\n# \n# public function testLintWithExclude()\n\ # {\n# $tester = $this->createCommandTester();\n# $filename1 = $this->createFile('foo:\ \ bar');\n# $filename2 = $this->createFile('bar: baz');\n# \n# $ret = $tester->execute(['filename'\ \ => [$filename1, $filename2], '--exclude' => [$filename1]], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE,\ \ 'decorated' => false]);\n# $this->assertSame(0, $ret, 'lint:yaml exits with\ \ code 0 in case of success');\n# $this->assertStringContainsString('All 1 YAML\ \ files contain valid syntax.', trim($tester->getDisplay()));\n# }\n# \n# public\ \ function testLintFileNotReadable()\n# {\n# $tester = $this->createCommandTester();\n\ # $filename = $this->createFile('');\n# unlink($filename);\n# \n# $this->expectException(\\\ RuntimeException::class);\n# \n# $tester->execute(['filename' => $filename], ['decorated'\ \ => false]);\n# }\n# \n# /**\n# * @dataProvider provideCompletionSuggestions" - name: provideCompletionSuggestions visibility: public parameters: [] comment: null - name: createFile visibility: private parameters: - name: content comment: null - name: createCommand visibility: protected parameters: [] comment: null - name: createCommandTester visibility: protected parameters: [] comment: null - name: setUp visibility: protected parameters: [] comment: null - name: tearDown visibility: protected parameters: [] comment: null traits: - PHPUnit\Framework\TestCase - Symfony\Component\Console\Application - Symfony\Component\Console\Command\Command - Symfony\Component\Console\Output\OutputInterface - Symfony\Component\Console\Tester\CommandCompletionTester - Symfony\Component\Console\Tester\CommandTester - Symfony\Component\Yaml\Command\LintCommand interfaces: []