mqttBrokerHost, $this->mqttBrokerPort, 'test-not-connected'); $this->expectException(ClientNotConnectedToBrokerException::class); $client->publish('foo/bar', 'baz'); } public function test_throws_exception_when_topic_is_subscribed_without_connecting_to_broker(): void { $client = new MqttClient($this->mqttBrokerHost, $this->mqttBrokerPort, 'test-not-connected'); $this->expectException(ClientNotConnectedToBrokerException::class); $client->subscribe('foo/bar', fn () => true); } public function test_throws_exception_when_topic_is_unsubscribed_without_connecting_to_broker(): void { $client = new MqttClient($this->mqttBrokerHost, $this->mqttBrokerPort, 'test-not-connected'); $this->expectException(ClientNotConnectedToBrokerException::class); $client->unsubscribe('foo/bar'); } public function test_throws_exception_when_disconnecting_without_connecting_to_broker_first(): void { $client = new MqttClient($this->mqttBrokerHost, $this->mqttBrokerPort, 'test-not-connected'); $this->expectException(ClientNotConnectedToBrokerException::class); $client->disconnect(); } }