Skip to content

Commit b6167ca

Browse files
Merge branch '5.4' into 6.0
* 5.4: (26 commits) [Dotenv] Fix testBootEnv() to start from a fresh context fix tests relax expected exception message for forward-compatibility with 5.4 fix expected exception messages after changes made in Definition class [DependencyInjection] show class name on DI errors skip command completion tests with older Symfony Console versions Use GitHub issue form templates Fix CS add ResponseIsUnprocessable Add missing translations for Persian (fa) skip command completion tests with older Symfony Console versions prevent issues with timezones and DST by using only UNIX timestamps Add the missing translations for Bahasa Indonesia (id) [Finder] Fix .gitignore infinite loop Update README.md fix messenger DI dependency for registerAttributeForAutoconfiguration [Messenger] Autoconfigurable attributes Fix deprecations on PHP 8.2 [Dotenv] Fix testLoadEnv() .env.dist isolation Since 5.0, throws \UnexpectedValueException has been removed. ...
2 parents 49938d5 + 36b49ce commit b6167ca

File tree

6 files changed

+65
-3
lines changed

6 files changed

+65
-3
lines changed

Command/ConfigDumpReferenceCommand.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\Component\Config\Definition\Dumper\XmlReferenceDumper;
1616
use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper;
1717
use Symfony\Component\Console\Attribute\AsCommand;
18+
use Symfony\Component\Console\Completion\CompletionInput;
19+
use Symfony\Component\Console\Completion\CompletionSuggestions;
1820
use Symfony\Component\Console\Exception\InvalidArgumentException;
1921
use Symfony\Component\Console\Input\InputArgument;
2022
use Symfony\Component\Console\Input\InputInterface;
@@ -155,4 +157,32 @@ protected function execute(InputInterface $input, OutputInterface $output): int
155157

156158
return 0;
157159
}
160+
161+
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
162+
{
163+
if ($input->mustSuggestArgumentValuesFor('name')) {
164+
$suggestions->suggestValues($this->getAvailableBundles());
165+
}
166+
167+
if ($input->mustSuggestOptionValuesFor('format')) {
168+
$suggestions->suggestValues($this->getAvailableFormatOptions());
169+
}
170+
}
171+
172+
private function getAvailableBundles(): array
173+
{
174+
$bundles = [];
175+
176+
foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
177+
$bundles[] = $bundle->getName();
178+
$bundles[] = $bundle->getContainerExtension()->getAlias();
179+
}
180+
181+
return $bundles;
182+
}
183+
184+
private function getAvailableFormatOptions(): array
185+
{
186+
return ['yaml', 'xml'];
187+
}
158188
}

DependencyInjection/FrameworkExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
use Symfony\Component\Mailer\Bridge\Sendinblue\Transport\SendinblueTransportFactory;
9797
use Symfony\Component\Mailer\Mailer;
9898
use Symfony\Component\Mercure\HubRegistry;
99+
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
99100
use Symfony\Component\Messenger\Bridge\AmazonSqs\Transport\AmazonSqsTransportFactory;
100101
use Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpTransportFactory;
101102
use Symfony\Component\Messenger\Bridge\Beanstalkd\Transport\BeanstalkdTransportFactory;
@@ -581,6 +582,13 @@ public function load(array $configs, ContainerBuilder $container)
581582
$container->registerAttributeForAutoconfiguration(AsController::class, static function (ChildDefinition $definition, AsController $attribute): void {
582583
$definition->addTag('controller.service_arguments');
583584
});
585+
$container->registerAttributeForAutoconfiguration(AsMessageHandler::class, static function (ChildDefinition $definition, AsMessageHandler $attribute): void {
586+
$tagAttributes = get_object_vars($attribute);
587+
$tagAttributes['from_transport'] = $tagAttributes['fromTransport'];
588+
unset($tagAttributes['fromTransport']);
589+
590+
$definition->addTag('messenger.message_handler', $tagAttributes);
591+
});
584592

585593
if (!$container->getParameter('kernel.debug')) {
586594
// remove tagged iterator argument for resource checkers

Resources/config/console.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@
307307
->set('console.command.secrets_list', SecretsListCommand::class)
308308
->args([
309309
service('secrets.vault'),
310-
service('secrets.local_vault'),
310+
service('secrets.local_vault')->ignoreOnInvalid(),
311311
])
312312
->tag('console.command')
313313

@@ -321,7 +321,7 @@
321321
->set('console.command.secrets_encrypt_from_local', SecretsEncryptFromLocalCommand::class)
322322
->args([
323323
service('secrets.vault'),
324-
service('secrets.local_vault'),
324+
service('secrets.local_vault')->ignoreOnInvalid(),
325325
])
326326
->tag('console.command')
327327
;

Test/BrowserKitAssertionsTrait.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ public static function assertResponseCookieValueSame(string $name, string $expec
9494
), $message);
9595
}
9696

97+
public static function assertResponseIsUnprocessable(string $message = ''): void
98+
{
99+
self::assertThatForResponse(new ResponseConstraint\ResponseIsUnprocessable(), $message);
100+
}
101+
97102
public static function assertBrowserHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void
98103
{
99104
self::assertThatForClient(new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain), $message);

Tests/DependencyInjection/PhpFrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function testRateLimiterLockFactory()
126126
});
127127

128128
$this->expectException(OutOfBoundsException::class);
129-
$this->expectExceptionMessage('The argument "2" doesn\'t exist.');
129+
$this->expectExceptionMessageMatches('/^The argument "2" doesn\'t exist.*\.$/');
130130

131131
$container->getDefinition('limiter.without_lock')->getArgument(2);
132132
}

Tests/Functional/ConfigDumpReferenceCommandTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

14+
use Symfony\Bundle\FrameworkBundle\Command\ConfigDumpReferenceCommand;
1415
use Symfony\Bundle\FrameworkBundle\Console\Application;
1516
use Symfony\Component\Console\Input\ArrayInput;
1617
use Symfony\Component\Console\Output\NullOutput;
18+
use Symfony\Component\Console\Tester\CommandCompletionTester;
1719
use Symfony\Component\Console\Tester\CommandTester;
1820

1921
/**
@@ -81,6 +83,23 @@ public function testDumpAtPathXml()
8183
$this->assertStringContainsString('[ERROR] The "path" option is only available for the "yaml" format.', $tester->getDisplay());
8284
}
8385

86+
/**
87+
* @dataProvider provideCompletionSuggestions
88+
*/
89+
public function testComplete(array $input, array $expectedSuggestions)
90+
{
91+
$this->application->add(new ConfigDumpReferenceCommand());
92+
$tester = new CommandCompletionTester($this->application->get('config:dump-reference'));
93+
$suggestions = $tester->complete($input, 2);
94+
$this->assertSame($expectedSuggestions, $suggestions);
95+
}
96+
97+
public function provideCompletionSuggestions(): iterable
98+
{
99+
yield 'name' => [[''], ['DefaultConfigTestBundle', 'default_config_test', 'ExtensionWithoutConfigTestBundle', 'extension_without_config_test', 'FrameworkBundle', 'framework', 'TestBundle', 'test']];
100+
yield 'option --format' => [['--format', ''], ['yaml', 'xml']];
101+
}
102+
84103
private function createCommandTester(): CommandTester
85104
{
86105
$command = $this->application->find('config:dump-reference');

0 commit comments

Comments
 (0)