Skip to content

Commit aeca353

Browse files
Alin Eugen Deacbinsoul
authored andcommitted
Add is connected on 'connect' event test
Proves that a client is connected once the "connect" event is dispatched.
1 parent 1a88d47 commit aeca353

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/Integration/ReactMqttClientTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,29 @@ public function test_connect_failure()
334334
$this->startLoop();
335335
}
336336

337+
/**
338+
* Test that client's is-connected state is updated correctly
339+
*
340+
* @depends test_connect_success
341+
*/
342+
public function test_is_connected_when_connect_event_emitted()
343+
{
344+
$client = $this->buildClient();
345+
346+
$client->on('connect', function(Connection $connection) use($client){
347+
$this->assertTrue($client->isConnected(), 'Client is should be connected');
348+
$this->stopLoop();
349+
});
350+
351+
$client->connect(self::HOSTNAME, self::PORT, null, 1)
352+
->then(function () use ($client) {
353+
$this->assertTrue($client->isConnected());
354+
$this->stopLoop();
355+
});
356+
357+
$this->startLoop();
358+
}
359+
337360
/**
338361
* Tests that messages can be send and received successfully.
339362
*

0 commit comments

Comments
 (0)