Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHPUnit tests on develop branch #1771

Merged
merged 1 commit into from
Dec 8, 2019
Merged
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
21 changes: 20 additions & 1 deletion tests/PhpWord/_includes/AbstractWebServerEmbeddedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,26 @@ abstract class AbstractWebServerEmbeddedTest extends \PHPUnit\Framework\TestCase
public static function setUpBeforeClass()
{
if (self::isBuiltinServerSupported()) {
self::$httpServer = new Process('php -S localhost:8080 -t tests/PhpWord/_files');
$commandLine = 'php -S localhost:8080 -t tests/PhpWord/_files';

/*
* Make sure to invoke \Symfony\Component\Process\Process correctly
* regardless of PHP version used.
*
* In Process version >= 5 / PHP >= 7.2.5, the constructor requires
* an array, while in version < 3.3 / PHP < 5.5.9 it requires a string.
* In between, it can accept both.
*
* Process::fromShellCommandLine() was introduced in version 4.2.0,
* to enable recent versions of Process to parse a command string,
* so if it is not available it means it is still possible to pass
* a string to the constructor.
*/
if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandLine')) {
self::$httpServer = Process::fromShellCommandline($commandLine);
} else {
self::$httpServer = new Process($commandLine);
}
self::$httpServer->start();
while (!self::$httpServer->isRunning()) {
usleep(1000);
Expand Down