Check if Client exists when test.client does not exist, to provide clearer exception message

This commit is contained in:
Serkan Yildiz 2019-03-07 16:18:06 +01:00 committed by Fabien Potencier
parent e9c8e19f46
commit b429950af6
1 changed files with 4 additions and 1 deletions

View File

@ -36,7 +36,10 @@ abstract class WebTestCase extends KernelTestCase
try {
$client = $kernel->getContainer()->get('test.client');
} catch (ServiceNotFoundException $e) {
throw new \LogicException('You cannot create the client used in functional tests if the BrowserKit component is not available. Try running "composer require symfony/browser-kit".');
if (class_exists(Client::class)) {
throw new \LogicException('You cannot create the client used in functional tests if the "framework.test" config is not set to true.');
}
throw new \LogicException('You cannot create the client used in functional tests if the BrowserKit component is not available. Try running "composer require symfony/browser-kit"');
}
$client->setServerParameters($server);