@@ -58,7 +58,9 @@ public function testPing()
5858 $ c ->connect ();
5959 $ c ->ping ();
6060 $ c ->ping ();
61- $ this ->assertGreaterThan (0 , $ c ->pingsCount ());
61+ $ count = $ c ->pingsCount ();
62+ $ this ->assertInternalType ("int " , $ count );
63+ $ this ->assertGreaterThan (0 , $ count );
6264 $ c ->close ();
6365 }
6466
@@ -72,7 +74,47 @@ public function testPublish()
7274 $ c = new Nats \Connection ();
7375 $ c ->connect ();
7476 $ c ->publish ("foo " , "bar " );
75- $ this ->assertGreaterThan (0 , $ c ->pubsCount ());
77+ $ count = $ c ->pubsCount ();
78+ $ this ->assertInternalType ("int " , $ count );
79+ $ this ->assertGreaterThan (0 , $ count );
7680 $ c ->close ();
7781 }
82+
83+ /**
84+ * Test Server reconnection
85+ *
86+ * @return null
87+ */
88+ public function testReconnect ()
89+ {
90+ $ c = new Nats \Connection ();
91+ $ c ->connect ();
92+ $ c ->reconnect ();
93+ $ count = $ c ->reconnectsCount ();
94+ $ this ->assertInternalType ("int " , $ count );
95+ $ this ->assertGreaterThan (0 , $ count );
96+ $ c ->close ();
97+ }
98+
99+ /**
100+ * Test Server subscription
101+ *
102+ * @return null
103+ */
104+ public function testSubscription ()
105+ {
106+ $ c = new Nats \Connection ();
107+ $ c ->connect ();
108+ $ c ->subscribe (
109+ "foo " , function ($ message ) {
110+ $ this ->assertNotNull ($ message );
111+ }
112+ );
113+ $ this ->assertGreaterThan (0 , $ c ->subscriptionsCount ());
114+ $ subscriptions = $ c ->getSubscriptions ();
115+ $ this ->assertInternalType ("array " , $ subscriptions );
116+
117+ $ c ->publish ("foo " , "bar " );
118+ $ c ->wait (1 );
119+ }
78120}
0 commit comments