Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dca646d

Browse files
Merge branch '5.2' into 5.3
* 5.2: [Console] Escape synopsis output [SecurityBundle] Link UserProviderListener to correct firewall dispatcher [FrameworkBundle] fix KernelBrowser::loginUser with a stateless firewall Document null support in NumberToLocalizedStringTransformer Update loader’s directory when calling ContainerConfigurator::withPath
2 parents 0585538 + 3685a3a commit dca646d

4 files changed

Lines changed: 27 additions & 2 deletions

File tree

Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ public function renderThrowable(\Throwable $e, OutputInterface $output): void
798798
$this->doRenderThrowable($e, $output);
799799

800800
if (null !== $this->runningCommand) {
801-
$output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
801+
$output->writeln(sprintf('<info>%s</info>', OutputFormatter::escape(sprintf($this->runningCommand->getSynopsis(), $this->getName()))), OutputInterface::VERBOSITY_QUIET);
802802
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
803803
}
804804
}

Tests/ApplicationTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,23 @@ public function testRenderExceptionStackTraceContainsRootException()
927927
$this->assertStringContainsString('Dummy type "class@anonymous" is invalid.', $tester->getDisplay(true));
928928
}
929929

930+
public function testRenderExceptionEscapesLinesOfSynopsis()
931+
{
932+
$application = new Application();
933+
$application->setAutoExit(false);
934+
$application
935+
->register('foo')
936+
->setCode(function () {
937+
throw new \Exception('some exception');
938+
})
939+
->addArgument('info')
940+
;
941+
$tester = new ApplicationTester($application);
942+
943+
$tester->run(['command' => 'foo'], ['decorated' => false]);
944+
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/application_rendersynopsis_escapesline.txt', $tester->getDisplay(true), '->renderException() escapes lines containing formatting of synopsis');
945+
}
946+
930947
public function testRun()
931948
{
932949
$application = new Application();

Tests/Command/CommandTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ public function testGetSynopsis()
186186
$command = new \TestCommand();
187187
$command->addOption('foo');
188188
$command->addArgument('bar');
189-
$this->assertEquals('namespace:name [--foo] [--] [<bar>]', $command->getSynopsis(), '->getSynopsis() returns the synopsis');
189+
$command->addArgument('info');
190+
$this->assertEquals('namespace:name [--foo] [--] [<bar> [<info>]]', $command->getSynopsis(), '->getSynopsis() returns the synopsis');
190191
}
191192

192193
public function testAddGetUsages()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
In ApplicationTest.php line %d:
3+
4+
some exception
5+
6+
7+
foo [<info>]

0 commit comments

Comments
 (0)