Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit fcb329d

Browse files
committed
More tests
1 parent 1b53b88 commit fcb329d

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

spec/Nats/ConnectionOptionsSpec.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
class ConnectionOptionsSpec extends ObjectBehavior
99
{
10+
1011
function it_is_initializable()
1112
{
1213
$this->shouldHaveType('Nats\ConnectionOptions');
@@ -47,4 +48,28 @@ function it_has_default_reconnect_value_as_null() {
4748
function it_returns_a_valid_default_address() {
4849
$this->getAddress()->shouldEqual("tcp://localhost:4222");
4950
}
51+
52+
function it_options_can_be_overrided()
53+
{
54+
$options = array(
55+
'host' => 'remotehost.com',
56+
'port' => 4321,
57+
'user' => 'user',
58+
'pass' => 'pass',
59+
'token' => 'token',
60+
'lang' => 'php',
61+
'version' => '1.2.3',
62+
'verbose' => true,
63+
'pedantic' => true,
64+
'reconnect' => false,
65+
);
66+
$this->setConnectionOptions($options);
67+
$this->getHost()->shouldBe('remotehost.com');
68+
$this->getPort()->shouldBe(4321);
69+
$this->getUser()->shouldBe('user');
70+
$this->getPass()->shouldBe('pass');
71+
$this->getToken()->shouldBe('token');
72+
$this->getLang()->shouldBe('php');
73+
$this->getVersion()->shouldBe('1.2.3');
74+
}
5075
}

src/Nats/ConnectionOptions.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,25 @@ public function setReconnect($reconnect)
420420
return $this;
421421
}
422422

423+
/**
424+
* Set the connection options.
425+
*
426+
* @param Traversable|array $options The connection options.
427+
*
428+
* @return void
429+
*/
430+
public function setConnectionOptions($options)
431+
{
432+
$this->initialize($options);
433+
}
434+
423435
/**
424436
* Initialize the parameters.
425437
*
426438
* @param Traversable|array $options The connection options.
427439
*
428440
* @throws Exception When $options are an invalid type.
441+
*
429442
* @return void
430443
*/
431444
protected function initialize($options)

0 commit comments

Comments
 (0)