GNUsocialTestCase.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // {{{ License
  3. // This file is part of GNU social - https://www.gnu.org/software/social
  4. //
  5. // GNU social is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU Affero General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // GNU social is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU Affero General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Affero General Public License
  16. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  17. // }}}
  18. /**
  19. * String formatting utilities
  20. *
  21. * @package GNUsocial
  22. * @category Util
  23. *
  24. * @author Hugo Sales <hugo@hsal.es>
  25. * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
  26. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  27. */
  28. namespace App\Util;
  29. use App\Core\GNUsocial;
  30. use Functional as F;
  31. use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
  32. class GNUsocialTestCase extends WebTestCase
  33. {
  34. private static GNUsocial $social;
  35. /**
  36. * Provide our own initialization for testing
  37. */
  38. public static function bootKernel(array $options = [])
  39. {
  40. $kernel = parent::bootKernel($options);
  41. $container = self::$kernel->getContainer()->get('test.service_container');
  42. $services = F\map(
  43. (new \ReflectionClass(GNUsocial::class))->getMethod('__construct')->getParameters(),
  44. function ($p) use ($container) { return $container->get((string) $p->getType()); }
  45. );
  46. self::$social = new GNUsocial(...$services);
  47. return $kernel;
  48. }
  49. }