Skip to content

Commit 5489c7d

Browse files
Update ServicesAssertionsTrait.php: Adding another hint about private services
If this setting is missing, `test.private_services_locator` isn't loaded. Just encountered this problem in one of my projects...
1 parent d9084f5 commit 5489c7d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Codeception/Module/Symfony/ServicesAssertionsTrait.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ trait ServicesAssertionsTrait
1010
{
1111
/**
1212
* Grabs a service from the Symfony dependency injection container (DIC).
13-
* In "test" environment, Symfony uses a special `test.service_container`.
13+
* In the "test" environment, Symfony uses a special `test.service_container`.
1414
* See the "[Public Versus Private Services](https://symfony.com/doc/current/service_container/alias_private.html#marking-services-as-public-private)" documentation.
15-
* Services that aren't injected somewhere into your app, need to be defined as `public` to be accessible by Codeception.
15+
* Services that aren't injected anywhere in your app, need to be defined as `public` to be accessible by Codeception.
1616
*
1717
* ```php
1818
* <?php
@@ -25,7 +25,8 @@ public function grabService(string $serviceId): object
2525
{
2626
if (!$service = $this->getService($serviceId)) {
2727
$this->fail("Service `{$serviceId}` is required by Codeception, but not loaded by Symfony since you're not using it anywhere in your app.\n
28-
Recommended solution: Set it to `public` in your `config/services_test.php`/`.yaml`, see https://symfony.com/doc/current/service_container/alias_private.html#marking-services-as-public-private");
28+
Recommended solution: Set it to `public` in your `config/services.php`/`.yaml`, see https://symfony.com/doc/current/service_container/alias_private.html#marking-services-as-public-private\n
29+
Besides, `test` needs to be set to `true` in your `config/packages/framework.php`/`.yaml`, see https://symfony.com/doc/current/reference/configuration/framework.html#test");
2930
}
3031

3132
return $service;

0 commit comments

Comments
 (0)