Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Symfony 6] Remove setting services for test as public #14407

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,12 +20,6 @@ public function process(ContainerBuilder $container): void
$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
Expand Down
10 changes: 5 additions & 5 deletions tests/Api/Shop/OrdersTest.php
Expand Up @@ -38,7 +38,7 @@ public function it_gets_an_order(): void
$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');
Expand Down Expand Up @@ -74,7 +74,7 @@ public function it_gets_order_items(): void
$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');
Expand All @@ -99,7 +99,7 @@ public function it_gets_order_adjustments(): void
$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');
Expand All @@ -123,7 +123,7 @@ public function it_gets_order_item_adjustments(): void
$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');
Expand Down Expand Up @@ -162,7 +162,7 @@ public function it_allows_to_add_items_to_order(): void
$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');
Expand Down
6 changes: 3 additions & 3 deletions tests/Api/Shop/PaymentMethodsTest.php
Expand Up @@ -29,7 +29,7 @@ public function it_gets_available_payment_methods_from_payments(): void
$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');
Expand Down Expand Up @@ -62,7 +62,7 @@ public function it_gets_empty_response_if_only_payment_id_is_set_in_filter(): vo
$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');
Expand Down Expand Up @@ -95,7 +95,7 @@ public function it_gets_empty_response_if_only_cart_token_is_set_in_filter(): vo
$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');
Expand Down
2 changes: 1 addition & 1 deletion tests/Api/Shop/ShippingMethodsTest.php
Expand Up @@ -190,7 +190,7 @@ public function it_returns_empty_list_of_available_shipping_methods_for_not_exis
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');
Expand Down
2 changes: 1 addition & 1 deletion tests/Api/Utils/OrderPlacerTrait.php
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions tests/Controller/SessionAwareAjaxTest.php
Expand Up @@ -14,11 +14,11 @@ protected function setUp(): void
{
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);
Expand Down