Skip to content

Commit

Permalink
SentryTestCommand > Define command name in config (#635)
Browse files Browse the repository at this point in the history
This fixes a deprecation on Symfony 6.1:
```
Since symfony/console 6.1: Relying on the static property "$defaultName" for setting a command name is deprecated. Add the "Symfony\Component\Console\Attribute\AsCommand" attribute to the "Sentry\SentryBundle\Command\SentryTestCommand" class instead.
```
  • Loading branch information
ruudk authored May 28, 2022
1 parent d1d2895 commit 4174898
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Fix compatibility issue with Symfony >= 6.1.0 (#635)

## 4.2.10 (2022-05-17)

Expand Down
2 changes: 0 additions & 2 deletions src/Command/SentryTestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

class SentryTestCommand extends Command
{
protected static $defaultName = 'sentry:test';

protected function execute(InputInterface $input, OutputInterface $output): int
{
$currentHub = SentrySdk::getCurrentHub();
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</service>

<service id="Sentry\SentryBundle\Command\SentryTestCommand" class="Sentry\SentryBundle\Command\SentryTestCommand">
<tag name="console.command" />
<tag name="console.command" command="sentry:test" />
</service>

<service id="Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionFactoryInterface" alias="Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionFactory" />
Expand Down
5 changes: 4 additions & 1 deletion tests/Command/SentryTestCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ public function testExecuteFailsDueToMissingClient(): void

private function executeCommand(): CommandTester
{
$command = new SentryTestCommand();
$command->setName('sentry:test');

$application = new Application();
$application->add(new SentryTestCommand());
$application->add($command);

$command = $application->find('sentry:test');
$commandTester = new CommandTester($command);
Expand Down

0 comments on commit 4174898

Please sign in to comment.