Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / tests / Drupal / FunctionalJavascriptTests / DrupalSelenium2Driver.php
diff --git a/web/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php b/web/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php
new file mode 100644 (file)
index 0000000..5f243af
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+namespace Drupal\FunctionalJavascriptTests;
+
+use Behat\Mink\Driver\Selenium2Driver;
+
+/**
+ * Provides a driver for Selenium testing.
+ */
+class DrupalSelenium2Driver extends Selenium2Driver {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setCookie($name, $value = NULL) {
+    if ($value === NULL) {
+      $this->getWebDriverSession()->deleteCookie($name);
+      return;
+    }
+
+    $cookieArray = [
+      'name' => $name,
+      'value' => urlencode($value),
+      'secure' => FALSE,
+      // Unlike \Behat\Mink\Driver\Selenium2Driver::setCookie we set a domain
+      // and an expire date, as otherwise cookies leak from one test site into
+      // another.
+      'domain' => parse_url($this->getWebDriverSession()->url(), PHP_URL_HOST),
+      'expires' => time() + 80000,
+    ];
+
+    $this->getWebDriverSession()->setCookie($cookieArray);
+  }
+
+}