Skip to content

Commit 9b5483a

Browse files
committed
Incorporating Pull Request 1771
That Pull Request is "Fix PHPUnit tests on Develop Branch".
1 parent 30e3981 commit 9b5483a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/PhpWord/_includes/AbstractWebServerEmbeddedTest.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,25 @@ abstract class AbstractWebServerEmbeddedTest extends \PHPUnit\Framework\TestCase
2626
public static function setUpBeforeClass()
2727
{
2828
if (self::isBuiltinServerSupported()) {
29-
self::$httpServer = new Process('php -S localhost:8080 -t tests/PhpWord/_files');
29+
$commandLine = 'php -S localhost:8080 -t tests/PhpWord/_files';
30+
/*
31+
* Make sure to invoke \Symfony\Component\Process\Process correctly
32+
* regardless of PHP version used.
33+
*
34+
* In Process version >= 5 / PHP >= 7.2.5, the constructor requires
35+
* an array, while in version < 3.3 / PHP < 5.5.9 it requires a string.
36+
* In between, it can accept both.
37+
*
38+
* Process::fromShellCommandLine() was introduced in version 4.2.0,
39+
* to enable recent versions of Process to parse a command string,
40+
* so if it is not available it means it is still possible to pass
41+
* a string to the constructor.
42+
*/
43+
if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandLine')) {
44+
self::$httpServer = Process::fromShellCommandline($commandLine);
45+
} else {
46+
self::$httpServer = new Process($commandLine);
47+
}
3048
self::$httpServer->start();
3149
while (!self::$httpServer->isRunning()) {
3250
usleep(1000);

0 commit comments

Comments
 (0)