-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
55 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace PhpPactTest\Helper; | ||
|
||
use Symfony\Component\Process\Process; | ||
|
||
class ProviderProcess | ||
{ | ||
private Process $process; | ||
|
||
public function __construct(string $publicPath, private int $port = 7202) | ||
{ | ||
$this->process = new Process(['php', '-S', "127.0.0.1:$port", '-t', $publicPath]); | ||
} | ||
|
||
public function start(): void | ||
{ | ||
$this->process->start(function ($type, $buffer): void { | ||
if (Process::ERR === $type) { | ||
echo 'ERR > '.$buffer; | ||
} else { | ||
echo 'OUT > '.$buffer; | ||
} | ||
}); | ||
$this->process->waitUntil(function (): bool { | ||
$fp = @fsockopen('127.0.0.1', $this->port); | ||
$isOpen = is_resource($fp); | ||
if ($isOpen) { | ||
fclose($fp); | ||
} | ||
|
||
return $isOpen; | ||
}); | ||
} | ||
|
||
public function stop(): void | ||
{ | ||
$this->process->stop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters