Skip to content

Commit 0f69e6b

Browse files
committed
Polish
1 parent 40e6da0 commit 0f69e6b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/spec/ReferenceTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,16 @@ public function testResolveFileInSubdirWithMultipleRelativePaths()
234234

235235
public function testResolveFileHttp()
236236
{
237+
$host = 'localhost:8787'; # create mock web server to avoid calling real GitHub URL and rate limit hit
237238
// $file = 'https://raw.githubusercontent.com/cebe/php-openapi/290389bbd337cf4d70ecedfd3a3d886715e19552/tests/spec/data/reference/base.yaml';
238239
if (stripos(PHP_OS_FAMILY, 'Windows') !== false) {
239-
$cmd = 'powershell -Command "Start-Process php -ArgumentList \'-S localhost:8787\' -NoNewWindow"';
240-
popen($cmd, "r");
240+
$cmd = 'powershell -Command "Start-Process php -ArgumentList \'-S '.$host.'\' -NoNewWindow"';
241+
$res = popen($cmd, "r");
241242
} else {
242-
exec('nohup php -S localhost:8787 > /dev/null 2>&1 &', $op);
243+
exec('nohup php -S '.$host.' > /dev/null 2>&1 &');
243244
}
244245
sleep(2);
245246

246-
$host = 'localhost:8787';
247247
// $path = '/cebe/php-openapi/290389bbd337cf4d70ecedfd3a3d886715e19552/tests/spec/data/reference/base.yaml';
248248
$path = '/tests/data/issue/236/base.yaml';
249249
$file = 'http://' . $host . $path;
@@ -263,6 +263,10 @@ public function testResolveFileHttp()
263263
$this->assertInstanceOf(Schema::class, $petItems = $openapi->components->schemas['Dog']);
264264
$this->assertArrayHasKey('id', $openapi->components->schemas['Pet']->properties);
265265
$this->assertArrayHasKey('name', $openapi->components->schemas['Dog']->properties);
266+
267+
if (isset($res) && is_resource($petItems)) {
268+
pclose($res);
269+
}
266270
}
267271

268272
public function testResolvePaths()

0 commit comments

Comments
 (0)