Skip to content

[RFC] make Mink use KernelBrowser::$defaultHttpOptions #181

Description

@nikophil

Hello,

In my tests, I like to do stuff like this:

$this->browser()
    ->useTurbo()
    ->actAsUserWithRoles('ROLE_1', 'ROLE_2')
   // ->maybeOtherStuff()

those methods exists because I'm using a custom browser:

use Zenstruck\Browser\KernelBrowser;

final class MyCustom extends KernelBrowser
{
    public function actAsUserWithRoles('(string $role, string ...$roles): self

    public function useTurbo(): self
}

all along those methods, I modify the protected property KernelBrowser::$defaultHttpOptions.

So far, so good, I can make any requests with ->get(), ->post(), etc... which will use my prerequisites for the client

Until I want I'm using ->click() or stuff that use Mink under the hood.

The problem is because mink does not access to $defaultHttpOptions, and it directly call the (Symfony) client created in ->browser() method.

I think we can mitigate the problem by deferring the creation of the Symfony client (by using a closure) until the first moment we actually need the mink session.

Another solution may be that somehow, \Zenstruck\Browser\Session\Driver\BrowserKitDriver could access the default http options (not sure how to do that)

EDIT: even in 2.x without Mink, I think the problem still exist

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions