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

Commit

Permalink
Fixing Process building for PHP 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
pietrinoatzenimfm committed Mar 5, 2019
1 parent e30a95a commit c02a209
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 34 deletions.
34 changes: 27 additions & 7 deletions src/NodeJS/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Behat\Mink\Driver\NodeJS;

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

/**
* Abstract base class to start and connect to a NodeJS server process.
Expand Down Expand Up @@ -358,16 +359,35 @@ public function start(Process $process = null)
$env['OPTIONS'] = json_encode($this->options);
}

$process = new Process(
array(
if (method_exists('\Symfony\Component\Process\Process', 'inheritEnvironmentVariables')) {
$process = new Process(
array(
$this->nodeBin,
$this->serverPath,
),
null,
$env
);

$process->inheritEnvironmentVariables();
} else {
$processBuilder = new ProcessBuilder(array(
$this->nodeBin,
$this->serverPath,
),
null,
$env
);
));
$processBuilder->setEnv('HOST', $this->host)
->setEnv('PORT', $this->port);

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

$process->inheritEnvironmentVariables();
if (!empty($this->options)) {
$processBuilder->setEnv('OPTIONS', json_encode($this->options));
}

$process = $processBuilder->getProcess();
}
}

$this->process = $process;
Expand Down
1 change: 1 addition & 0 deletions tests/Custom/InstantiationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Behat\Mink\Tests\Driver\Custom;

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

class InstantiationTestCase extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Custom/NodeJS/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

class TestServer extends BaseServer
{
Expand Down
26 changes: 0 additions & 26 deletions tests/Custom/TestCase.php

This file was deleted.

0 comments on commit c02a209

Please sign in to comment.