Skip to content

Commit 5dc78eb

Browse files
authored
Merge pull request #177 from OwlyCode/master
Added readinessPath to use custom path for server readiness detection
2 parents 3d6ec21 + 0c738cb commit 5dc78eb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/PantherTestCaseTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ trait PantherTestCaseTrait
6565
'port' => 9080,
6666
'router' => '',
6767
'external_base_uri' => null,
68+
'readinessPath' => '',
6869
];
6970

7071
public static function tearDownAfterClass(): void
@@ -113,6 +114,7 @@ public static function startWebServer(array $options = []): void
113114
'hostname' => $options['hostname'] ?? self::$defaultOptions['hostname'],
114115
'port' => (int) ($options['port'] ?? $_SERVER['PANTHER_WEB_SERVER_PORT'] ?? self::$defaultOptions['port']),
115116
'router' => $options['router'] ?? $_SERVER['PANTHER_WEB_SERVER_ROUTER'] ?? self::$defaultOptions['router'],
117+
'readinessPath' => $options['readinessPath'] ?? $_SERVER['PANTHER_READINESS_PATH'] ?? self::$defaultOptions['readinessPath'],
116118
];
117119

118120
self::$webServerManager = new WebServerManager(...array_values($options));

src/ProcessManager/WebServerManager.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ final class WebServerManager
2525

2626
private $hostname;
2727
private $port;
28+
private $readinessPath;
2829

2930
/**
3031
* @var Process
@@ -34,10 +35,11 @@ final class WebServerManager
3435
/**
3536
* @throws \RuntimeException
3637
*/
37-
public function __construct(string $documentRoot, string $hostname, int $port, string $router = '')
38+
public function __construct(string $documentRoot, string $hostname, int $port, string $router = '', string $readinessPath = '')
3839
{
3940
$this->hostname = $hostname;
4041
$this->port = $port;
42+
$this->readinessPath = $readinessPath;
4143

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

72-
$this->waitUntilReady($this->process, "http://$this->hostname:$this->port", true);
74+
$url = "http://$this->hostname:$this->port";
75+
76+
if ($this->readinessPath) {
77+
$url .= $this->readinessPath;
78+
}
79+
80+
$this->waitUntilReady($this->process, $url, true);
7381
}
7482

7583
/**

0 commit comments

Comments
 (0)