Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / tests / Drupal / FunctionalJavascriptTests / JavascriptTestBase.php
index 8aa46c7ec1a3a47c82b5634cbe9ad0ef9c6aea36..55b1284f708a4fd4858da419f5b20d1f18bde3ed 100644 (file)
@@ -15,6 +15,9 @@ abstract class JavascriptTestBase extends BrowserTestBase {
 
   /**
    * {@inheritdoc}
+   *
+   * To use a webdriver based approach, please use DrupalSelenium2Driver::class.
+   * We will switch the default later.
    */
   protected $minkDefaultDriverClass = PhantomJSDriver::class;
 
@@ -22,14 +25,19 @@ abstract class JavascriptTestBase extends BrowserTestBase {
    * {@inheritdoc}
    */
   protected function initMink() {
-    // Set up the template cache used by the PhantomJS mink driver.
-    $path = $this->tempFilesDirectory . DIRECTORY_SEPARATOR . 'browsertestbase-templatecache';
-    $this->minkDefaultDriverArgs = [
-      'http://127.0.0.1:8510',
-      $path,
-    ];
-    if (!file_exists($path)) {
-      mkdir($path);
+    if ($this->minkDefaultDriverClass === DrupalSelenium2Driver::class) {
+      $this->minkDefaultDriverArgs = ['chrome', NULL, 'http://localhost:4444/'];
+    }
+    elseif ($this->minkDefaultDriverClass === PhantomJSDriver::class) {
+      // Set up the template cache used by the PhantomJS mink driver.
+      $path = $this->tempFilesDirectory . DIRECTORY_SEPARATOR . 'browsertestbase-templatecache';
+      $this->minkDefaultDriverArgs = [
+        'http://127.0.0.1:8510',
+        $path,
+      ];
+      if (!file_exists($path)) {
+        mkdir($path);
+      }
     }
 
     try {
@@ -63,6 +71,19 @@ abstract class JavascriptTestBase extends BrowserTestBase {
     parent::tearDown();
   }
 
+  /**
+    * {@inheritdoc}
+    */
+  protected function getMinkDriverArgs() {
+    if ($this->minkDefaultDriverClass === DrupalSelenium2Driver::class) {
+      return getenv('MINK_DRIVER_ARGS_WEBDRIVER') ?: getenv('MINK_DRIVER_ARGS_PHANTOMJS') ?: parent::getMinkDriverArgs();
+    }
+    elseif ($this->minkDefaultDriverClass === PhantomJSDriver::class) {
+      return getenv('MINK_DRIVER_ARGS_PHANTOMJS') ?: parent::getMinkDriverArgs();
+    }
+    return parent::getMinkDriverArgs();
+  }
+
   /**
    * Asserts that the element with the given CSS selector is visible.
    *
@@ -169,4 +190,12 @@ EndOfScript;
     return $this->getSession()->evaluateScript($script) ?: [];
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  protected function getHtmlOutputHeaders() {
+    // The webdriver API does not support fetching headers.
+    return '';
+  }
+
 }