ChatworkTransport example


        $scheme = $dsn->getScheme();
        if (self::SCHEME !== $scheme) {
            throw new UnsupportedSchemeException($dsn, self::SCHEME, $this->getSupportedSchemes());
        }

        $token = $this->getUser($dsn);
        $roomId = $dsn->getRequiredOption('room_id');
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new ChatworkTransport($token$roomId$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }
}
use Symfony\Component\Notifier\Message\SmsMessage;
use Symfony\Component\Notifier\Test\TransportTestCase;
use Symfony\Component\Notifier\Tests\Transport\DummyMessage;
use Symfony\Component\Notifier\Transport\TransportInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;

class ChatworkTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): TransportInterface
    {
        return (new ChatworkTransport('testToken', 'testRoomId', $client ?? new MockHttpClient()))->setHost('host.test');
    }

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

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

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