This repository was archived by the owner on Oct 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88class 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}
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments