Skip to content

Commit 0a03028

Browse files
committed
Move to HTTP
1 parent 477f08f commit 0a03028

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src-deprecated/BuiltinServerStartTrait.php renamed to src-deprecated/Http/BuiltinServerStartTrait.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,30 @@
99
use ReflectionClass;
1010

1111
use function dirname;
12-
use function str_replace;
12+
use function register_shutdown_function;
1313

1414
/**
1515
* @deprecated User HttpResource instead
1616
*/
1717
trait BuiltinServerStartTrait
1818
{
19-
/**
20-
* Hosting built server URL
21-
*
22-
* User can change it in unit test
23-
*
24-
* @var string
25-
*/
26-
protected static $httpHost = 'http://127.0.0.1:8088';
19+
/** @var string */
20+
private static $host = '127.0.0.1:8088';
21+
22+
/** @var string */
23+
private $httpHost = 'http://127.0.0.1:8088';
2724

2825
/** @var BuiltinServer */
2926
private static $server;
3027

3128
public static function setUpBeforeClass(): void
3229
{
33-
$host = str_replace(['http://', 'https://'], '', self::$httpHost);
3430
$dir = dirname((new ReflectionClass(static::class))->getFileName());
35-
self::$server = new BuiltinServer($host, $dir . '/index.php');
31+
self::$server = new BuiltinServer(self::$host, $dir . '/index.php');
3632
self::$server->start();
33+
register_shutdown_function(static function () {
34+
self::$server->stop();
35+
});
3736
}
3837

3938
public static function tearDownAfterClass(): void
@@ -43,6 +42,6 @@ public static function tearDownAfterClass(): void
4342

4443
public function getHttpResourceClient(InjectorInterface $injector, string $class): ResourceInterface
4544
{
46-
return new HttpResourceClient(self::$httpHost, $injector, $class);
45+
return new HttpResourceClient($this->httpHost, $injector, $class);
4746
}
4847
}

0 commit comments

Comments
 (0)