From e1a1d01844a15fb5717d89cbcd222f6582dc5793 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Thu, 6 May 2021 19:37:38 +0000 Subject: [PATCH] [TESTS] Add GNUsocialTestCase, which initializes our infrastructure when bootKernel is called --- src/Util/GNUsocialTestCase.php | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/Util/GNUsocialTestCase.php diff --git a/src/Util/GNUsocialTestCase.php b/src/Util/GNUsocialTestCase.php new file mode 100644 index 0000000000..b76d418d84 --- /dev/null +++ b/src/Util/GNUsocialTestCase.php @@ -0,0 +1,55 @@ +. +// }}} + +/** + * String formatting utilities + * + * @package GNUsocial + * @category Util + * + * @author Hugo Sales + * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later + */ + +namespace App\Util; + +use App\Core\GNUsocial; +use Functional as F; +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; + +class GNUsocialTestCase extends WebTestCase +{ + private static GNUsocial $social; + + /** + * Provide our own initialization for testing + */ + public static function bootKernel(array $options = []) + { + $kernel = parent::bootKernel($options); + $container = self::$kernel->getContainer()->get('test.service_container'); + $services = F\map( + (new \ReflectionClass(GNUsocial::class))->getMethod('__construct')->getParameters(), + function ($p) use ($container) { return $container->get((string) $p->getType()); } + ); + self::$social = new GNUsocial(...$services); + return $kernel; + } +}