Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HttpClient] stop all server processes after tests have run #54400

Merged
merged 1 commit into from Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be updated to the next 2.4 I guess?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see a95835f

"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)
{
OskarStark marked this conversation as resolved.
Show resolved Hide resolved
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't bump here. I think we can ship this as a bugfix.

}
}
}