minor #37013 [HttpClient] fix issues in tests (nicolas-grekas)
This PR was merged into the 4.4 branch.
Discussion
----------
[HttpClient] fix issues in tests
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Commits
-------
a337ba5547
[HttpClient] fix issues in tests
This commit is contained in:
commit
68d14c8511
@ -151,6 +151,7 @@ before_install:
|
||||
INI=~/.phpenv/versions/$PHP/etc/conf.d/travis.ini
|
||||
echo date.timezone = Europe/Paris >> $INI
|
||||
echo memory_limit = -1 >> $INI
|
||||
echo default_socket_timeout = 10 >> $INI
|
||||
echo session.gc_probability = 0 >> $INI
|
||||
echo opcache.enable_cli = 1 >> $INI
|
||||
echo apc.enable_cli = 1 >> $INI
|
||||
|
@ -9,6 +9,8 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpClient\Tests\DataCollector;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpClient\DataCollector\HttpClientDataCollector;
|
||||
use Symfony\Component\HttpClient\NativeHttpClient;
|
||||
@ -19,9 +21,13 @@ use Symfony\Contracts\HttpClient\Test\TestHttpServer;
|
||||
|
||||
class HttpClientDataCollectorTest extends TestCase
|
||||
{
|
||||
public function testItCollectsRequestCount()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
TestHttpServer::start();
|
||||
}
|
||||
|
||||
public function testItCollectsRequestCount()
|
||||
{
|
||||
$httpClient1 = $this->httpClientThatHasTracedRequests([
|
||||
[
|
||||
'method' => 'GET',
|
||||
@ -50,7 +56,6 @@ class HttpClientDataCollectorTest extends TestCase
|
||||
|
||||
public function testItCollectsErrorCount()
|
||||
{
|
||||
TestHttpServer::start();
|
||||
$httpClient1 = $this->httpClientThatHasTracedRequests([
|
||||
[
|
||||
'method' => 'GET',
|
||||
@ -80,7 +85,6 @@ class HttpClientDataCollectorTest extends TestCase
|
||||
|
||||
public function testItCollectsErrorCountByClient()
|
||||
{
|
||||
TestHttpServer::start();
|
||||
$httpClient1 = $this->httpClientThatHasTracedRequests([
|
||||
[
|
||||
'method' => 'GET',
|
||||
@ -113,7 +117,6 @@ class HttpClientDataCollectorTest extends TestCase
|
||||
|
||||
public function testItCollectsTracesByClient()
|
||||
{
|
||||
TestHttpServer::start();
|
||||
$httpClient1 = $this->httpClientThatHasTracedRequests([
|
||||
[
|
||||
'method' => 'GET',
|
||||
@ -146,7 +149,6 @@ class HttpClientDataCollectorTest extends TestCase
|
||||
|
||||
public function testItIsEmptyAfterReset()
|
||||
{
|
||||
TestHttpServer::start();
|
||||
$httpClient1 = $this->httpClientThatHasTracedRequests([
|
||||
[
|
||||
'method' => 'GET',
|
||||
|
@ -22,8 +22,6 @@ use Symfony\Contracts\HttpClient\Test\TestHttpServer;
|
||||
|
||||
class HttplugClientTest extends TestCase
|
||||
{
|
||||
private static $server;
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
TestHttpServer::start();
|
||||
|
@ -21,8 +21,6 @@ use Symfony\Contracts\HttpClient\Test\TestHttpServer;
|
||||
|
||||
class Psr18ClientTest extends TestCase
|
||||
{
|
||||
private static $server;
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
TestHttpServer::start();
|
||||
|
@ -19,12 +19,12 @@ use Symfony\Component\Process\Process;
|
||||
*/
|
||||
class TestHttpServer
|
||||
{
|
||||
private static $started;
|
||||
private static $process;
|
||||
|
||||
public static function start()
|
||||
{
|
||||
if (self::$started) {
|
||||
return;
|
||||
if (self::$process) {
|
||||
self::$process->stop();
|
||||
}
|
||||
|
||||
$finder = new PhpExecutableFinder();
|
||||
@ -32,9 +32,10 @@ class TestHttpServer
|
||||
$process->setWorkingDirectory(__DIR__.'/Fixtures/web');
|
||||
$process->start();
|
||||
|
||||
register_shutdown_function([$process, 'stop']);
|
||||
sleep('\\' === \DIRECTORY_SEPARATOR ? 10 : 1);
|
||||
do {
|
||||
usleep(50000);
|
||||
} while (!@fopen('http://127.0.0.1:8057/', 'r'));
|
||||
|
||||
self::$started = true;
|
||||
self::$process = $process;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user