Unverified Commit 5733c62b authored by larowlan's avatar larowlan

Issue #3088688 by alexpott: Remove PhantomJS based testing

parent 1ab63529
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "dae5dda860ab15f463191e5d55112484",
"content-hash": "11e97079b577249b708678d9fdb70cff",
"packages": [
{
"name": "asm89/stack-cors",
......@@ -4566,121 +4566,6 @@
],
"time": "2019-09-23T15:50:44+00:00"
},
{
"name": "jcalderonzumba/gastonjs",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/jcalderonzumba/gastonjs.git",
"reference": "21bebb8ca03eb0f93ec2f3fad61192fb079e2622"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jcalderonzumba/gastonjs/zipball/21bebb8ca03eb0f93ec2f3fad61192fb079e2622",
"reference": "21bebb8ca03eb0f93ec2f3fad61192fb079e2622",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "~5.0|~6.0",
"php": ">=5.4"
},
"require-dev": {
"phpunit/phpunit": "~4.6",
"silex/silex": "~1.2",
"symfony/phpunit-bridge": "~2.7",
"symfony/process": "~2.1"
},
"type": "phantomjs-api",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Zumba\\GastonJS\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Juan Francisco Calderón Zumba",
"email": "juanfcz@gmail.com",
"homepage": "http://github.com/jcalderonzumba"
}
],
"description": "PhantomJS API based server for webpage automation",
"homepage": "https://github.com/jcalderonzumba/gastonjs",
"keywords": [
"api",
"automation",
"browser",
"headless",
"phantomjs"
],
"time": "2016-01-18T09:21:03+00:00"
},
{
"name": "jcalderonzumba/mink-phantomjs-driver",
"version": "v0.3.2",
"source": {
"type": "git",
"url": "https://github.com/jcalderonzumba/MinkPhantomJSDriver.git",
"reference": "194942e14557b86467bf31e313f1370645d6c828"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jcalderonzumba/MinkPhantomJSDriver/zipball/194942e14557b86467bf31e313f1370645d6c828",
"reference": "194942e14557b86467bf31e313f1370645d6c828",
"shasum": ""
},
"require": {
"behat/mink": "~1.7",
"jcalderonzumba/gastonjs": "~1.0",
"php": ">=5.4",
"twig/twig": "~1.20|~2.0"
},
"require-dev": {
"mink/driver-testsuite": "dev-master",
"phpunit/phpunit": "~4.6"
},
"type": "mink-driver",
"extra": {
"branch-alias": {
"dev-master": "0.4.x-dev"
}
},
"autoload": {
"psr-4": {
"Zumba\\Mink\\Driver\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Juan Francisco Calderón Zumba",
"email": "juanfcz@gmail.com",
"homepage": "http://github.com/jcalderonzumba"
}
],
"description": "PhantomJS driver for Mink framework",
"homepage": "http://mink.behat.org/",
"keywords": [
"ajax",
"browser",
"headless",
"javascript",
"phantomjs",
"testing"
],
"time": "2016-10-04T09:27:04+00:00"
},
{
"name": "justinrainbow/json-schema",
"version": "5.2.8",
......
......@@ -12,8 +12,6 @@
"behat/mink-selenium2-driver": "1.4.0 | 1.3.1.1 | 1.3.x-dev",
"composer/composer": "^1.9.1",
"drupal/coder": "^8.3.2",
"jcalderonzumba/gastonjs": "^1.0.2",
"jcalderonzumba/mink-phantomjs-driver": "^0.3.1",
"justinrainbow/json-schema": "^5.2",
"mikey179/vfsstream": "^1.6.8",
"phpspec/prophecy": "^1.7",
......
......@@ -20,8 +20,6 @@
"drupal/coder": "8.3.6",
"fabpot/goutte": "v3.2.3",
"instaclick/php-webdriver": "1.4.6",
"jcalderonzumba/gastonjs": "v1.0.2",
"jcalderonzumba/mink-phantomjs-driver": "v0.3.2",
"justinrainbow/json-schema": "5.2.8",
"mikey179/vfsstream": "v1.6.8",
"myclabs/deep-copy": "1.7.0",
......
......@@ -34,8 +34,6 @@ class Composer {
'guzzlehttp/promises' => ['tests'],
'guzzlehttp/psr7' => ['tests'],
'instaclick/php-webdriver' => ['doc', 'test'],
'jcalderonzumba/gastonjs' => ['docs', 'examples', 'tests'],
'jcalderonzumba/mink-phantomjs-driver' => ['tests'],
'justinrainbow/json-schema' => ['demo'],
'masterminds/html5' => ['bin', 'test'],
'mikey179/vfsStream' => ['src/test'],
......
......@@ -7,7 +7,7 @@
use Drupal\Core\Url;
/**
* Test form for JSWebAssert JavaScriptTestBase.
* Test form for JSWebAssert WebDriverTestBase.
*
* @internal
*/
......
......@@ -32,8 +32,6 @@
<env name="MINK_DRIVER_CLASS" value=''/>
<!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' -->
<env name="MINK_DRIVER_ARGS" value=''/>
<!-- Example for changing the driver args to phantomjs tests MINK_DRIVER_ARGS_PHANTOMJS value: '["http://127.0.0.1:8510"]' -->
<env name="MINK_DRIVER_ARGS_PHANTOMJS" value=''/>
<!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" -->
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value=''/>
</php>
......
......@@ -151,7 +151,7 @@ protected function drupalGetWithAlert($path, array $options = [], array $headers
$this->metaRefreshCount = 0;
}
// Log only for JavascriptTestBase tests because for Goutte we log with
// Log only for WebDriverTestBase tests because for Goutte we log with
// ::getResponseLogHandler.
if ($this->htmlOutputEnabled && !($this->getSession()->getDriver() instanceof GoutteDriver)) {
$html_output = 'GET request to: ' . $url .
......
......@@ -221,9 +221,9 @@ public function waitOnAutocomplete() {
/**
* Test that a node, or its specific corner, is visible in the viewport.
*
* Note: Always set the viewport size. This can be done with a PhantomJS
* startup parameter or in your test with \Behat\Mink\Session->resizeWindow().
* Drupal CI Javascript tests by default use a viewport of 1024x768px.
* Note: Always set the viewport size. This can be done in your test with
* \Behat\Mink\Session->resizeWindow(). Drupal CI Javascript tests by default
* use a viewport of 1024x768px.
*
* @param string $selector_type
* The element selector type (CSS, XPath).
......@@ -441,7 +441,7 @@ public function assertEscaped($raw) {
* Escapes HTML for testing.
*
* Drupal's Html::escape() uses the ENT_QUOTES flag with htmlspecialchars() to
* escape both single and double quotes. With JavascriptTestBase testing the
* escape both single and double quotes. With WebDriverTestBase testing the
* browser is automatically converting &quot; and &#039; to double and single
* quotes respectively therefore we can not escape them when testing for
* escaped HTML.
......
......@@ -3,7 +3,7 @@
namespace Drupal\FunctionalJavascriptTests;
/**
* Tests Drupal settings retrieval in JavascriptTestBase tests.
* Tests Drupal settings retrieval in WebDriverTestBase tests.
*
* @group javascript
*/
......
<?php
namespace Drupal\FunctionalJavascriptTests;
@trigger_error('The ' . __NAMESPACE__ . '\JavascriptTestBase is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.0. Instead, use ' . __NAMESPACE__ . '\WebDriverTestBase. See https://www.drupal.org/node/2945059', E_USER_DEPRECATED);
use Zumba\Mink\Driver\PhantomJSDriver;
/**
* Runs a browser test using PhantomJS.
*
* Base class for testing browser interaction implemented in JavaScript.
*
* @deprecated in drupal:8.6.0 and is removed from drupal:9.0.0.
* Use \Drupal\FunctionalJavascriptTests\WebDriverTestBase instead
*
* @see https://www.drupal.org/node/2945059
*
* @ingroup testing
*/
abstract class JavascriptTestBase extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected $minkDefaultDriverClass = PhantomJSDriver::class;
/**
* {@inheritdoc}
*/
public function assertSession($name = NULL) {
// Return a WebAssert that supports status code and header assertions.
return new JSWebAssert($this->getSession($name), $this->baseUrl);
}
}
<?php
namespace Drupal\FunctionalJavascriptTests;
/**
* Runs a browser test using PhantomJS.
*
* @deprecated in drupal:8.6.0 and is removed from drupal:9.0.0.
* Use \Drupal\FunctionalJavascriptTests\WebDriverTestBase instead
*
* BC layer for testing browser interaction implemented in JavaScript.
*/
abstract class LegacyJavascriptTestBase extends JavascriptTestBase {
}
......@@ -5,8 +5,6 @@
use Behat\Mink\Exception\DriverException;
use Drupal\Tests\BrowserTestBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Zumba\GastonJS\Exception\DeadClient;
use Zumba\Mink\Driver\PhantomJSDriver;
/**
* Runs a browser test using a driver that supports Javascript.
......@@ -29,8 +27,6 @@ abstract class WebDriverTestBase extends BrowserTestBase {
/**
* {@inheritdoc}
*
* To use a legacy phantomjs based approach, please use PhantomJSDriver::class.
*/
protected $minkDefaultDriverClass = DrupalSelenium2Driver::class;
......@@ -38,27 +34,14 @@ abstract class WebDriverTestBase extends BrowserTestBase {
* {@inheritdoc}
*/
protected function initMink() {
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);
}
if (!is_a($this->minkDefaultDriverClass, DrupalSelenium2Driver::class, TRUE)) {
throw new \UnexpectedValueException(sprintf("%s has to be an instance of %s", $this->minkDefaultDriverClass, DrupalSelenium2Driver::class));
}
$this->minkDefaultDriverArgs = ['chrome', NULL, 'http://localhost:4444'];
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) {
if ($this->minkDefaultDriverClass === DrupalSelenium2Driver::class) {
$this->markTestSkipped("The test wasn't able to connect to your webdriver instance. For more information read core/tests/README.md.\n\nThe original message while starting Mink: {$e->getMessage()}");
......@@ -125,10 +108,7 @@ protected function tearDown() {
*/
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 getenv('MINK_DRIVER_ARGS_WEBDRIVER') ?: parent::getMinkDriverArgs();
}
return parent::getMinkDriverArgs();
}
......@@ -190,8 +170,8 @@ protected function assertJsCondition($condition, $timeout = 10000, $message = ''
* Creates a screenshot.
*
* @param string $filename
* The file name of the resulting screenshot. If using the default phantomjs
* driver then this should be a JPG filename.
* The file name of the resulting screenshot including a writeable path. For
* example, /tmp/test_screenshot.jpg.
* @param bool $set_background_color
* (optional) By default this method will set the background color to white.
* Set to FALSE to override this behaviour.
......
......@@ -108,7 +108,7 @@ protected function submitForm(array $edit, $submit, $form_html_id = NULL) {
$this->metaRefreshCount = 0;
}
// Log only for JavascriptTestBase tests because for Goutte we log with
// Log only for WebDriverTestBase tests because for Goutte we log with
// ::getResponseLogHandler.
if ($this->htmlOutputEnabled && !($this->getSession()->getDriver() instanceof GoutteDriver)) {
$out = $this->getSession()->getPage()->getContent();
......@@ -336,7 +336,7 @@ protected function drupalGet($path, array $options = [], array $headers = []) {
$this->metaRefreshCount = 0;
}
// Log only for JavascriptTestBase tests because for Goutte we log with
// Log only for WebDriverTestBase tests because for Goutte we log with
// ::getResponseLogHandler.
if ($this->htmlOutputEnabled && !($this->getSession()->getDriver() instanceof GoutteDriver)) {
$html_output = 'GET request to: ' . $url .
......@@ -462,7 +462,7 @@ protected function drupalUserIsLoggedIn(AccountInterface $account) {
protected function click($css_selector) {
$starting_url = $this->getSession()->getCurrentUrl();
$this->getSession()->getDriver()->click($this->cssSelectToXpath($css_selector));
// Log only for JavascriptTestBase tests because for Goutte we log with
// Log only for WebDriverTestBase tests because for Goutte we log with
// ::getResponseLogHandler.
if ($this->htmlOutputEnabled && !($this->getSession()->getDriver() instanceof GoutteDriver)) {
$out = $this->getSession()->getPage()->getContent();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment