expectException(ServerException::class); $this->expectExceptionMessage($exceptionMessage); $producer = Producer::create('tcp://localhost:4150'); Loop::run(static function () use ($producer, $topic, $body): Generator { yield $producer->connect(); yield $producer->publish($topic, $body); }); } /** * @return Generator */ public function pubFails(): Generator { yield 'Empty body' => ['test', '', 'E_BAD_MESSAGE PUB invalid message body size 0']; yield 'Invalid topic' => ['test$%^&', '', 'E_BAD_TOPIC PUB topic name "test$%^&" is not valid']; } }