protected function BrowserTestBase::initMink in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::initMink()
- 10 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 WebTestBase::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 226
Class
- BrowserTestBase
- Provides a test case for functional Drupal tests.
Namespace
Drupal\TestsCode
protected function initMink() {
$driver = $this
->getDefaultDriverInstance();
if ($driver instanceof GoutteDriver) {
// 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;
}