Skip to content

Commit d8a8943

Browse files
Update ServicesAssertionsTrait.php: Adding another hint about private services (#210)
1 parent c3a1c42 commit d8a8943

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Codeception/Module/Symfony/ServicesAssertionsTrait.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ trait ServicesAssertionsTrait
1111
{
1212
/**
1313
* Grabs a service from the Symfony dependency injection container (DIC).
14-
* In "test" environment, Symfony uses a special `test.service_container`.
14+
* In the "test" environment, Symfony uses a special `test.service_container`.
1515
* See the "[Public Versus Private Services](https://symfony.com/doc/current/service_container/alias_private.html#marking-services-as-public-private)" documentation.
16-
* Services that aren't injected somewhere into your app, need to be defined as `public` to be accessible by Codeception.
16+
* Services that aren't injected anywhere in your app, need to be defined as `public` to be accessible by Codeception.
1717
*
1818
* ```php
1919
* <?php
@@ -25,10 +25,10 @@ trait ServicesAssertionsTrait
2525
public function grabService(string $serviceId): object
2626
{
2727
if (!$service = $this->getService($serviceId)) {
28-
Assert::fail(
29-
"Service `{$serviceId}` is required by Codeception, but not loaded by Symfony since you're not using it anywhere in your app.\n
30-
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"
31-
);
28+
Assert::fail("Service `{$serviceId}` is required by Codeception, but not loaded by Symfony. Possible solutions:\n
29+
In your `config/packages/framework.php`/`.yaml`, set `test` to `true` (when in test environment), see https://symfony.com/doc/current/reference/configuration/framework.html#test\n
30+
If you're still getting this message, you're not using that service in your app, so Symfony isn't loading it at all.\n
31+
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");
3232
}
3333

3434
return $service;

0 commit comments

Comments
 (0)