From c3b59ca675463c7e7a4620d556635deb63d9dc5f Mon Sep 17 00:00:00 2001 From: Supun Wimalasena Date: Tue, 24 Feb 2026 12:22:58 +0100 Subject: [PATCH 1/2] command tester method --- bundle/src/Testing/BaseTestingTrait.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bundle/src/Testing/BaseTestingTrait.php b/bundle/src/Testing/BaseTestingTrait.php index ca40f10..3286483 100644 --- a/bundle/src/Testing/BaseTestingTrait.php +++ b/bundle/src/Testing/BaseTestingTrait.php @@ -7,10 +7,12 @@ use Hyvor\Internal\Bundle\Comms\MockComms; use Hyvor\Internal\Bundle\EventDispatcher\TestEventDispatcher; use Monolog\Handler\TestHandler; +use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Messenger\MessageBusInterface; use Zenstruck\Foundry\Test\Factories; use Zenstruck\Messenger\Test\InteractsWithMessenger; +use Symfony\Bundle\FrameworkBundle\Console\Application; trait BaseTestingTrait { @@ -73,4 +75,11 @@ public function setEnvVar(string $key, string $value): void $_ENV[$key] = $value; } + public function getCommandTester(string $command): CommandTester + { + $application = new Application(self::$kernel); + $command = $application->find($command); + return new CommandTester($command); + } + } From aed83116970055a050043e23bf91a0b6816367f5 Mon Sep 17 00:00:00 2001 From: Supun Wimalasena Date: Tue, 24 Feb 2026 12:26:27 +0100 Subject: [PATCH 2/2] test fixes --- bundle/src/Testing/BaseTestingTrait.php | 1 + tests/Bundle/Testing/ApiTestingTraitTest.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/bundle/src/Testing/BaseTestingTrait.php b/bundle/src/Testing/BaseTestingTrait.php index 3286483..df89da8 100644 --- a/bundle/src/Testing/BaseTestingTrait.php +++ b/bundle/src/Testing/BaseTestingTrait.php @@ -77,6 +77,7 @@ public function setEnvVar(string $key, string $value): void public function getCommandTester(string $command): CommandTester { + assert(self::$kernel !== null); $application = new Application(self::$kernel); $command = $application->find($command); return new CommandTester($command); diff --git a/tests/Bundle/Testing/ApiTestingTraitTest.php b/tests/Bundle/Testing/ApiTestingTraitTest.php index d32196f..c506215 100644 --- a/tests/Bundle/Testing/ApiTestingTraitTest.php +++ b/tests/Bundle/Testing/ApiTestingTraitTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\AbstractBrowser; use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\HttpKernel\KernelInterface; class ApiTestingTraitTest extends TestCase { @@ -15,6 +16,7 @@ class ApiTestingTraitTest extends TestCase private static int $status; public Container $container; + public static ?KernelInterface $kernel = null; /** * @param array $json