2525 */
2626class TestConnection extends \PHPUnit_Framework_TestCase
2727{
28- private $ c ;
28+ private $ _c ;
2929
3030 /**
3131 * Setup tests
32+ *
33+ * @return null
3234 */
33- public function setUp ()
35+ public function setUp ()
3436 {
35- $ this ->c = $ this ->getMockBuilder ('Nats\Connection ' )->getMock ();
36- $ this ->c ->expects ($ this ->any ())->method ("connect " )->willReturn (null );
37- $ this ->c ->expects ($ this ->any ())->method ("pingsCount " )->willReturn (1 );
38- $ this ->c ->expects ($ this ->any ())->method ("pubsCount " )->willReturn (1 );
39- $ this ->c ->expects ($ this ->any ())->method ("reconnectsCount " )->willReturn (1 );
40- $ this ->c ->expects ($ this ->any ())->method ("subscriptionsCount " )->willReturn (1 );
41- $ this ->c ->expects ($ this ->any ())->method ("getSubscriptions " )->willReturn (["foo " , "bar " ]);
37+ $ this ->_c = $ this ->getMockBuilder ('Nats\Connection ' )->getMock ();
38+
39+ $ this ->_c ->expects ($ this ->any ())
40+ ->method ("connect " )
41+ ->willReturn (null );
42+
43+ $ this ->_c ->expects ($ this ->any ())
44+ ->method ("pingsCount " )
45+ ->willReturn (1 );
46+
47+ $ this ->_c ->expects ($ this ->any ())
48+ ->method ("pubsCount " )
49+ ->willReturn (1 );
50+
51+ $ this ->_c ->expects ($ this ->any ())
52+ ->method ("reconnectsCount " )
53+ ->willReturn (1 );
54+
55+ $ this ->_c ->expects ($ this ->any ())
56+ ->method ("subscriptionsCount " )
57+ ->willReturn (1 );
58+
59+ $ this ->_c ->expects ($ this ->any ())
60+ ->method ("getSubscriptions " )
61+ ->willReturn (["foo " , "bar " ]);
4262 }
4363
4464 /**
4565 * Test Dummy
4666 *
4767 * @return null
4868 */
49- public function testDummy ()
69+ public function testDummy ()
5070 {
5171 $ this ->assertTrue (true );
5272 }
@@ -56,37 +76,37 @@ public function testDummy()
5676 *
5777 * @return null
5878 */
59- public function testConnection ()
79+ public function testConnection ()
6080 {
61- $ this ->c ->connect ();
62- $ this ->c ->close ();
81+ $ this ->_c ->connect ();
82+ $ this ->_c ->close ();
6383 }
6484
6585 /**
6686 * Test Ping command
6787 *
6888 * @return null
6989 */
70- public function testPing ()
90+ public function testPing ()
7191 {
72- $ count = $ this ->c ->pingsCount ();
92+ $ count = $ this ->_c ->pingsCount ();
7393 $ this ->assertInternalType ("int " , $ count );
7494 $ this ->assertGreaterThan (0 , $ count );
75- $ this ->c ->close ();
95+ $ this ->_c ->close ();
7696 }
7797
7898 /**
7999 * Test Publish command
80100 *
81101 * @return null
82102 */
83- public function testPublish ()
103+ public function testPublish ()
84104 {
85- $ this ->c ->publish ("foo " , "bar " );
86- $ this ->count = $ this ->c ->pubsCount ();
105+ $ this ->_c ->publish ("foo " , "bar " );
106+ $ this ->count = $ this ->_c ->pubsCount ();
87107 $ this ->assertInternalType ("int " , $ this ->count );
88108 $ this ->assertGreaterThan (0 , $ this ->count );
89- $ this ->c ->close ();
109+ $ this ->_c ->close ();
90110 }
91111
92112 /**
@@ -96,11 +116,11 @@ public function testPublish()
96116 */
97117 public function testReconnect ()
98118 {
99- $ this ->c ->reconnect ();
100- $ this ->count = $ this ->c ->reconnectsCount ();
119+ $ this ->_c ->reconnect ();
120+ $ this ->count = $ this ->_c ->reconnectsCount ();
101121 $ this ->assertInternalType ("int " , $ this ->count );
102122 $ this ->assertGreaterThan (0 , $ this ->count );
103- $ this ->c ->close ();
123+ $ this ->_c ->close ();
104124 }
105125
106126 /**
@@ -110,16 +130,15 @@ public function testReconnect()
110130 */
111131 public function testSubscription ()
112132 {
113- $ this ->c ->subscribe (
114- "foo " , function ($ message ) {
115- $ this ->assertNotNull ($ message );
116- }
117- );
118- $ this ->assertGreaterThan (0 , $ this ->c ->subscriptionsCount ());
119- $ subscriptions = $ this ->c ->getSubscriptions ();
133+ $ callback = function ($ message ) {
134+ $ this ->assertNotNull ($ message );
135+ };
136+ $ this ->_c ->subscribe ("foo " , $ callback );
137+ $ this ->assertGreaterThan (0 , $ this ->_c ->subscriptionsCount ());
138+ $ subscriptions = $ this ->_c ->getSubscriptions ();
120139 $ this ->assertInternalType ("array " , $ subscriptions );
121140
122- $ this ->c ->publish ("foo " , "bar " );
123- $ this ->c ->wait (1 );
141+ $ this ->_c ->publish ("foo " , "bar " );
142+ $ this ->_c ->wait (1 );
124143 }
125144}
0 commit comments