function BrowserTestBase::initMink

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::initMink()
  2. 10 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::initMink()
  3. 11.x core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::initMink()

Initializes Mink sessions.

4 calls to BrowserTestBase::initMink()
BrowserTestBase::setUp in core/tests/Drupal/Tests/BrowserTestBase.php
InstallerTestBase::setUp in core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
UpdatePathTestBase::setUp in core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php
Overrides BrowserTestBase::setUp() for update testing.
WebDriverTestBase::initMink in core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php
Initializes Mink sessions.
1 method overrides BrowserTestBase::initMink()
WebDriverTestBase::initMink in core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php
Initializes Mink sessions.

File

core/tests/Drupal/Tests/BrowserTestBase.php, line 220

Class

BrowserTestBase
Provides a test case for functional Drupal tests.

Namespace

Drupal\Tests

Code

protected function initMink() {
    $driver = $this->getDefaultDriverInstance();
    if ($driver instanceof BrowserKitDriver) {
        // Turn off curl timeout. Having a timeout is not a problem in a normal
        // test running, but it is a problem when debugging. Also, disable SSL
        // peer verification so that testing under HTTPS always works.
        
        /** @var \GuzzleHttp\Client $client */
        $client = $this->container
            ->get('http_client_factory')
            ->fromOptions([
            'timeout' => NULL,
            'verify' => FALSE,
        ]);
        // Inject a Guzzle middleware to generate debug output for every request
        // performed in the test.
        $handler_stack = $client->getConfig('handler');
        $handler_stack->push($this->getResponseLogHandler());
        $driver->getClient()
            ->setClient($client);
    }
    $selectors_handler = new SelectorsHandler([
        'hidden_field_selector' => new HiddenFieldSelector(),
    ]);
    $session = new Session($driver, $selectors_handler);
    $this->mink = new Mink();
    $this->mink
        ->registerSession('default', $session);
    $this->mink
        ->setDefaultSessionName('default');
    $this->registerSessions();
    $this->initFrontPage();
    // Copies cookies from the current environment, for example, XDEBUG_SESSION
    // in order to support Xdebug.
    // @see BrowserTestBase::initFrontPage()
    $cookies = $this->extractCookiesFromRequest(\Drupal::request());
    foreach ($cookies as $cookie_name => $values) {
        foreach ($values as $value) {
            $session->setCookie($cookie_name, $value);
        }
    }
    return $session;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.