Refactoring configs. Use connections settings on establishing connection. Create ClientConfig from array.
This commit is contained in:
@ -14,4 +14,57 @@ final class ClientConfigTest extends TestCase
|
||||
|
||||
new ClientConfig(deflate: true, snappy: true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider array
|
||||
*/
|
||||
public function testFromArray(array $data, array $expected): void
|
||||
{
|
||||
self::assertSame($expected, get_object_vars(ClientConfig::fromArray($data)));
|
||||
}
|
||||
|
||||
public function array(): Generator
|
||||
{
|
||||
$default = [
|
||||
'authSecret' => null,
|
||||
'connectTimeout' => 10,
|
||||
'maxAttempts' => 0,
|
||||
'tcpNoDelay' => false,
|
||||
'featureNegotiation' => true,
|
||||
'clientId' => '',
|
||||
'deflate' => false,
|
||||
'deflateLevel' => 6,
|
||||
'heartbeatInterval' => 30000,
|
||||
'hostname' => gethostname(),
|
||||
'msgTimeout' => 60000,
|
||||
'sampleRate' => 0,
|
||||
'tls' => false,
|
||||
'snappy' => false,
|
||||
'userAgent' => 'nsqphp/dev-main',
|
||||
];
|
||||
|
||||
yield 'Empty array' => [[], $default];
|
||||
|
||||
yield 'With wrong keys' => [['bla' => 'bla'], $default];
|
||||
|
||||
$custom = [
|
||||
'authSecret' => 'SomeSecret',
|
||||
'connectTimeout' => 100,
|
||||
'maxAttempts' => 10,
|
||||
'tcpNoDelay' => true,
|
||||
'featureNegotiation' => true,
|
||||
'clientId' => 'SomeGorgeousClientId',
|
||||
'deflate' => true,
|
||||
'deflateLevel' => 1,
|
||||
'heartbeatInterval' => 31111,
|
||||
'hostname' => gethostname(),
|
||||
'msgTimeout' => 59999,
|
||||
'sampleRate' => 25,
|
||||
'tls' => true,
|
||||
'snappy' => false,
|
||||
'userAgent' => 'nsqphp/test',
|
||||
];
|
||||
|
||||
yield 'Full filled' => [$custom, $custom];
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ final class NsqTest extends TestCase
|
||||
new ClientConfig(
|
||||
heartbeatInterval: 3000,
|
||||
snappy: false,
|
||||
readTimeout: 1,
|
||||
),
|
||||
];
|
||||
|
||||
@ -32,7 +31,6 @@ final class NsqTest extends TestCase
|
||||
new ClientConfig(
|
||||
heartbeatInterval: 3000,
|
||||
snappy: true,
|
||||
readTimeout: 1,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user