Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7961a29

Browse filesBrowse files
committed
improve error message when using test client without the BrowserKit component
1 parent f82beb5 commit 7961a29
Copy full SHA for 7961a29

File tree

Expand file treeCollapse file tree

2 files changed

+12
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-1
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
1919
use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
2020
use Symfony\Bundle\FullStack;
21+
use Symfony\Component\BrowserKit\Client;
2122
use Symfony\Component\Cache\Adapter\AbstractAdapter;
2223
use Symfony\Component\Cache\Adapter\AdapterInterface;
2324
use Symfony\Component\Cache\Adapter\ArrayAdapter;
@@ -223,6 +224,10 @@ public function load(array $configs, ContainerBuilder $container)
223224
$container->getDefinition('test.client.history')->setPrivate(true);
224225
$container->getDefinition('test.client.cookiejar')->setPrivate(true);
225226
$container->getDefinition('test.session.listener')->setPrivate(true);
227+
228+
if (!class_exists(Client::class)) {
229+
$container->removeDefinition('test.client');
230+
}
226231
}
227232

228233
if ($this->isConfigEnabled($container, $config['session'])) {

‎src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Test;
1313

1414
use Symfony\Bundle\FrameworkBundle\Client;
15+
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
1516

1617
/**
1718
* WebTestCase is the base class for functional tests.
@@ -32,7 +33,12 @@ protected static function createClient(array $options = array(), array $server =
3233
{
3334
$kernel = static::bootKernel($options);
3435

35-
$client = $kernel->getContainer()->get('test.client');
36+
try {
37+
$client = $kernel->getContainer()->get('test.client');
38+
} catch (ServiceNotFoundException $e) {
39+
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".');
40+
}
41+
3642
$client->setServerParameters($server);
3743

3844
return $client;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.