Skip to content

Commit c5fd30e

Browse files
committed
Attempt using nohup/start-process instead of donatj/mock-webserver
1 parent 241df9f commit c5fd30e

File tree

1 file changed

+77
-68
lines changed

1 file changed

+77
-68
lines changed

tests/spec/ReferenceTest.php

Lines changed: 77 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@
1717
class ReferenceTest extends \PHPUnit\Framework\TestCase
1818
{
1919
/** @var MockWebServer */
20-
protected static $server;
20+
// protected static $server;
2121

2222

23-
public static function setUpBeforeClass(): void
24-
{
25-
self::$server = new MockWebServer;
26-
self::$server->start();
27-
28-
// $this->server = new MockWebServer();
29-
// $this->server->stop();
30-
// $this->server->start();
23+
// public static function setUpBeforeClass(): void
24+
// {
25+
// self::$server = new MockWebServer;
26+
// self::$server->start();
3127
//
32-
// if (stripos(PHP_OS_FAMILY, 'Windows') !== false) {
33-
//// echo "Running on Windows\n";
34-
//// exec('ssh-keyscan -H '.$this->server->getHost().' | Out-File -Append -Encoding ASCII $env:USERPROFILE\.ssh\known_hosts');
35-
// }
36-
}
37-
38-
public static function tearDownAfterClass(): void
39-
{
40-
// $this->server->stop();
41-
self::$server->stop();
42-
43-
}
28+
//// $this->server = new MockWebServer();
29+
//// $this->server->stop();
30+
//// $this->server->start();
31+
////
32+
//// if (stripos(PHP_OS_FAMILY, 'Windows') !== false) {
33+
////// echo "Running on Windows\n";
34+
////// exec('ssh-keyscan -H '.$this->server->getHost().' | Out-File -Append -Encoding ASCII $env:USERPROFILE\.ssh\known_hosts');
35+
//// }
36+
// }
37+
38+
// public static function tearDownAfterClass(): void
39+
// {
40+
//// $this->server->stop();
41+
// self::$server->stop();
42+
//
43+
// }
4444

4545
public function testResolveInDocument()
4646
{
@@ -261,7 +261,7 @@ public function testResolveFileInSubdirWithMultipleRelativePaths()
261261

262262
public function testResolveFileHttp()
263263
{
264-
$this->registerPaths();
264+
// $this->registerPaths();
265265
// $this->handleMockServer();
266266
// return;
267267

@@ -273,10 +273,19 @@ public function testResolveFileHttp()
273273

274274
// $file = 'https://raw.githubusercontent.com/cebe/php-openapi/290389bbd337cf4d70ecedfd3a3d886715e19552/tests/spec/data/reference/base.yaml';
275275

276-
$host = static::$server->getHost() . ':' . static::$server->getPort();
277-
// $host = 'localhost:8787';
278-
$path = '/cebe/php-openapi/290389bbd337cf4d70ecedfd3a3d886715e19552/tests/spec/data/reference/base.yaml';
279-
// $path = '/tests/data/issue/236/base.yaml';
276+
if (stripos(PHP_OS_FAMILY, 'Windows') !== false) {
277+
exec('Start-Process php -S localhost:8787', $op);
278+
} else {
279+
exec('nohup php -S localhost:8787 > /dev/null 2>&1 &', $op);
280+
}
281+
sleep(2);
282+
283+
284+
// $this->assertNull($op);
285+
// $host = static::$server->getHost() . ':' . static::$server->getPort();
286+
$host = 'localhost:8787';
287+
// $path = '/cebe/php-openapi/290389bbd337cf4d70ecedfd3a3d886715e19552/tests/spec/data/reference/base.yaml';
288+
$path = '/tests/data/issue/236/base.yaml';
280289
$file = 'http://' . $host . $path;
281290
/** @var $openapi OpenApi */
282291
$openapi = Reader::readFromYaml(str_replace('##ABSOLUTEPATH##', dirname($file), file_get_contents($file)));
@@ -753,46 +762,46 @@ private function handleMockServer()
753762

754763
}
755764

756-
private function registerPaths()
757-
{
758-
static::$server->setResponseOfPath(
759-
'/cebe/php-openapi/290389bbd337cf4d70ecedfd3a3d886715e19552/tests/spec/data/reference/definitions.yaml',
760-
'
761-
Pet:
762-
type: object
763-
properties:
764-
id:
765-
type: integer
766-
format: int64
767-
Dog:
768-
type: object
769-
properties:
770-
name:
771-
type: string
772-
'
773-
);
774-
775-
static::$server->setResponseOfPath(
776-
'/cebe/php-openapi/290389bbd337cf4d70ecedfd3a3d886715e19552/tests/spec/data/reference/base.yaml',
777-
'
778-
openapi: 3.0.0
779-
info:
780-
title: Link Example
781-
version: 1.0.0
782-
components:
783-
schemas:
784-
Pet:
785-
$ref: definitions.yaml#/Pet
786-
Dog:
787-
$ref: ##ABSOLUTEPATH##/definitions.yaml#/Dog
788-
paths:
789-
\'/pet\':
790-
get:
791-
responses:
792-
200:
793-
description: return a pet
794-
'
795-
);
796-
797-
}
765+
// private function registerPaths()
766+
// {
767+
// static::$server->setResponseOfPath(
768+
// '/cebe/php-openapi/290389bbd337cf4d70ecedfd3a3d886715e19552/tests/spec/data/reference/definitions.yaml',
769+
// '
770+
//Pet:
771+
// type: object
772+
// properties:
773+
// id:
774+
// type: integer
775+
// format: int64
776+
//Dog:
777+
// type: object
778+
// properties:
779+
// name:
780+
// type: string
781+
//'
782+
// );
783+
//
784+
// static::$server->setResponseOfPath(
785+
// '/cebe/php-openapi/290389bbd337cf4d70ecedfd3a3d886715e19552/tests/spec/data/reference/base.yaml',
786+
// '
787+
//openapi: 3.0.0
788+
//info:
789+
// title: Link Example
790+
// version: 1.0.0
791+
//components:
792+
// schemas:
793+
// Pet:
794+
// $ref: definitions.yaml#/Pet
795+
// Dog:
796+
// $ref: ##ABSOLUTEPATH##/definitions.yaml#/Dog
797+
//paths:
798+
// \'/pet\':
799+
// get:
800+
// responses:
801+
// 200:
802+
// description: return a pet
803+
//'
804+
// );
805+
//
806+
// }
798807
}

0 commit comments

Comments
 (0)