Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Reanimate travis build #195

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
language: php

sudo: false

cache:
directories:
- $HOME/.composer/cache/files

php: [5.3, 5.4, 5.5, 5.6, 7.0, 7.1, hhvm]
php: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4]

env:
global:
- NODE_VERSION=''
- ZOMBIE_VERSION='@^3.0' # npm will install Zombie 4.x by default, even though it is not compatible with the version of node available on Travis.
# Force using PHP 5.6 for the webserver to be able to run it on PHP 5.3 and HHVM jobs too
- MINK_PHP_BIN=~/.phpenv/versions/5.6/bin/php
- ZOMBIE_VERSION=''
# Force binding to IPv4 as Zombie and PHP seem to have a different resolution for localhost on Travis.
- MINK_HOST=127.0.0.1:8002

matrix:
include:
- php: 5.6
env: ZOMBIE_VERSION='@^2.0'
- php: 5.4
dist: trusty
- php: 5.5
dist: trusty
- php: 5.3
dist: precise
env:
- MINK_PHP_BIN=~/.phpenv/versions/5.6/bin/php
- NODE_VERSION='8.12.0'
- php: 5.6
env:
- NODE_VERSION='5.4.1'
- ZOMBIE_VERSION='@^4.0'
- php: 5.6
env:
- NODE_VERSION='6.17.1'
- ZOMBIE_VERSION='@^5.0'

before_install:
- if [[ "$NODE_VERSION" != "" ]]; then wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz && tar xf node-v${NODE_VERSION}-linux-x64.tar.xz && export PATH="`pwd`/node-v${NODE_VERSION}-linux-x64/bin:$PATH"; fi
Expand All @@ -40,8 +47,7 @@ before_script:
# Start a webserver for web fixtures.
- vendor/bin/mink-test-server > /dev/null 2>&1 &

script: phpunit -v --coverage-clover=coverage.clover
script: vendor/bin/phpunit -v --coverage-clover=coverage.clover

after_script:
# XDebug is not yet available on PHP 7.1 so we don't have code coverage there. Not uploading it avoids telling Scrutinizer that it is missing
- if [[ "$TRAVIS_PHP_VERSION" != "7.1" ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
- wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover
43 changes: 32 additions & 11 deletions src/NodeJS/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Behat\Mink\Driver\NodeJS;

use Symfony\Component\Process\ProcessBuilder;
use Symfony\Component\Process\Process;

/**
Expand Down Expand Up @@ -344,24 +343,46 @@ public function start(Process $process = null)
));
}

// Create process object if neccessary
// Create process object if necessary
if (null === $process) {
$processBuilder = new ProcessBuilder(array(
$this->nodeBin,
$this->serverPath,
));
$processBuilder->setEnv('HOST', $this->host)
->setEnv('PORT', $this->port);
$env = array(
'HOST' => $this->host,
'PORT' => $this->port,
);

if (!empty($this->nodeModulesPath)) {
$processBuilder->setEnv('NODE_PATH', $this->nodeModulesPath);
$env['NODE_PATH'] = $this->nodeModulesPath;
}

if (!empty($this->options)) {
$processBuilder->setEnv('OPTIONS', json_encode($this->options));
$env['OPTIONS'] = json_encode($this->options);
}

$process = $processBuilder->getProcess();
$arguments = array($this->nodeBin, $this->serverPath);

if (\method_exists('Symfony\Component\Process\Process', 'escapeArgument')) {
// This is preferred way.
$commandLine = $arguments;
} else {
// This behavior is deprecated since Symfony 4.2.
$commandLine = implode(
' ',
array_map(array('Symfony\Component\Process\ProcessUtils', 'escapeArgument'), $arguments)
);

// Replace environment inheritance as was done by ProcessBuilder.
$env = array_replace($_ENV, $_SERVER, $env);
}

$process = new Process($commandLine, null, $env);
// to preserve the BC with symfony <3.3, we convert the array structure
// to a string structure to avoid the prefixing with the exec command
$process->setCommandLine($process->getCommandLine());

// Method was added in Symfony 3.2 and will be removed in Symfony 5.
if (\method_exists($process, 'inheritEnvironmentVariables')) {
$process->inheritEnvironmentVariables();
}
}
$this->process = $process;

Expand Down
9 changes: 7 additions & 2 deletions src/ZombieDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ public function getValue($xpath)
if (idx >= 0) {
value = node.options.item(idx).value;
} else {
value = null;
value = '';
}
}
} else {
Expand Down Expand Up @@ -570,6 +570,9 @@ public function setValue($xpath, $value)
throw new Error('The radio group "' + name + '" does not have an option "' + value + '"');
}
}
}
else if (type == 'file') {
browser.attach(node, value);
} else {
browser.fill(node, value);
}
Expand Down Expand Up @@ -918,7 +921,9 @@ protected function triggerKeyEvent($name, $xpath, $char, $modifier)
e.altKey = {$isAltKeyArg};
e.shiftKey = {$isShiftKeyArg};
e.metaKey = {$isMetaKeyArg};
e.keyCode = {$char};
e.charCode = {$char};
e.keyCode = {$char}; // deprecated.
e.which = {$char}; // deprecated.
node.dispatchEvent(e);
stream.end();
JS;
Expand Down
3 changes: 2 additions & 1 deletion tests/Custom/InstantiationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace Behat\Mink\Tests\Driver\Custom;

use Behat\Mink\Driver\ZombieDriver;
use PHPUnit\Framework\TestCase;

class InstantiationTest extends \PHPUnit_Framework_TestCase
class InstantiationTest extends TestCase
{
public function testInstantiateWithServer()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Custom/NodeJS/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Behat\Mink\Driver\NodeJS\Connection;
use Behat\Mink\Driver\NodeJS\Server as BaseServer;
use PHPUnit\Framework\TestCase;

class TestServer extends BaseServer
{
Expand Down Expand Up @@ -47,7 +48,7 @@ protected function getServerScript()
}
}

class ServerTest extends \PHPUnit_Framework_TestCase
class ServerTest extends TestCase
{
public function testCreateServerWithDefaults()
{
Expand Down