[Symfony 6] Remove setting services for test as public

This commit is contained in:
Mateusz Zalewski 2022-10-04 12:13:33 +02:00 committed by Grzegorz Sadowski
parent e95b96ff49
commit a49d879e3d
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
6 changed files with 12 additions and 18 deletions

View file

@ -20,12 +20,6 @@ final class Symfony6PrivateServicesPass implements CompilerPassInterface
$this->makeServicePublic('security.csrf.token_manager', $container);
$this->makeServicePublic('security.token_storage', $container);
$this->makeServicePublic('validator', $container);
if (str_starts_with((string) $container->getParameter('kernel.environment'), 'test')) {
$this->makeServicePublic('filesystem', $container);
$this->makeServicePublic('session.factory', $container);
$this->makeServicePublic('sylius.command_bus', $container);
}
}
private function makeServicePublic(string $serviceId, ContainerBuilder $container): void

View file

@ -38,7 +38,7 @@ final class OrdersTest extends JsonApiTestCase
$tokenValue = 'nAWw2jewpA';
/** @var MessageBusInterface $commandBus */
$commandBus = $this->get('sylius.command_bus');
$commandBus = self::getContainer()->get('sylius.command_bus');
$pickupCartCommand = new PickupCart($tokenValue);
$pickupCartCommand->setChannelCode('WEB');
@ -74,7 +74,7 @@ final class OrdersTest extends JsonApiTestCase
$tokenValue = 'nAWw2jewpA';
/** @var MessageBusInterface $commandBus */
$commandBus = $this->get('sylius.command_bus');
$commandBus = self::getContainer()->get('sylius.command_bus');
$pickupCartCommand = new PickupCart($tokenValue);
$pickupCartCommand->setChannelCode('WEB');
@ -99,7 +99,7 @@ final class OrdersTest extends JsonApiTestCase
$tokenValue = 'nAWw2jewpA';
/** @var MessageBusInterface $commandBus */
$commandBus = $this->get('sylius.command_bus');
$commandBus = self::getContainer()->get('sylius.command_bus');
$pickupCartCommand = new PickupCart($tokenValue);
$pickupCartCommand->setChannelCode('WEB');
@ -123,7 +123,7 @@ final class OrdersTest extends JsonApiTestCase
$tokenValue = 'nAWw2jewpA';
/** @var MessageBusInterface $commandBus */
$commandBus = $this->get('sylius.command_bus');
$commandBus = self::getContainer()->get('sylius.command_bus');
$pickupCartCommand = new PickupCart($tokenValue);
$pickupCartCommand->setChannelCode('WEB');
@ -162,7 +162,7 @@ final class OrdersTest extends JsonApiTestCase
$tokenValue = 'nAWw2jewpA';
/** @var MessageBusInterface $commandBus */
$commandBus = $this->get('sylius.command_bus');
$commandBus = self::getContainer()->get('sylius.command_bus');
$pickupCartCommand = new PickupCart($tokenValue);
$pickupCartCommand->setChannelCode('WEB');

View file

@ -29,7 +29,7 @@ final class PaymentMethodsTest extends JsonApiTestCase
$tokenValue = 'nAWw2jewpA';
/** @var MessageBusInterface $commandBus */
$commandBus = $this->get('sylius.command_bus');
$commandBus = self::getContainer()->get('sylius.command_bus');
$pickupCartCommand = new PickupCart($tokenValue, 'en_US');
$pickupCartCommand->setChannelCode('WEB');
@ -62,7 +62,7 @@ final class PaymentMethodsTest extends JsonApiTestCase
$tokenValue = 'nAWw2jewpA';
/** @var MessageBusInterface $commandBus */
$commandBus = $this->get('sylius.command_bus');
$commandBus = self::getContainer()->get('sylius.command_bus');
$pickupCartCommand = new PickupCart($tokenValue, 'en_US');
$pickupCartCommand->setChannelCode('WEB');
@ -95,7 +95,7 @@ final class PaymentMethodsTest extends JsonApiTestCase
$tokenValue = 'nAWw2jewpA';
/** @var MessageBusInterface $commandBus */
$commandBus = $this->get('sylius.command_bus');
$commandBus = self::getContainer()->get('sylius.command_bus');
$pickupCartCommand = new PickupCart($tokenValue, 'en_US');
$pickupCartCommand->setChannelCode('WEB');

View file

@ -190,7 +190,7 @@ final class ShippingMethodsTest extends JsonApiTestCase
private function getCartAndPutItemForCustomer(string $tokenValue, string $customer): void
{
/** @var MessageBusInterface $commandBus */
$commandBus = $this->get('sylius.command_bus');
$commandBus = self::getContainer()->get('sylius.command_bus');
$pickupCartCommand = new PickupCart($tokenValue, 'en_US');
$pickupCartCommand->setChannelCode('WEB');

View file

@ -30,7 +30,7 @@ trait OrderPlacerTrait
protected function placeOrder(string $tokenValue, string $email = 'sylius@example.com'): void
{
/** @var MessageBusInterface $commandBus */
$commandBus = $this->get('sylius.command_bus');
$commandBus = self::getContainer()->get('sylius.command_bus');
$pickupCartCommand = new PickupCart($tokenValue, 'en_US');
$pickupCartCommand->setChannelCode('WEB');

View file

@ -14,11 +14,11 @@ abstract class SessionAwareAjaxTest extends JsonApiTestCase
{
parent::setUp();
$requestStack = self::$kernel->getContainer()->get('request_stack');
$requestStack = self::getContainer()->get('request_stack');
try {
$requestStack->getSession();
} catch (SessionNotFoundException) {
$session = self::$kernel->getContainer()->get('session.factory')->createSession();
$session = self::getContainer()->get('session.factory')->createSession();
$request = new Request();
$request->setSession($session);
$requestStack->push($request);