Problem/Motivation

If using a different driver instance and not DrupalTestBrowser \Drupal\Tests\BrowserTestBase::initMink crashes as it assumes the abstract browser instance has a method for setting the HTTP client.

$driver->getClient()->setClient($client); this fails.

Steps to reproduce

I was experimenting with \Symfony\Component\HttpKernel\HttpKernelBrowser.

  protected function getDefaultDriverInstance() {
    return new BrowserKitDriver(new HttpKernelBrowser(
      $this->container->get('http_kernel')
    ));
  }

but initMink crashes with this.

Proposed resolution

Verify the driver's client is instance of DrupalTestBrowser

$driver->getClient() instanceof DrupalTestBrowser

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3553671

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Status: Active » Needs review
larowlan’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Performance, +DX (Developer Experience)

Looks good to me

mglaman’s picture

Thanks @larowlan!

longwave’s picture

Version: 11.x-dev » 10.5.x-dev
Status: Reviewed & tested by the community » Fixed

UiHelperTrait::isTestUsingGuzzleClient() does the same check, but needs the session to be initialised first - this is the code that does that initialisation, so we can't easily reuse it. Given this is a one line change this seems fine.

Backported down to 10.5.x as an eligible bug fix.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • longwave committed 4278605a on 10.5.x
    fix: #3553671 BrowserTestBase::initMink crashes if not using...

  • longwave committed 76658c29 on 10.6.x
    fix: #3553671 BrowserTestBase::initMink crashes if not using...

  • longwave committed 15191aaa on 11.2.x
    fix: #3553671 BrowserTestBase::initMink crashes if not using...

  • longwave committed a019a017 on 11.3.x
    fix: #3553671 BrowserTestBase::initMink crashes if not using...

  • longwave committed 2cf25946 on 11.x
    fix: #3553671 BrowserTestBase::initMink crashes if not using...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.