Skip to content

Commit

Permalink
[minor] allow setting server parameters to kernel browser
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Nov 2, 2021
1 parent 9bce254 commit 05736e9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Browser/Test/HasBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected function httpBrowser(array $kernelOptions = [], array $pantherOptions
;
}

protected function browser(array $options = []): KernelBrowser
protected function browser(array $kernelOptions = [], array $server = []): KernelBrowser
{
if (!$this instanceof KernelTestCase) {
throw new \RuntimeException(\sprintf('The "%s" method can only be used on TestCases that extend "%s".', __METHOD__, KernelTestCase::class));
Expand All @@ -128,16 +128,19 @@ protected function browser(array $options = []): KernelBrowser
if ($this instanceof WebTestCase) {
static::ensureKernelShutdown();

$browser = new $class(static::createClient($options));
$browser = new $class(static::createClient($kernelOptions, $server));
} else {
// reboot kernel before starting browser
static::bootKernel($options);
static::bootKernel($kernelOptions);

if (!static::$container->has('test.client')) {
throw new \RuntimeException('The Symfony test client is not enabled.');
}

$browser = new $class(static::$container->get('test.client'));
$client = static::$container->get('test.client');
$client->setServerParameters($server);

$browser = new $class($client);
}

BrowserExtension::registerBrowser($browser);
Expand Down

0 comments on commit 05736e9

Please sign in to comment.