-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Hi!
I'm using my own KernelBrowser class via
<php>
<server name="KERNEL_BROWSER_CLASS" value="App\Tests\KernelBrowser" />
</php>
This class MUST extend Zenstruck\Browser\KernelBrowser as per check in HasBrowser::browser method.
However, the constructor of Zenstruck\Browser\KernelBrowser is final and I can't add stuff I use in all tests, e.g.
public function __construct(SymfonyKernelBrowser $client, array $options = [])
{
parent::__construct($client, $options);
$this->actingAs(new InMemoryUser('admin', 'admin', ['ROLE_ADMIN']));
->use(...);
}
Is this not intented way to extend the browser?
The other way I can achieve what I want is to override the HasBrowser::browser method itself in a parent abstract test case class, but this looks finicky TBH and makes PHPStan complain if in my tests, I want to use some other methods I've added to by Browser class:
use HasBrowser {
browser as protected baseBrowser;
}
protected function browser(array $options = [], array $server = []): KernelBrowser
{
return $this->baseBrowser($options, $server)
->actingAs(new InMemoryUser('admin', 'admin', ['ROLE_ADMIN']))
->use(...);
}
Metadata
Metadata
Assignees
Labels
No labels