-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
1 parent
5b5010d
commit 87c8fa2
Showing
6 changed files
with
39 additions
and
21 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 |
---|---|---|
@@ -1,30 +1,40 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Process; | ||
use PHPUnit\Framework\ExpectationFailedException; | ||
|
||
use function Orchestra\Testbench\remote; | ||
|
||
it('can boot up the app', function () { | ||
$process = remote('native:serve'); | ||
$process->setTty(true)->start(function ($type, $line) { | ||
echo $line; | ||
$output = ''; | ||
|
||
$process = remote('native:serve --no-dependencies --no-interaction'); | ||
$process->start(function ($type, $line) use (&$output) { | ||
$output .= $line; | ||
}); | ||
|
||
try { | ||
retry(12, function () { | ||
retry(20, function () use ($output) { | ||
// Wait until port 8100 is open | ||
dump('Waiting for port 8100 to open...'); | ||
|
||
$fp = @fsockopen('localhost', 8100, $errno, $errstr, 1); | ||
if ($fp === false) { | ||
throw new Exception('Port 8100 is not open yet'); | ||
throw new Exception(sprintf( | ||
'Port 8100 is not open yet. Output: "%s"', | ||
$output, | ||
)); | ||
} | ||
}, 5000); | ||
} catch (Exception $e) { | ||
Process::run('pkill -9 -P '.$process->getPid()); | ||
throw $e; | ||
} finally { | ||
$process->stop(); | ||
} | ||
|
||
Process::run('pkill -9 -P '.$process->getPid()); | ||
|
||
expect(true)->toBeTrue(); | ||
try { | ||
expect($output)->toContain('Running the dev script with npm'); | ||
} catch (ExpectationFailedException) { | ||
throw new ExpectationFailedException(sprintf( | ||
'"%s" does not match the expected output.', | ||
$output, | ||
)); | ||
} | ||
}); |
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