test.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DependencyInjection\Loader\Configurator;
  11. use Symfony\Bundle\FrameworkBundle\KernelBrowser;
  12. use Symfony\Bundle\FrameworkBundle\Test\TestContainer;
  13. use Symfony\Component\BrowserKit\CookieJar;
  14. use Symfony\Component\BrowserKit\History;
  15. use Symfony\Component\DependencyInjection\ServiceLocator;
  16. use Symfony\Component\HttpKernel\EventListener\TestSessionListener;
  17. return static function (ContainerConfigurator $container) {
  18. $container->parameters()->set('test.client.parameters', []);
  19. $container->services()
  20. ->set('test.client', KernelBrowser::class)
  21. ->args([
  22. service('kernel'),
  23. param('test.client.parameters'),
  24. service('test.client.history'),
  25. service('test.client.cookiejar'),
  26. ])
  27. ->share(false)
  28. ->public()
  29. ->set('test.client.history', History::class)->share(false)
  30. ->set('test.client.cookiejar', CookieJar::class)->share(false)
  31. ->set('test.session.listener', TestSessionListener::class)
  32. ->args([
  33. service_locator([
  34. 'session' => service('session')->ignoreOnInvalid(),
  35. ]),
  36. ])
  37. ->tag('kernel.event_subscriber')
  38. ->set('test.service_container', TestContainer::class)
  39. ->args([
  40. service('kernel'),
  41. 'test.private_services_locator',
  42. ])
  43. ->public()
  44. ->set('test.private_services_locator', ServiceLocator::class)
  45. ->args([abstract_arg('callable collection')])
  46. ->public()
  47. ;
  48. };