From 753cf728aeb47805a8b81bda31b001166c709b80 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Fri, 6 Mar 2026 16:51:55 +0300 Subject: [PATCH] Improve tests: fix deprecations and allow running with enabled zend.assertions --- phpunit.xml | 9 ++++----- .../Feature/Console/GenerateCommand/ContextBuilder.php | 3 ++- .../Feature/McpTools/Traits/InteractsWithMcpTools.php | 7 +++++-- tests/src/Unit/Source/TextSourceFromArrayTest.php | 2 ++ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 85ed5bb1..77354b31 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,14 +1,13 @@ - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"> + src - + tests/src/Unit diff --git a/tests/src/Feature/Console/GenerateCommand/ContextBuilder.php b/tests/src/Feature/Console/GenerateCommand/ContextBuilder.php index b3b3d1a1..ab4280f8 100644 --- a/tests/src/Feature/Console/GenerateCommand/ContextBuilder.php +++ b/tests/src/Feature/Console/GenerateCommand/ContextBuilder.php @@ -8,6 +8,7 @@ use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; final readonly class ContextBuilder { @@ -73,7 +74,7 @@ private function runCommand( /** @psalm-suppress ArgumentTypeCoercion */ $output->setVerbosity($verbosityLevel ?? $this->defaultVerbosityLevel); - $this->console->run($command, $input, $output); + $this->console->run($command, $input, new SymfonyStyle($input, $output)); return $output->fetch(); } diff --git a/tests/src/Feature/McpTools/Traits/InteractsWithMcpTools.php b/tests/src/Feature/McpTools/Traits/InteractsWithMcpTools.php index 9e301dc3..7414352b 100644 --- a/tests/src/Feature/McpTools/Traits/InteractsWithMcpTools.php +++ b/tests/src/Feature/McpTools/Traits/InteractsWithMcpTools.php @@ -7,6 +7,7 @@ use Spiral\Console\Console; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; +use Symfony\Component\Console\Style\SymfonyStyle; use Tests\Feature\McpTools\ToolExecutionResult; /** @@ -38,8 +39,9 @@ protected function executeTool( $input['-c'] = $configPath; } + $input = new ArrayInput($input); $output = new BufferedOutput(); - $result = $console->run('tool:run', new ArrayInput($input), $output); + $result = $console->run('tool:run', $input, new SymfonyStyle($input, $output)); return new ToolExecutionResult( exitCode: $result->getCode(), @@ -70,7 +72,8 @@ protected function getToolSchema(string $toolId, ?string $configPath = null): ar $input['-c'] = $configPath; } - $console->run('tool:schema', new ArrayInput($input), $output); + $input = new ArrayInput($input); + $console->run('tool:schema', $input, new SymfonyStyle($input, $output)); $decoded = \json_decode($output->fetch(), true); diff --git a/tests/src/Unit/Source/TextSourceFromArrayTest.php b/tests/src/Unit/Source/TextSourceFromArrayTest.php index d36eff89..52511b12 100644 --- a/tests/src/Unit/Source/TextSourceFromArrayTest.php +++ b/tests/src/Unit/Source/TextSourceFromArrayTest.php @@ -11,6 +11,8 @@ class TextSourceFromArrayTest extends TestCase { + private TextSourceFactory $factory; + #[Test] public function it_should_create_from_array_with_minimal_parameters(): void {