From 2b16481756451c5b2a488eed0b73f885e2953bb0 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Wed, 21 Oct 2020 23:50:22 +0200 Subject: [PATCH 1/2] Update Symfony.php Adding hint about unused services not being available, see https://github.com/Codeception/Codeception/issues/5828 and https://stackoverflow.com/a/63131476/1668200 --- src/Codeception/Module/Symfony.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Codeception/Module/Symfony.php b/src/Codeception/Module/Symfony.php index 39756533..0c291d4a 100644 --- a/src/Codeception/Module/Symfony.php +++ b/src/Codeception/Module/Symfony.php @@ -571,7 +571,7 @@ public function grabService($service) { $container = $this->_getContainer(); if (!$container->has($service)) { - $this->fail("Service $service is not available in container"); + $this->fail("Service $service is not available in container. If the service isn't injected anywhere in your app, you need to set it to `public` in `services.php`/`.yaml`"); } return $container->get($service); } From 38d59328a70e4210149fcfc5ad0be10f6d46e8a9 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Thu, 22 Oct 2020 11:35:41 +0200 Subject: [PATCH 2/2] Update Symfony.php Switching to *test* config, see https://github.com/Codeception/Codeception/issues/5828#issuecomment-714061132 --- src/Codeception/Module/Symfony.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Codeception/Module/Symfony.php b/src/Codeception/Module/Symfony.php index 0c291d4a..cffeec4a 100644 --- a/src/Codeception/Module/Symfony.php +++ b/src/Codeception/Module/Symfony.php @@ -571,7 +571,9 @@ public function grabService($service) { $container = $this->_getContainer(); if (!$container->has($service)) { - $this->fail("Service $service is not available in container. If the service isn't injected anywhere in your app, you need to set it to `public` in `services.php`/`.yaml`"); + $this->fail("Service $service is not available in container. + If the service isn't injected anywhere in your app, you need to set it to `public` in your `config/services_test.php`/`.yaml`, + see https://symfony.com/doc/current/testing.html#accessing-the-container"); } return $container->get($service); }