Skip to content

Commit ada8cc2

Browse files
committed
fix tests
Since #60076 using a closure as the command code that does not return an integer is deprecated. This means that our tests can trigger deprecations on older branches when the high deps job is run. This usually is not an issue as we silence them with the `SYMFONY_DEPRECATIONS_HELPER` env var. However, phpt tests are run in a child process where the deprecation error handler of the PHPUnit bridge doesn't step in. Thus, for them deprecations are not silenced leading to failures.
1 parent 96120e6 commit ada8cc2

6 files changed

+18
-6
lines changed

src/Symfony/Component/Runtime/Tests/phpt/application.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818

1919
return function (array $context) {
2020
$command = new Command('go');
21-
$command->setCode(function (InputInterface $input, OutputInterface $output) use ($context) {
21+
$command->setCode(function (InputInterface $input, OutputInterface $output) use ($context): int {
2222
$output->write('OK Application '.$context['SOME_VAR']);
23+
24+
return 0;
2325
});
2426

2527
$app = new Application();

src/Symfony/Component/Runtime/Tests/phpt/command.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
return function (Command $command, InputInterface $input, OutputInterface $output, array $context) {
2020
$command->addOption('hello', 'e', InputOption::VALUE_REQUIRED, 'How should I greet?', 'OK');
2121

22-
return $command->setCode(function () use ($input, $output, $context) {
22+
return $command->setCode(function () use ($input, $output, $context): int {
2323
$output->write($input->getOption('hello').' Command '.$context['SOME_VAR']);
24+
25+
return 0;
2426
});
2527
};

src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_debug_exists_0_to_1.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
require __DIR__.'/autoload.php';
2222

23-
return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): void {
23+
return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): int {
2424
$output->writeln($context['DEBUG_ENABLED']);
25+
26+
return 0;
2527
});

src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_debug_exists_1_to_0.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
require __DIR__.'/autoload.php';
2222

23-
return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): void {
23+
return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): int {
2424
$output->writeln($context['DEBUG_MODE']);
25+
26+
return 0;
2527
});

src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_env_exists.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
require __DIR__.'/autoload.php';
2222

23-
return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): void {
23+
return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): int {
2424
$output->writeln($context['ENV_MODE']);
25+
26+
return 0;
2527
});

src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload_command_no_debug.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
require __DIR__.'/autoload.php';
2121

22-
return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): void {
22+
return static fn (Command $command, OutputInterface $output, array $context): Command => $command->setCode(static function () use ($output, $context): int {
2323
$output->writeln($context['DEBUG_ENABLED']);
24+
25+
return 0;
2426
});

0 commit comments

Comments
 (0)