No need for socket_import_stream() to set TCP_NODELAY since PHP 7.1.

This commit is contained in:
Daniele Alessandri
2020-09-04 17:56:19 +02:00
parent 67487528eb
commit e5f44c33a2
4 changed files with 89 additions and 10 deletions
@@ -132,4 +132,46 @@ class StreamConnectionTest extends PredisConnectionTestCase
$this->assertNotSame($connection1->getResource(), $connection2->getResource());
}
/**
* @group connected
*/
public function testTcpNodelayParameterSetsContextFlagWhenTrue()
{
$connection = $this->createConnectionWithParams(['tcp_nodelay' => true]);
$options = stream_context_get_options($connection->getResource());
$this->assertIsArray($options);
$this->assertArrayHasKey('socket', $options);
$this->assertArrayHasKey('tcp_nodelay', $options['socket']);
$this->assertTrue($options['socket']['tcp_nodelay']);
}
/**
* @group connected
*/
public function testTcpNodelayParameterDoesNotSetContextFlagWhenFalse()
{
$connection = $this->createConnectionWithParams(['tcp_nodelay' => false]);
$options = stream_context_get_options($connection->getResource());
$this->assertIsArray($options);
$this->assertArrayHasKey('socket', $options);
$this->assertArrayHasKey('tcp_nodelay', $options['socket']);
$this->assertFalse($options['socket']['tcp_nodelay']);
}
/**
* @group connected
*/
public function testTcpDelayContextFlagIsNotSetByDefault()
{
$connection = $this->createConnectionWithParams([]);
$options = stream_context_get_options($connection->getResource());
$this->assertIsArray($options);
$this->assertArrayHasKey('socket', $options);
$this->assertArrayHasKey('tcp_nodelay', $options['socket']);
$this->assertFalse($options['socket']['tcp_nodelay']);
}
}