Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/PantherTestCaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ trait PantherTestCaseTrait
'port' => 9080,
'router' => '',
'external_base_uri' => null,
'readinessPath' => '',
];

public static function tearDownAfterClass(): void
Expand Down Expand Up @@ -113,6 +114,7 @@ public static function startWebServer(array $options = []): void
'hostname' => $options['hostname'] ?? self::$defaultOptions['hostname'],
'port' => (int) ($options['port'] ?? $_SERVER['PANTHER_WEB_SERVER_PORT'] ?? self::$defaultOptions['port']),
'router' => $options['router'] ?? $_SERVER['PANTHER_WEB_SERVER_ROUTER'] ?? self::$defaultOptions['router'],
'readinessPath' => $options['readinessPath'] ?? $_SERVER['PANTHER_READINESS_PATH'] ?? self::$defaultOptions['readinessPath'],
];

self::$webServerManager = new WebServerManager(...array_values($options));
Expand Down
12 changes: 10 additions & 2 deletions src/ProcessManager/WebServerManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class WebServerManager

private $hostname;
private $port;
private $readinessPath;

/**
* @var Process
Expand All @@ -34,10 +35,11 @@ final class WebServerManager
/**
* @throws \RuntimeException
*/
public function __construct(string $documentRoot, string $hostname, int $port, string $router = '')
public function __construct(string $documentRoot, string $hostname, int $port, string $router = '', string $readinessPath = '')
{
$this->hostname = $hostname;
$this->port = $port;
$this->readinessPath = $readinessPath;

$finder = new PhpExecutableFinder();
if (false === $binary = $finder->find(false)) {
Expand Down Expand Up @@ -69,7 +71,13 @@ public function start(): void
$this->checkPortAvailable($this->hostname, $this->port);
$this->process->start();

$this->waitUntilReady($this->process, "http://$this->hostname:$this->port", true);
$url = "http://$this->hostname:$this->port";

if ($this->readinessPath) {
$url .= $this->readinessPath;
}

$this->waitUntilReady($this->process, $url, true);
}

/**
Expand Down