Skip to content

Commit 1741a3a

Browse files
committed
add socket connection factory test
1 parent 7e5c85e commit 1741a3a

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

Tests/RabbitMq/AMQPConnectionFactoryTest.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,83 @@ public function testSSLClusterConnectionParameters()
532532
);
533533
}
534534

535+
public function testSocketClusterConnectionParameters()
536+
{
537+
$factory = new AMQPConnectionFactory(
538+
AMQPSocketConnection::class,
539+
[
540+
'hosts' => [
541+
[
542+
'host' => 'cluster_host',
543+
'port' => 123,
544+
'user' => 'cluster_user',
545+
'password' => 'cluster_password',
546+
'vhost' => '/cluster_vhost',
547+
],
548+
[
549+
'url' => 'amqp://user:pass@host:321/vhost',
550+
]
551+
]
552+
]
553+
);
554+
555+
/** @var AMQPSocketConnection $instance */
556+
$instance = $factory->createConnection();
557+
$this->assertInstanceOf(AMQPSocketConnection::class, $instance);
558+
$this->assertEquals([
559+
'cluster_host', // host
560+
123, // port
561+
'cluster_user', // user
562+
'cluster_password', // password
563+
'/cluster_vhost', // vhost
564+
false, // insist
565+
"AMQPLAIN", // login method
566+
null, // login response
567+
"en_US", // locale
568+
3, // read_timeout
569+
false, // keepalive
570+
3, // write_timeout
571+
0, // heartbeat
572+
], $instance->constructParams);
573+
574+
$this->assertEquals(
575+
[
576+
[
577+
[
578+
'host' => 'cluster_host',
579+
'port' => 123,
580+
'user' => 'cluster_user',
581+
'password' => 'cluster_password',
582+
'vhost' => '/cluster_vhost',
583+
],
584+
[
585+
'host' => 'host',
586+
'port' => 321,
587+
'user' => 'user',
588+
'password' => 'pass',
589+
'vhost' => 'vhost',
590+
]
591+
],
592+
[
593+
'url' => '',
594+
'host' => 'localhost',
595+
'port' => 5672,
596+
'user' => 'guest',
597+
'password' => 'guest',
598+
'vhost' => '/',
599+
'ssl_context' => null,
600+
'keepalive' => false,
601+
'heartbeat' => 0,
602+
'connection_timeout' => 3,
603+
'read_write_timeout' => 3,
604+
'read_timeout' => 3,
605+
'write_timeout' => 3
606+
]
607+
],
608+
$instance::$createConnectionParams
609+
);
610+
}
611+
535612
public function testConnectionsParametersProviderWithConstructorArgs()
536613
{
537614
$connectionParametersProvider = $this->prepareConnectionParametersProvider();

0 commit comments

Comments
 (0)