diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php index fe7692a66a..81d379f915 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php @@ -366,26 +366,4 @@ function t(r, lx, ly) { return $this->session->evaluateScript($full_javascript_visibility_test); } - /** - * Overrides statusCodeEquals function. Use Functional tests for status code validation - * - * @param int $code - * - */ - public function statusCodeEquals($code) - { - // should we throw an error? - } - - /** - * Overrides statusCodeEquals function. Use Functional tests for status code validation - * - * @param int $code - * - */ - public function statusCodeNotEquals($code) - { - // should we throw an error? - } - } diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php index 37ff82a04e..bbdde6f33a 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php @@ -2,9 +2,10 @@ namespace Drupal\FunctionalJavascriptTests; -use Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver; use Behat\Mink\Exception\DriverException; use Drupal\Tests\BrowserTestBase; +use Zumba\GastonJS\Exception\DeadClient; +use Zumba\Mink\Driver\PhantomJSDriver; /** * Runs a browser test using a driver that supports Javascript. @@ -15,18 +16,37 @@ /** * {@inheritdoc} + * + * To use a webdriver based approach, please use DrupalSelenium2Driver::class. + * We will switch the default later. */ - protected $minkDefaultDriverClass = DrupalSelenium2Driver::class; + protected $minkDefaultDriverClass = PhantomJSDriver::class; /** * {@inheritdoc} */ protected function initMink() { - $this->minkDefaultDriverArgs = ['phantomjs']; + if ($this->minkDefaultDriverClass === DrupalSelenium2Driver::class) { + $this->minkDefaultDriverArgs = ['phantomjs']; + } + 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 { return parent::initMink(); } + catch (DeadClient $e) { + $this->markTestSkipped('PhantomJS is either not installed or not running. Start it via phantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768&'); + } catch (DriverException $e) { $this->markTestSkipped($e->getMessage()); } @@ -165,7 +185,7 @@ protected function getDrupalSettings() { * {@inheritdoc} */ protected function getHtmlOutputHeaders() { - // No headers on the selenium driver, nothing to show. + // The webdriver API does not support fetching headers. return ''; } diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebWithWebDriverAssertTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebWithWebDriverAssertTest.php index cfead7227d..d31a9a51c3 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebWithWebDriverAssertTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebWithWebDriverAssertTest.php @@ -2,14 +2,18 @@ namespace Drupal\FunctionalJavascriptTests\Tests; -use Behat\Mink\Element\NodeElement; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver; /** - * Tests for the JSWebAssert class. + * Tests for the JSWebAssert class using webdriver. * * @group javascript */ class JSWebWithWebDriverAssertTest extends JSWebAssertTest { + /** + * {@inheritdoc} + */ + protected $minkDefaultDriverClass = DrupalSelenium2Driver::class; + }