MercureTransport example

use Symfony\Contracts\HttpClient\HttpClientInterface;

/** * @author Mathias Arlaud <mathias.arlaud@gmail.com> */
final class MercureTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null, HubInterface $hub = null, string $hubId = 'hubId', $topics = null): MercureTransport
    {
        $hub ??= new DummyHub();

        return new MercureTransport($hub$hubId$topics);
    }

    public static function toStringProvider(): iterable
    {
        yield ['mercure://hubId?topic=https%3A%2F%2Fsymfony.com%2Fnotifier', self::createTransport()];
        yield ['mercure://customHubId?topic=%2Ftopic', self::createTransport(null, null, 'customHubId', '/topic')];
        yield ['mercure://customHubId?topic%5B0%5D=%2Ftopic%2F1&topic%5B1%5D%5B0%5D=%2Ftopic%2F2', self::createTransport(null, null, 'customHubId', ['/topic/1', ['/topic/2']])];
    }

    public static function supportedMessagesProvider(): iterable
    {
        


        $hubId = $dsn->getHost();
        $topic = $dsn->getOption('topic');

        try {
            $hub = $this->registry->getHub($hubId);
        } catch (InvalidArgumentException) {
            throw new IncompleteDsnException(sprintf('Hub "%s" not found. Did you mean one of: "%s"?', $hubIdimplode('", "', array_keys($this->registry->all()))));
        }

        return new MercureTransport($hub$hubId$topic);
    }

    protected function getSupportedSchemes(): array
    {
        return ['mercure'];
    }
}
Home | Imprint | This part of the site doesn't use cookies.