1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AMQPAL\Adapter\PhpAmqpLib\Options; |
4
|
|
|
|
5
|
|
|
use AMQPAL\Adapter\PhpAmqpLib\Factory; |
6
|
|
|
|
7
|
|
|
class ConnectionOptionsTest extends \PHPUnit_Framework_TestCase |
8
|
|
|
{ |
9
|
|
|
public function testGetterAndSetter() |
10
|
|
|
{ |
11
|
|
|
$configuration = [ |
12
|
|
|
'type' => 'test-type', |
13
|
|
|
'host' => 'test-host', |
14
|
|
|
'port' => 1234, |
15
|
|
|
'username' => 'test-username', |
16
|
|
|
'password' => 'test-password', |
17
|
|
|
'vhost' => 'test-vhost', |
18
|
|
|
'insist' => true, |
19
|
|
|
'login_method' => 'test-login_method', |
20
|
|
|
'locale' => 'test-locale', |
21
|
|
|
'read_write_timeout' => 12, |
22
|
|
|
'keep_alive' => true, |
23
|
|
|
'heartbeat' => 234, |
24
|
|
|
'connection_timeout' => 432, |
25
|
|
|
'ssl_options' => [ |
26
|
|
|
'opt1' => 'value1', |
27
|
|
|
'opt2' => 'value2', |
28
|
|
|
], |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
$options = new ConnectionOptions(); |
32
|
|
|
$options->setFromArray($configuration); |
33
|
|
|
|
34
|
|
|
static::assertEquals($configuration['type'], $options->getType()); |
35
|
|
|
static::assertEquals($configuration['host'], $options->getHost()); |
36
|
|
|
static::assertEquals($configuration['port'], $options->getPort()); |
37
|
|
|
static::assertEquals($configuration['username'], $options->getUsername()); |
38
|
|
|
static::assertEquals($configuration['password'], $options->getPassword()); |
39
|
|
|
static::assertEquals($configuration['vhost'], $options->getVhost()); |
40
|
|
|
static::assertEquals($configuration['insist'], $options->isInsist()); |
41
|
|
|
static::assertEquals($configuration['login_method'], $options->getLoginMethod()); |
42
|
|
|
static::assertEquals($configuration['locale'], $options->getLocale()); |
43
|
|
|
static::assertEquals($configuration['read_write_timeout'], $options->getReadWriteTimeout()); |
44
|
|
|
static::assertEquals($configuration['keep_alive'], $options->isKeepAlive()); |
45
|
|
|
static::assertEquals($configuration['heartbeat'], $options->getHeartbeat()); |
46
|
|
|
static::assertEquals($configuration['connection_timeout'], $options->getConnectionTimeout()); |
47
|
|
|
static::assertEquals($configuration['ssl_options'], $options->getSslOptions()); |
48
|
|
|
static::assertInstanceOf(Factory\ConnectionFactoryFactory::class, $options->getConnectionFactoryFactory()); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function testSetConnectionFactory() |
52
|
|
|
{ |
53
|
|
|
$connectionFactoryFactory = $this->prophesize(Factory\ConnectionFactoryFactory::class); |
54
|
|
|
$options = new ConnectionOptions(); |
55
|
|
|
$options->setConnectionFactoryFactory($connectionFactoryFactory->reveal()); |
56
|
|
|
|
57
|
|
|
static::assertSame($connectionFactoryFactory->reveal(), $options->getConnectionFactoryFactory()); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|