Skip to content

Commit

Permalink
stop all server processes after tests have run
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Mar 26, 2024
1 parent 7ba3d8e commit 36345e0
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 2 deletions.
Expand Up @@ -24,6 +24,11 @@ public static function setUpBeforeClass(): void
TestHttpServer::start();
}

public static function tearDownAfterClass(): void
{
TestHttpServer::stop();
}

public function testItCollectsRequestCount()
{
$httpClient1 = $this->httpClientThatHasTracedRequests([
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/HttpClient/Tests/HttplugClientTest.php
Expand Up @@ -32,6 +32,11 @@ public static function setUpBeforeClass(): void
TestHttpServer::start();
}

public static function tearDownAfterClass(): void
{
TestHttpServer::stop();
}

public function testSendRequest()
{
$client = new HttplugClient(new NativeHttpClient());
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/HttpClient/Tests/Psr18ClientTest.php
Expand Up @@ -28,6 +28,11 @@ public static function setUpBeforeClass(): void
TestHttpServer::start();
}

public static function tearDownAfterClass(): void
{
TestHttpServer::stop();
}

public function testSendRequest()
{
$factory = new Psr17Factory();
Expand Down
Expand Up @@ -27,6 +27,11 @@

class RetryableHttpClientTest extends TestCase
{
public static function tearDownAfterClass(): void
{
TestHttpServer::stop();
}

public function testRetryOnError()
{
$client = new RetryableHttpClient(
Expand Down
Expand Up @@ -29,6 +29,11 @@ public static function setUpBeforeClass(): void
TestHttpServer::start();
}

public static function tearDownAfterClass(): void
{
TestHttpServer::stop();
}

public function testItTracesRequest()
{
$httpClient = $this->createMock(HttpClientInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpClient/composer.json
Expand Up @@ -25,7 +25,7 @@
"php": ">=7.2.5",
"psr/log": "^1|^2|^3",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/http-client-contracts": "^2.4",
"symfony/http-client-contracts": "^2.6",
"symfony/polyfill-php73": "^1.11",
"symfony/polyfill-php80": "^1.16",
"symfony/service-contracts": "^1.0|^2|^3"
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php
Expand Up @@ -28,6 +28,12 @@ public static function setUpBeforeClass(): void
TestHttpServer::start();
}

public static function tearDownAfterClass(): void
{
TestHttpServer::stop(8067);
TestHttpServer::stop(8077);
}

abstract protected function getHttpClient(string $testCase): HttpClientInterface;

public function testGetRequest()
Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Contracts/HttpClient/Test/TestHttpServer.php
Expand Up @@ -43,4 +43,11 @@ public static function start(int $port = 8057)

return $process;
}

public static function stop(int $port = 8057)
{
if (isset(self::$process[$port])) {
self::$process[$port]->stop();
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Contracts/composer.json
Expand Up @@ -52,7 +52,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-main": "2.5-dev"
"dev-main": "2.6-dev"
}
}
}

0 comments on commit 36345e0

Please sign in to comment.