File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,26 @@ abstract class AbstractWebServerEmbeddedTest extends \PHPUnit\Framework\TestCase
26
26
public static function setUpBeforeClass ()
27
27
{
28
28
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
+ /*
32
+ * Make sure to invoke \Symfony\Component\Process\Process correctly
33
+ * regardless of PHP version used.
34
+ *
35
+ * In Process version >= 5 / PHP >= 7.2.5, the constructor requires
36
+ * an array, while in version < 3.3 / PHP < 5.5.9 it requires a string.
37
+ * In between, it can accept both.
38
+ *
39
+ * Process::fromShellCommandLine() was introduced in version 4.2.0,
40
+ * to enable recent versions of Process to parse a command string,
41
+ * so if it is not available it means it is still possible to pass
42
+ * a string to the constructor.
43
+ */
44
+ if (method_exists ('Symfony\Component\Process\Process ' , 'fromShellCommandLine ' )) {
45
+ self ::$ httpServer = Process::fromShellCommandline ($ commandLine );
46
+ } else {
47
+ self ::$ httpServer = new Process ($ commandLine );
48
+ }
30
49
self ::$ httpServer ->start ();
31
50
while (!self ::$ httpServer ->isRunning ()) {
32
51
usleep (1000 );
You can’t perform that action at this time.
0 commit comments