88
99class Connection implements ConnectionInterface
1010{
11- /** @var Request */
11+ /**
12+ * The request instance.
13+ *
14+ * @var Request
15+ */
1216 public $ httpRequest ;
1317
18+ /**
19+ * The sent data through the connection.
20+ *
21+ * @var array
22+ */
1423 public $ sentData = [];
1524
25+ /**
26+ * The raw (unencoded) sent data.
27+ *
28+ * @var array
29+ */
1630 public $ sentRawData = [];
1731
32+ /**
33+ * Wether the connection has been closed.
34+ *
35+ * @var bool
36+ */
1837 public $ closed = false ;
1938
39+ /**
40+ * Send the data through the connection.
41+ *
42+ * @param mixed $data
43+ * @return void
44+ */
2045 public function send ($ data )
2146 {
2247 $ this ->sentData [] = json_decode ($ data , true );
2348 $ this ->sentRawData [] = $ data ;
2449 }
2550
51+ /**
52+ * Mark the connection as closed.
53+ *
54+ * @return void
55+ */
2656 public function close ()
2757 {
2858 $ this ->closed = true ;
2959 }
3060
61+ /**
62+ * Assert that an event got sent.
63+ *
64+ * @param string $name
65+ * @param array $additionalParameters
66+ * @return void
67+ */
3168 public function assertSentEvent (string $ name , array $ additionalParameters = [])
3269 {
3370 $ event = collect ($ this ->sentData )->firstWhere ('event ' , '= ' , $ name );
@@ -41,6 +78,12 @@ public function assertSentEvent(string $name, array $additionalParameters = [])
4178 }
4279 }
4380
81+ /**
82+ * Assert that an event got not sent.
83+ *
84+ * @param string $name
85+ * @return void
86+ */
4487 public function assertNotSentEvent (string $ name )
4588 {
4689 $ event = collect ($ this ->sentData )->firstWhere ('event ' , '= ' , $ name );
@@ -50,6 +93,11 @@ public function assertNotSentEvent(string $name)
5093 );
5194 }
5295
96+ /**
97+ * Assert the connection is closed.
98+ *
99+ * @return void
100+ */
53101 public function assertClosed ()
54102 {
55103 PHPUnit::assertTrue ($ this ->closed );
0 commit comments