From 98352cfece92d9a25d54ba04a1559ded52915371 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Thu, 11 Nov 2021 12:31:54 +0000 Subject: [PATCH] [TESTS] Properly provide both createClient and bootKernel in test base class --- src/Util/GNUsocialTestCase.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Util/GNUsocialTestCase.php b/src/Util/GNUsocialTestCase.php index 05e70f9fa5..50ea215f2e 100644 --- a/src/Util/GNUsocialTestCase.php +++ b/src/Util/GNUsocialTestCase.php @@ -44,15 +44,27 @@ class GNUsocialTestCase extends WebTestCase /** * Provide our own initialization for testing */ + public static function createClient(array $options = [], array $server = []) + { + $client = parent::createClient($options, $server); + self::do_setup(); + return $client; + } + public static function bootKernel(array $options = []) { - $kernel = parent::bootKernel($options); + $kernel = parent::bootKernel(); + self::do_setup(); + return $kernel; + } + + private static function do_setup() + { $container = self::$kernel->getContainer()->get('test.service_container'); $services = F\map( (new ReflectionClass(GNUsocial::class))->getMethod('__construct')->getParameters(), fn ($p) => $container->get((string) $p->getType()), ); self::$social = new GNUsocial(...$services); - return $kernel; } }