File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,25 @@ 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
+ * 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
+ }
30
48
self ::$ httpServer ->start ();
31
49
while (!self ::$ httpServer ->isRunning ()) {
32
50
usleep (1000 );
You can’t perform that action at this time.
0 commit comments