Skip to content

Commit 927cdf2

Browse files
Merge branch '6.0' into 6.1
* 6.0: Revert "bug #45813 [HttpClient] Move Content-Type after Content-Length (nicolas-grekas)" [FrameworkBundle] Fix exit codes in debug:translation command [Cache] Declaratively declare/hide DoctrineProvider to avoid breaking static analysis [HttpClient] Let curl handle Content-Length headers Improve testsuite [HttpClient] Move Content-Type after Content-Length [HttpClient] minor cs fix [Config] Fix using null values with config builders
2 parents 419ab39 + fdaa6d8 commit 927cdf2

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

Command/TranslationDebugCommand.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
131131
$locale = $input->getArgument('locale');
132132
$domain = $input->getOption('domain');
133133

134-
$exitCode = 0;
134+
$exitCode = self::SUCCESS;
135135

136136
/** @var KernelInterface $kernel */
137137
$kernel = $this->getApplication()->getKernel();
@@ -217,16 +217,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int
217217
if (!$currentCatalogue->defines($messageId, $domain)) {
218218
$states[] = self::MESSAGE_MISSING;
219219

220-
$exitCode = $exitCode | self::EXIT_CODE_MISSING;
220+
if (!$input->getOption('only-unused')) {
221+
$exitCode = $exitCode | self::EXIT_CODE_MISSING;
222+
}
221223
}
222224
} elseif ($currentCatalogue->defines($messageId, $domain)) {
223225
$states[] = self::MESSAGE_UNUSED;
224226

225-
$exitCode = $exitCode | self::EXIT_CODE_UNUSED;
227+
if (!$input->getOption('only-missing')) {
228+
$exitCode = $exitCode | self::EXIT_CODE_UNUSED;
229+
}
226230
}
227231

228-
if (!\in_array(self::MESSAGE_UNUSED, $states) && true === $input->getOption('only-unused')
229-
|| !\in_array(self::MESSAGE_MISSING, $states) && true === $input->getOption('only-missing')) {
232+
if (!\in_array(self::MESSAGE_UNUSED, $states) && $input->getOption('only-unused')
233+
|| !\in_array(self::MESSAGE_MISSING, $states) && $input->getOption('only-missing')
234+
) {
230235
continue;
231236
}
232237

Tests/Command/TranslationDebugCommandTest.php

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand;
1616
use Symfony\Bundle\FrameworkBundle\Console\Application;
1717
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\ExtensionWithoutConfigTestBundle\ExtensionWithoutConfigTestBundle;
18+
use Symfony\Component\Console\Command\Command;
1819
use Symfony\Component\Console\Tester\CommandCompletionTester;
1920
use Symfony\Component\Console\Tester\CommandTester;
2021
use Symfony\Component\DependencyInjection\Container;
@@ -36,7 +37,7 @@ public function testDebugMissingMessages()
3637
$res = $tester->execute(['locale' => 'en', 'bundle' => 'foo']);
3738

3839
$this->assertMatchesRegularExpression('/missing/', $tester->getDisplay());
39-
$this->assertEquals(TranslationDebugCommand::EXIT_CODE_MISSING, $res);
40+
$this->assertSame(TranslationDebugCommand::EXIT_CODE_MISSING, $res);
4041
}
4142

4243
public function testDebugUnusedMessages()
@@ -45,7 +46,7 @@ public function testDebugUnusedMessages()
4546
$res = $tester->execute(['locale' => 'en', 'bundle' => 'foo']);
4647

4748
$this->assertMatchesRegularExpression('/unused/', $tester->getDisplay());
48-
$this->assertEquals(TranslationDebugCommand::EXIT_CODE_UNUSED, $res);
49+
$this->assertSame(TranslationDebugCommand::EXIT_CODE_UNUSED, $res);
4950
}
5051

5152
public function testDebugFallbackMessages()
@@ -54,7 +55,7 @@ public function testDebugFallbackMessages()
5455
$res = $tester->execute(['locale' => 'fr', 'bundle' => 'foo']);
5556

5657
$this->assertMatchesRegularExpression('/fallback/', $tester->getDisplay());
57-
$this->assertEquals(TranslationDebugCommand::EXIT_CODE_FALLBACK, $res);
58+
$this->assertSame(TranslationDebugCommand::EXIT_CODE_FALLBACK, $res);
5859
}
5960

6061
public function testNoDefinedMessages()
@@ -63,7 +64,7 @@ public function testNoDefinedMessages()
6364
$res = $tester->execute(['locale' => 'fr', 'bundle' => 'test']);
6465

6566
$this->assertMatchesRegularExpression('/No defined or extracted messages for locale "fr"/', $tester->getDisplay());
66-
$this->assertEquals(TranslationDebugCommand::EXIT_CODE_GENERAL_ERROR, $res);
67+
$this->assertSame(TranslationDebugCommand::EXIT_CODE_GENERAL_ERROR, $res);
6768
}
6869

6970
public function testDebugDefaultDirectory()
@@ -74,7 +75,7 @@ public function testDebugDefaultDirectory()
7475

7576
$this->assertMatchesRegularExpression('/missing/', $tester->getDisplay());
7677
$this->assertMatchesRegularExpression('/unused/', $tester->getDisplay());
77-
$this->assertEquals($expectedExitStatus, $res);
78+
$this->assertSame($expectedExitStatus, $res);
7879
}
7980

8081
public function testDebugDefaultRootDirectory()
@@ -92,7 +93,7 @@ public function testDebugDefaultRootDirectory()
9293

9394
$this->assertMatchesRegularExpression('/missing/', $tester->getDisplay());
9495
$this->assertMatchesRegularExpression('/unused/', $tester->getDisplay());
95-
$this->assertEquals($expectedExitStatus, $res);
96+
$this->assertSame($expectedExitStatus, $res);
9697
}
9798

9899
public function testDebugCustomDirectory()
@@ -112,7 +113,7 @@ public function testDebugCustomDirectory()
112113

113114
$this->assertMatchesRegularExpression('/missing/', $tester->getDisplay());
114115
$this->assertMatchesRegularExpression('/unused/', $tester->getDisplay());
115-
$this->assertEquals($expectedExitStatus, $res);
116+
$this->assertSame($expectedExitStatus, $res);
116117
}
117118

118119
public function testDebugInvalidDirectory()
@@ -128,6 +129,22 @@ public function testDebugInvalidDirectory()
128129
$tester->execute(['locale' => 'en', 'bundle' => 'dir']);
129130
}
130131

132+
public function testNoErrorWithOnlyMissingOptionAndNoResults()
133+
{
134+
$tester = $this->createCommandTester([], ['foo' => 'foo']);
135+
$res = $tester->execute(['locale' => 'en', '--only-missing' => true]);
136+
137+
$this->assertSame(Command::SUCCESS, $res);
138+
}
139+
140+
public function testNoErrorWithOnlyUnusedOptionAndNoResults()
141+
{
142+
$tester = $this->createCommandTester(['foo' => 'foo']);
143+
$res = $tester->execute(['locale' => 'en', '--only-unused' => true]);
144+
145+
$this->assertSame(Command::SUCCESS, $res);
146+
}
147+
131148
protected function setUp(): void
132149
{
133150
$this->fs = new Filesystem();

0 commit comments

Comments
 (0)