protected function BrowserTestBase::getDefaultDriverInstance in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/simpletest/src/BrowserTestBase.php \Drupal\simpletest\BrowserTestBase::getDefaultDriverInstance()
Gets an instance of the default Mink driver.
Return value
Behat\Mink\Driver\DriverInterface Instance of default Mink driver.
Throws
\InvalidArgumentException When provided default Mink driver class can't be instantiated.
1 call to BrowserTestBase::getDefaultDriverInstance()
- BrowserTestBase::initMink in core/
modules/ simpletest/ src/ BrowserTestBase.php - Initializes Mink sessions.
File
- core/
modules/ simpletest/ src/ BrowserTestBase.php, line 241 - Contains \Drupal\simpletest\BrowserTestBase.
Class
- BrowserTestBase
- Provides a test case for functional Drupal tests.
Namespace
Drupal\simpletestCode
protected function getDefaultDriverInstance() {
// Get default driver params from environment if availables.
if ($arg_json = getenv('MINK_DRIVER_ARGS')) {
$this->minkDefaultDriverArgs = json_decode($arg_json);
}
// Get and check default driver class from environment if availables.
if ($minkDriverClass = getenv('MINK_DRIVER_CLASS')) {
if (class_exists($minkDriverClass)) {
$this->minkDefaultDriverClass = $minkDriverClass;
}
else {
throw new \InvalidArgumentException("Can't instantiate provided {$minkDriverClass} class by environment as default driver class.");
}
}
if (is_array($this->minkDefaultDriverArgs)) {
// Use ReflectionClass to instantiate class with received params.
$reflector = new ReflectionClass($this->minkDefaultDriverClass);
$driver = $reflector
->newInstanceArgs($this->minkDefaultDriverArgs);
}
else {
$driver = new $this->minkDefaultDriverClass();
}
return $driver;
}