-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
BugDXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)FrameworkBundleStatus: Needs Review
Description
Symfony version(s) affected: 4.2.4
Description
This situation can happen accidentally, because it might not be obvious when second kernel is being created. In our situation, we were creating objects in setUp
method and saving them in properties, which is usual. In test cases itself we use self::createClient()
.
If we attempt to use one of these objects we saved earlier, this leads to error
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException : The "kernel" service is synthetic, it needs to be set at boot time before it can be used.
At this point it's really hard to find out what's wrong if you don't realize you booted kernel twice and took a guess that this is what's causing the problem.
How to reproduce
public function testIndex()
{
$router = static::bootKernel()->getContainer()->get('router');
$client = static::createClient();
$router->getRouteCollection();
}
Metadata
Metadata
Assignees
Labels
BugDXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)FrameworkBundleStatus: Needs Review