From 84d74f715c806c7003e76d72c91d4cb356c0b669 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com> Date: Wed, 24 Apr 2024 11:42:01 +0700 Subject: [PATCH] build: enable symfony/runtime (#48) --- composer.json | 6 +++++- tests/Common/TestKernel.php | 9 ++++++--- tests/console | 13 +++++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 11a972c..100f37f 100644 --- a/composer.json +++ b/composer.json @@ -55,6 +55,7 @@ "psalm/plugin-phpunit": "^0.18.4", "symfony/framework-bundle": "^6.4 || ^7.0", "symfony/http-kernel": "^6.4 || ^7.0", + "symfony/runtime": "^6.4 || ^7.0", "symfony/uid": "^6.4 || ^7.0", "symfony/var-dumper": "^6.4 || ^7.0", "symfony/yaml": "^6.4 || ^7.0", @@ -73,6 +74,9 @@ } }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "symfony/runtime": true + } } } diff --git a/tests/Common/TestKernel.php b/tests/Common/TestKernel.php index b8f44af..97313b7 100644 --- a/tests/Common/TestKernel.php +++ b/tests/Common/TestKernel.php @@ -38,9 +38,12 @@ class TestKernel extends Kernel /** * @param array $config */ - public function __construct(private array $config = []) - { - parent::__construct('test', true); + public function __construct( + private array $config = [], + string $env = 'test', + bool $debug = true + ) { + parent::__construct($env, $debug); } public function registerBundles(): iterable diff --git a/tests/console b/tests/console index deb290b..6391b4c 100755 --- a/tests/console +++ b/tests/console @@ -17,8 +17,13 @@ namespace Rekalogika\Mapper\Tests; use Rekalogika\Mapper\Tests\Common\TestKernel; use Symfony\Bundle\FrameworkBundle\Console\Application; -require_once __DIR__ . '/../vendor/autoload.php'; +require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; -$kernel = new TestKernel(); -$application = new Application($kernel); -$application->run(); +return function (array $context) { + $env = $context['APP_ENV'] ?? 'test'; + assert(is_string($env)); + + $kernel = new TestKernel([], $env, (bool) $context['APP_DEBUG']); + + return new Application($kernel); +};