Skip to content

Commit ce2a392

Browse files
Improving error message for public services (#145)
1 parent c376568 commit ce2a392

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Codeception/Module/Symfony/ServicesAssertionsTrait.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ trait ServicesAssertionsTrait
2626
public function grabService(string $serviceId): object
2727
{
2828
if (!$service = $this->getService($serviceId)) {
29-
$this->fail("Service {$serviceId} is not available in container.
30-
If the service isn't injected anywhere in your app, you need to set it to `public` in your `config/services_test.php`/`.yaml`,
31-
see https://symfony.com/doc/current/testing.html#accessing-the-container");
29+
$this->fail("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/testing.html#retrieving-services-in-the-test");
3231
}
3332
return $service;
3433
}
@@ -92,4 +91,4 @@ protected function getService(string $serviceId): ?object
9291
}
9392
return null;
9493
}
95-
}
94+
}

0 commit comments

Comments
 (0)