MattermostTransport example

if ('mattermost' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'mattermost', $this->getSupportedSchemes());
        }

        $path = $dsn->getPath();
        $token = $this->getUser($dsn);
        $channel = $dsn->getRequiredOption('channel');
        $host = $dsn->getHost();
        $port = $dsn->getPort();

        return (new MattermostTransport($token$channel$path$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    protected function getSupportedSchemes(): array
    {
        return ['mattermost'];
    }
}
use Symfony\Component\Notifier\Test\TransportTestCase;
use Symfony\Component\Notifier\Tests\Transport\DummyMessage;
use Symfony\Contracts\HttpClient\HttpClientInterface;

/** * @author Oskar Stark <oskarstark@googlemail.com> */
final class MattermostTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): MattermostTransport
    {
        return (new MattermostTransport('testAccessToken', 'testChannel', null, $client ?? new MockHttpClient()))->setHost('host.test');
    }

    public static function toStringProvider(): iterable
    {
        yield ['mattermost://host.test?channel=testChannel', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
    }

    
Home | Imprint | This part of the site doesn't use cookies.