CMS 2.0
This commit is contained in:
36
vendor/php-mqtt/client/tests/Feature/ConnectWithInvalidHostAndPortTest.php
vendored
Normal file
36
vendor/php-mqtt/client/tests/Feature/ConnectWithInvalidHostAndPortTest.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use PhpMqtt\Client\Exceptions\ConnectingToBrokerFailedException;
|
||||
use PhpMqtt\Client\MqttClient;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Tests that the client throws an exception if connecting using invalid host and port.
|
||||
*
|
||||
* @package Tests\Feature
|
||||
*/
|
||||
class ConnectWithInvalidHostAndPortTest extends TestCase
|
||||
{
|
||||
public function test_throws_exception_when_connecting_using_invalid_host_and_port(): void
|
||||
{
|
||||
$client = new MqttClient('127.0.0.1', 56565, 'test-invalid-host');
|
||||
|
||||
$this->expectException(ConnectingToBrokerFailedException::class);
|
||||
$this->expectExceptionCode(ConnectingToBrokerFailedException::EXCEPTION_CONNECTION_SOCKET_ERROR);
|
||||
|
||||
try {
|
||||
$client->connect(null, true);
|
||||
} catch (ConnectingToBrokerFailedException $e) {
|
||||
$this->assertGreaterThan(0, $e->getConnectionErrorCode());
|
||||
$this->assertNotEmpty($e->getConnectionErrorMessage());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user