This commit is contained in:
2021-02-01 00:39:07 +03:00
parent 070b980003
commit 3d8f5be2d0
6 changed files with 261 additions and 14 deletions

View File

@ -11,7 +11,10 @@ use PHPUnit\Framework\TestCase;
final class NsqTest extends TestCase
{
public function test(): void
/**
* @dataProvider configs
*/
public function test(ClientConfig $clientConfig): void
{
$producer = new Producer('tcp://localhost:4150');
$producer->pub(__FUNCTION__, __FUNCTION__);
@ -20,10 +23,7 @@ final class NsqTest extends TestCase
topic: 'test',
channel: 'test',
address: 'tcp://localhost:4150',
clientConfig: new ClientConfig(
heartbeatInterval: 3000,
readTimeout: 1,
),
clientConfig: $clientConfig,
);
$generator = $consumer->generator();
@ -89,4 +89,26 @@ final class NsqTest extends TestCase
$generator->send(0);
self::assertTrue($consumer->isClosed());
}
/**
* @return Generator<string, array<int, ClientConfig>>
*/
public function configs(): Generator
{
yield 'default' => [
new ClientConfig(
heartbeatInterval: 3000,
snappy: false,
readTimeout: 1,
),
];
yield 'snappy' => [
new ClientConfig(
heartbeatInterval: 3000,
snappy: true,
readTimeout: 1,
),
];
}
}