From 2dd970a2263dcdab6c4b5dd561547ab4c8a05d5a Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Thu, 20 Sep 2018 12:58:35 +0200 Subject: [PATCH] [FrameworkBundle] Support 4.2 lint commands changes in 4.1 tests --- .../Tests/Command/XliffLintCommandTest.php | 4 +++- .../Tests/Command/YamlLintCommandTest.php | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/XliffLintCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/XliffLintCommandTest.php index 2d0e8dcd1bdae..8783f204afe63 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/XliffLintCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/XliffLintCommandTest.php @@ -30,6 +30,7 @@ class XliffLintCommandTest extends TestCase { private $files; + private $supportsArrayOfFiles = false; public function testGetHelp() { @@ -64,7 +65,7 @@ public function testLintFilesFromBundleDirectory() { $tester = $this->createCommandTester($this->getKernelAwareApplicationMock()); $tester->execute( - array('filename' => '@AppBundle/Resources'), + array('filename' => $this->supportsArrayOfFiles ? array('@AppBundle/Resources') : '@AppBundle/Resources'), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false) ); @@ -83,6 +84,7 @@ private function createCommandTester($application = null) } $command = $application->find('lint:xliff'); + $this->supportsArrayOfFiles = $command->getDefinition()->getArgument('filename')->isArray(); if ($application) { $command->setApplication($application); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php index 2daa2e3228318..26dea51be4958 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php @@ -29,6 +29,7 @@ class YamlLintCommandTest extends TestCase { private $files; + private $supportsArrayOfFiles = false; public function testLintCorrectFile() { @@ -36,7 +37,7 @@ public function testLintCorrectFile() $filename = $this->createFile('foo: bar'); $tester->execute( - array('filename' => $filename), + array('filename' => $this->supportsArrayOfFiles ? array($filename) : $filename), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false) ); @@ -52,7 +53,7 @@ public function testLintIncorrectFile() $tester = $this->createCommandTester(); $filename = $this->createFile($incorrectContent); - $tester->execute(array('filename' => $filename), array('decorated' => false)); + $tester->execute(array('filename' => $this->supportsArrayOfFiles ? array($filename) : $filename), array('decorated' => false)); $this->assertEquals(1, $tester->getStatusCode(), 'Returns 1 in case of error'); $this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay())); @@ -67,7 +68,7 @@ public function testLintFileNotReadable() $filename = $this->createFile(''); unlink($filename); - $tester->execute(array('filename' => $filename), array('decorated' => false)); + $tester->execute(array('filename' => $this->supportsArrayOfFiles ? array($filename) : $filename), array('decorated' => false)); } public function testGetHelp() @@ -103,7 +104,7 @@ public function testLintFilesFromBundleDirectory() { $tester = $this->createCommandTester($this->getKernelAwareApplicationMock()); $tester->execute( - array('filename' => '@AppBundle/Resources'), + array('filename' => $this->supportsArrayOfFiles ? array('@AppBundle/Resources') : '@AppBundle/Resources'), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false) ); @@ -135,6 +136,7 @@ private function createCommandTester($application = null) } $command = $application->find('lint:yaml'); + $this->supportsArrayOfFiles = $command->getDefinition()->getArgument('filename')->isArray(); if ($application) { $command->setApplication($application);