Merge branch '5.1' into 5.2
* 5.1: [Notifier] Improve tests (5.1) [Notifier] Fix wrong package names [Notifier] [Free Mobile] Could not use custom host in DSN
This commit is contained in:
commit
904b05a0de
@ -25,8 +25,7 @@ final class FirebaseTransportFactoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$transport = $factory->create(Dsn::fromString('firebase://username:password@default'));
|
$transport = $factory->create(Dsn::fromString('firebase://username:password@host.test'));
|
||||||
$transport->setHost('host.test');
|
|
||||||
|
|
||||||
$this->assertSame('firebase://host.test', (string) $transport);
|
$this->assertSame('firebase://host.test', (string) $transport);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
|
|||||||
*/
|
*/
|
||||||
final class FreeMobileTransport extends AbstractTransport
|
final class FreeMobileTransport extends AbstractTransport
|
||||||
{
|
{
|
||||||
protected const HOST = 'https://smsapi.free-mobile.fr/sendmsg';
|
protected const HOST = 'smsapi.free-mobile.fr/sendmsg';
|
||||||
|
|
||||||
private $login;
|
private $login;
|
||||||
private $password;
|
private $password;
|
||||||
@ -58,7 +58,9 @@ final class FreeMobileTransport extends AbstractTransport
|
|||||||
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given) and configured with your phone number.', __CLASS__, SmsMessage::class, \get_class($message)));
|
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given) and configured with your phone number.', __CLASS__, SmsMessage::class, \get_class($message)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->client->request('POST', $this->getEndpoint(), [
|
$endpoint = sprintf('https://%s', $this->getEndpoint());
|
||||||
|
|
||||||
|
$response = $this->client->request('POST', $endpoint, [
|
||||||
'json' => [
|
'json' => [
|
||||||
'user' => $this->login,
|
'user' => $this->login,
|
||||||
'pass' => $this->password,
|
'pass' => $this->password,
|
||||||
|
@ -43,7 +43,10 @@ final class FreeMobileTransportFactory extends AbstractTransportFactory
|
|||||||
throw new IncompleteDsnException('Missing phone.', $dsn->getOriginalDsn());
|
throw new IncompleteDsnException('Missing phone.', $dsn->getOriginalDsn());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FreeMobileTransport($login, $password, $phone, $this->client, $this->dispatcher);
|
$host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
|
||||||
|
$port = $dsn->getPort();
|
||||||
|
|
||||||
|
return (new FreeMobileTransport($login, $password, $phone, $this->client, $this->dispatcher))->setHost($host)->setPort($port);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getSupportedSchemes(): array
|
protected function getSupportedSchemes(): array
|
||||||
|
@ -23,9 +23,7 @@ final class FreeMobileTransportFactoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$dsn = 'freemobile://login:pass@default?phone=0611223344';
|
$transport = $factory->create(Dsn::fromString('freemobile://login:pass@host.test?phone=0611223344'));
|
||||||
$transport = $factory->create(Dsn::fromString($dsn));
|
|
||||||
$transport->setHost('host.test');
|
|
||||||
|
|
||||||
$this->assertSame('freemobile://host.test?phone=0611223344', (string) $transport);
|
$this->assertSame('freemobile://host.test?phone=0611223344', (string) $transport);
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,9 @@ final class MattermostTransportFactoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$accessToken = 'testAccessToken';
|
$transport = $factory->create(Dsn::fromString('mattermost://accessToken@host.test?channel=testChannel'));
|
||||||
$host = 'testHost';
|
|
||||||
$channel = 'testChannel';
|
|
||||||
|
|
||||||
$transport = $factory->create(Dsn::fromString(sprintf('mattermost://%s@%s/?channel=%s', $accessToken, $host, $channel)));
|
$this->assertSame('mattermost://host.test?channel=testChannel', (string) $transport);
|
||||||
|
|
||||||
$this->assertSame(sprintf('mattermost://%s?channel=%s', $host, $channel), (string) $transport);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateWithMissingOptionChannelThrowsIncompleteDsnException()
|
public function testCreateWithMissingOptionChannelThrowsIncompleteDsnException()
|
||||||
@ -49,21 +45,21 @@ final class MattermostTransportFactoryTest extends TestCase
|
|||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$this->expectException(IncompleteDsnException::class);
|
$this->expectException(IncompleteDsnException::class);
|
||||||
$factory->create(Dsn::fromString(sprintf('mattermost://%s/?channel=%s', 'testHost', 'testChannel')));
|
$factory->create(Dsn::fromString('mattermost://host.test?channel=testChannel'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSupportsReturnsTrueWithSupportedScheme()
|
public function testSupportsReturnsTrueWithSupportedScheme()
|
||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$this->assertTrue($factory->supports(Dsn::fromString('mattermost://token@host/?channel=testChannel')));
|
$this->assertTrue($factory->supports(Dsn::fromString('mattermost://token@host?channel=testChannel')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSupportsReturnsFalseWithUnsupportedScheme()
|
public function testSupportsReturnsFalseWithUnsupportedScheme()
|
||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$this->assertFalse($factory->supports(Dsn::fromString('somethingElse://token@host/?channel=testChannel')));
|
$this->assertFalse($factory->supports(Dsn::fromString('somethingElse://token@host?channel=testChannel')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUnsupportedSchemeThrowsUnsupportedSchemeException()
|
public function testUnsupportedSchemeThrowsUnsupportedSchemeException()
|
||||||
@ -72,7 +68,7 @@ final class MattermostTransportFactoryTest extends TestCase
|
|||||||
|
|
||||||
$this->expectException(UnsupportedSchemeException::class);
|
$this->expectException(UnsupportedSchemeException::class);
|
||||||
|
|
||||||
$factory->create(Dsn::fromString('somethingElse://token@host/?channel=testChannel'));
|
$factory->create(Dsn::fromString('somethingElse://token@host?channel=testChannel'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUnsupportedSchemeThrowsUnsupportedSchemeExceptionEvenIfRequiredOptionIsMissing()
|
public function testUnsupportedSchemeThrowsUnsupportedSchemeExceptionEvenIfRequiredOptionIsMissing()
|
||||||
|
@ -38,7 +38,7 @@ final class MattermostTransportTest extends TestCase
|
|||||||
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
|
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSendNonChatMessageThrows()
|
public function testSendNonChatMessageThrowsLogicException()
|
||||||
{
|
{
|
||||||
$transport = $this->createTransport();
|
$transport = $this->createTransport();
|
||||||
|
|
||||||
|
@ -23,9 +23,7 @@ final class NexmoTransportFactoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$dsn = 'nexmo://apiKey:apiSecret@default?from=0611223344';
|
$transport = $factory->create(Dsn::fromString('nexmo://apiKey:apiSecret@host.test?from=0611223344'));
|
||||||
$transport = $factory->create(Dsn::fromString($dsn));
|
|
||||||
$transport->setHost('host.test');
|
|
||||||
|
|
||||||
$this->assertSame('nexmo://host.test?from=0611223344', (string) $transport);
|
$this->assertSame('nexmo://host.test?from=0611223344', (string) $transport);
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,7 @@ final class OvhCloudTransportFactoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$dsn = 'ovhcloud://applicationKey:applicationSecret@default?consumer_key=consumerKey&service_name=serviceName';
|
$transport = $factory->create(Dsn::fromString('ovhcloud://applicationKey:applicationSecret@host.test?consumer_key=consumerKey&service_name=serviceName'));
|
||||||
$transport = $factory->create(Dsn::fromString($dsn));
|
|
||||||
$transport->setHost('host.test');
|
|
||||||
|
|
||||||
$this->assertSame('ovhcloud://host.test?consumer_key=consumerKey&service_name=serviceName', (string) $transport);
|
$this->assertSame('ovhcloud://host.test?consumer_key=consumerKey&service_name=serviceName', (string) $transport);
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,9 @@ final class RocketChatTransportFactoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$accessToken = 'testAccessToken';
|
$transport = $factory->create(Dsn::fromString('rocketchat://accessToken@host.test?channel=testChannel'));
|
||||||
$host = 'testHost';
|
|
||||||
$channel = 'testChannel';
|
|
||||||
|
|
||||||
$transport = $factory->create(Dsn::fromString(sprintf('rocketchat://%s@%s/?channel=%s', $accessToken, $host, $channel)));
|
$this->assertSame('rocketchat://host.test?channel=testChannel', (string) $transport);
|
||||||
|
|
||||||
$this->assertSame(sprintf('rocketchat://%s?channel=%s', $host, $channel), (string) $transport);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateWithNoTokenThrowsIncompleteDsnException()
|
public function testCreateWithNoTokenThrowsIncompleteDsnException()
|
||||||
@ -40,21 +36,21 @@ final class RocketChatTransportFactoryTest extends TestCase
|
|||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$this->expectException(IncompleteDsnException::class);
|
$this->expectException(IncompleteDsnException::class);
|
||||||
$factory->create(Dsn::fromString(sprintf('rocketchat://%s/?channel=%s', 'testHost', 'testChannel')));
|
$factory->create(Dsn::fromString('rocketchat://host.test?channel=testChannel'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSupportsReturnsTrueWithSupportedScheme()
|
public function testSupportsReturnsTrueWithSupportedScheme()
|
||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$this->assertTrue($factory->supports(Dsn::fromString('rocketchat://token@host/?channel=testChannel')));
|
$this->assertTrue($factory->supports(Dsn::fromString('rocketchat://token@host?channel=testChannel')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSupportsReturnsFalseWithUnsupportedScheme()
|
public function testSupportsReturnsFalseWithUnsupportedScheme()
|
||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$this->assertFalse($factory->supports(Dsn::fromString('somethingElse://token@host/?channel=testChannel')));
|
$this->assertFalse($factory->supports(Dsn::fromString('somethingElse://token@host?channel=testChannel')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUnsupportedSchemeThrowsUnsupportedSchemeException()
|
public function testUnsupportedSchemeThrowsUnsupportedSchemeException()
|
||||||
@ -63,7 +59,7 @@ final class RocketChatTransportFactoryTest extends TestCase
|
|||||||
|
|
||||||
$this->expectException(UnsupportedSchemeException::class);
|
$this->expectException(UnsupportedSchemeException::class);
|
||||||
|
|
||||||
$factory->create(Dsn::fromString('somethingElse://token@host/?channel=testChannel'));
|
$factory->create(Dsn::fromString('somethingElse://token@host?channel=testChannel'));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createFactory(): RocketChatTransportFactory
|
private function createFactory(): RocketChatTransportFactory
|
||||||
|
@ -38,7 +38,7 @@ final class RocketChatTransportTest extends TestCase
|
|||||||
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
|
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSendNonChatMessageThrows()
|
public function testSendNonChatMessageThrowsLogicException()
|
||||||
{
|
{
|
||||||
$transport = $this->createTransport();
|
$transport = $this->createTransport();
|
||||||
|
|
||||||
|
@ -23,9 +23,7 @@ final class SinchTransportFactoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$dsn = 'sinch://accountSid:authToken@default?from=0611223344';
|
$transport = $factory->create(Dsn::fromString('sinch://accountSid:authToken@host.test?from=0611223344'));
|
||||||
$transport = $factory->create(Dsn::fromString($dsn));
|
|
||||||
$transport->setHost('host.test');
|
|
||||||
|
|
||||||
$this->assertSame('sinch://host.test?from=0611223344', (string) $transport);
|
$this->assertSame('sinch://host.test?from=0611223344', (string) $transport);
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,12 @@ final class SlackTransportFactoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
$factory = new SlackTransportFactory();
|
$factory = new SlackTransportFactory();
|
||||||
|
|
||||||
$host = 'testHost';
|
$transport = $factory->create(Dsn::fromString('slack://testUser@testHost/?channel=testChannel'));
|
||||||
$channel = 'testChannel';
|
|
||||||
$transport = $factory->create(Dsn::fromString(sprintf('slack://testUser@%s/?channel=%s', $host, $channel)));
|
|
||||||
|
|
||||||
$this->assertSame(sprintf('slack://%s?channel=%s', $host, $channel), (string) $transport);
|
$this->assertSame('slack://testHost?channel=testChannel', (string) $transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateWithDeprecatedDsn(): void
|
public function testCreateWithDeprecatedDsn()
|
||||||
{
|
{
|
||||||
$this->expectException(InvalidArgumentException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
$this->expectExceptionMessage('Support for Slack webhook DSN has been dropped since 5.2 (maybe you haven\'t updated the DSN when upgrading from 5.1).');
|
$this->expectExceptionMessage('Support for Slack webhook DSN has been dropped since 5.2 (maybe you haven\'t updated the DSN when upgrading from 5.1).');
|
||||||
@ -40,7 +38,7 @@ final class SlackTransportFactoryTest extends TestCase
|
|||||||
$factory->create(Dsn::fromString('slack://default/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX'));
|
$factory->create(Dsn::fromString('slack://default/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateWithNoTokenThrowsMalformed(): void
|
public function testCreateWithNoTokenThrowsMalformed()
|
||||||
{
|
{
|
||||||
$factory = new SlackTransportFactory();
|
$factory = new SlackTransportFactory();
|
||||||
|
|
||||||
|
@ -28,13 +28,12 @@ final class SlackTransportTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testToStringContainsProperties()
|
public function testToStringContainsProperties()
|
||||||
{
|
{
|
||||||
$host = 'testHost';
|
|
||||||
$channel = 'test Channel'; // invalid channel name to test url encoding of the channel
|
$channel = 'test Channel'; // invalid channel name to test url encoding of the channel
|
||||||
|
|
||||||
$transport = new SlackTransport('testToken', $channel, $this->createMock(HttpClientInterface::class));
|
$transport = new SlackTransport('testToken', $channel, $this->createMock(HttpClientInterface::class));
|
||||||
$transport->setHost('testHost');
|
$transport->setHost('testHost');
|
||||||
|
|
||||||
$this->assertSame(sprintf('slack://%s?channel=%s', $host, urlencode($channel)), (string) $transport);
|
$this->assertSame('slack://testHost?channel=test+Channel', (string) $transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSupportsChatMessage()
|
public function testSupportsChatMessage()
|
||||||
@ -45,7 +44,7 @@ final class SlackTransportTest extends TestCase
|
|||||||
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
|
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSendNonChatMessageThrows()
|
public function testSendNonChatMessageThrowsLogicException()
|
||||||
{
|
{
|
||||||
$this->expectException(LogicException::class);
|
$this->expectException(LogicException::class);
|
||||||
|
|
||||||
|
@ -23,12 +23,9 @@ final class TelegramTransportFactoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$host = 'testHost';
|
$transport = $factory->create(Dsn::fromString('telegram://user:password@host.test?channel=testChannel'));
|
||||||
$channel = 'testChannel';
|
|
||||||
|
|
||||||
$transport = $factory->create(Dsn::fromString(sprintf('telegram://%s@%s/?channel=%s', 'testUser:testPassword', $host, $channel)));
|
$this->assertSame('telegram://host.test?channel=testChannel', (string) $transport);
|
||||||
|
|
||||||
$this->assertSame(sprintf('telegram://%s?channel=%s', $host, $channel), (string) $transport);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateWithNoPasswordThrowsIncompleteDsnException()
|
public function testCreateWithNoPasswordThrowsIncompleteDsnException()
|
||||||
@ -36,7 +33,7 @@ final class TelegramTransportFactoryTest extends TestCase
|
|||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$this->expectException(IncompleteDsnException::class);
|
$this->expectException(IncompleteDsnException::class);
|
||||||
$factory->create(Dsn::fromString(sprintf('telegram://%s@%s/?channel=%s', 'simpleToken', 'testHost', 'testChannel')));
|
$factory->create(Dsn::fromString('telegram://simpleToken@host.test?channel=testChannel'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateWithNoTokenThrowsIncompleteDsnException()
|
public function testCreateWithNoTokenThrowsIncompleteDsnException()
|
||||||
@ -44,21 +41,21 @@ final class TelegramTransportFactoryTest extends TestCase
|
|||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$this->expectException(IncompleteDsnException::class);
|
$this->expectException(IncompleteDsnException::class);
|
||||||
$factory->create(Dsn::fromString(sprintf('telegram://%s/?channel=%s', 'testHost', 'testChannel')));
|
$factory->create(Dsn::fromString('telegram://host.test?channel=testChannel'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSupportsReturnsTrueWithSupportedScheme()
|
public function testSupportsReturnsTrueWithSupportedScheme()
|
||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$this->assertTrue($factory->supports(Dsn::fromString('telegram://host/?channel=testChannel')));
|
$this->assertTrue($factory->supports(Dsn::fromString('telegram://host?channel=testChannel')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSupportsReturnsFalseWithUnsupportedScheme()
|
public function testSupportsReturnsFalseWithUnsupportedScheme()
|
||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$this->assertFalse($factory->supports(Dsn::fromString('somethingElse://host/?channel=testChannel')));
|
$this->assertFalse($factory->supports(Dsn::fromString('somethingElse://host?channel=testChannel')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUnsupportedSchemeThrowsUnsupportedSchemeException()
|
public function testUnsupportedSchemeThrowsUnsupportedSchemeException()
|
||||||
@ -67,7 +64,7 @@ final class TelegramTransportFactoryTest extends TestCase
|
|||||||
|
|
||||||
$this->expectException(UnsupportedSchemeException::class);
|
$this->expectException(UnsupportedSchemeException::class);
|
||||||
|
|
||||||
$factory->create(Dsn::fromString('somethingElse://user:pwd@host/?channel=testChannel'));
|
$factory->create(Dsn::fromString('somethingElse://user:pwd@host?channel=testChannel'));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createFactory(): TelegramTransportFactory
|
private function createFactory(): TelegramTransportFactory
|
||||||
|
@ -26,26 +26,24 @@ final class TelegramTransportTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testToStringContainsProperties()
|
public function testToStringContainsProperties()
|
||||||
{
|
{
|
||||||
$channel = 'testChannel';
|
$transport = $this->createTransport();
|
||||||
|
|
||||||
$transport = new TelegramTransport('testToken', $channel, $this->createMock(HttpClientInterface::class));
|
$this->assertSame('telegram://host.test?channel=testChannel', (string) $transport);
|
||||||
$transport->setHost('host.test');
|
|
||||||
|
|
||||||
$this->assertSame(sprintf('telegram://%s?channel=%s', 'host.test', $channel), (string) $transport);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSupportsChatMessage()
|
public function testSupportsChatMessage()
|
||||||
{
|
{
|
||||||
$transport = new TelegramTransport('testToken', 'testChannel', $this->createMock(HttpClientInterface::class));
|
$transport = $this->createTransport();
|
||||||
|
|
||||||
$this->assertTrue($transport->supports(new ChatMessage('testChatMessage')));
|
$this->assertTrue($transport->supports(new ChatMessage('testChatMessage')));
|
||||||
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
|
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSendNonChatMessageThrows()
|
public function testSendNonChatMessageThrowsLogicException()
|
||||||
{
|
{
|
||||||
|
$transport = $this->createTransport();
|
||||||
|
|
||||||
$this->expectException(LogicException::class);
|
$this->expectException(LogicException::class);
|
||||||
$transport = new TelegramTransport('testToken', 'testChannel', $this->createMock(HttpClientInterface::class));
|
|
||||||
|
|
||||||
$transport->send($this->createMock(MessageInterface::class));
|
$transport->send($this->createMock(MessageInterface::class));
|
||||||
}
|
}
|
||||||
@ -67,7 +65,7 @@ final class TelegramTransportTest extends TestCase
|
|||||||
return $response;
|
return $response;
|
||||||
});
|
});
|
||||||
|
|
||||||
$transport = new TelegramTransport('testToken', 'testChannel', $client);
|
$transport = $this->createTransport('testChannel', $client);
|
||||||
|
|
||||||
$transport->send(new ChatMessage('testMessage'));
|
$transport->send(new ChatMessage('testMessage'));
|
||||||
}
|
}
|
||||||
@ -121,12 +119,12 @@ JSON;
|
|||||||
return $response;
|
return $response;
|
||||||
});
|
});
|
||||||
|
|
||||||
$transport = new TelegramTransport('testToken', $channel, $client);
|
$transport = $this->createTransport($channel, $client);
|
||||||
|
|
||||||
$sentMessage = $transport->send(new ChatMessage('testMessage'));
|
$sentMessage = $transport->send(new ChatMessage('testMessage'));
|
||||||
|
|
||||||
$this->assertEquals(1, $sentMessage->getMessageId());
|
$this->assertEquals(1, $sentMessage->getMessageId());
|
||||||
$this->assertEquals('telegram://api.telegram.org?channel=testChannel', $sentMessage->getTransport());
|
$this->assertEquals('telegram://host.test?channel=testChannel', $sentMessage->getTransport());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSendWithChannelOverride()
|
public function testSendWithChannelOverride()
|
||||||
@ -177,7 +175,7 @@ JSON;
|
|||||||
return $response;
|
return $response;
|
||||||
});
|
});
|
||||||
|
|
||||||
$transport = new TelegramTransport('testToken', 'defaultChannel', $client);
|
$transport = $this->createTransport('defaultChannel', $client);
|
||||||
|
|
||||||
$messageOptions = new TelegramOptions();
|
$messageOptions = new TelegramOptions();
|
||||||
$messageOptions->chatId($channelOverride);
|
$messageOptions->chatId($channelOverride);
|
||||||
@ -185,6 +183,11 @@ JSON;
|
|||||||
$sentMessage = $transport->send(new ChatMessage('testMessage', $messageOptions));
|
$sentMessage = $transport->send(new ChatMessage('testMessage', $messageOptions));
|
||||||
|
|
||||||
$this->assertEquals(1, $sentMessage->getMessageId());
|
$this->assertEquals(1, $sentMessage->getMessageId());
|
||||||
$this->assertEquals('telegram://api.telegram.org?channel=defaultChannel', $sentMessage->getTransport());
|
$this->assertEquals('telegram://host.test?channel=defaultChannel', $sentMessage->getTransport());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createTransport($channel = 'testChannel', ?HttpClientInterface $client = null): TelegramTransport
|
||||||
|
{
|
||||||
|
return (new TelegramTransport('token', $channel, $client ?: $this->createMock(HttpClientInterface::class)))->setHost('host.test');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,7 @@ final class TwilioTransportFactoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
$factory = $this->createFactory();
|
$factory = $this->createFactory();
|
||||||
|
|
||||||
$dsn = 'twilio://accountSid:authToken@default?from=0611223344';
|
$transport = $factory->create(Dsn::fromString('twilio://accountSid:authToken@host.test?from=0611223344'));
|
||||||
$transport = $factory->create(Dsn::fromString($dsn));
|
|
||||||
$transport->setHost('host.test');
|
|
||||||
|
|
||||||
$this->assertSame('twilio://host.test?from=0611223344', (string) $transport);
|
$this->assertSame('twilio://host.test?from=0611223344', (string) $transport);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class UnsupportedSchemeException extends LogicException
|
|||||||
],
|
],
|
||||||
'rocketchat' => [
|
'rocketchat' => [
|
||||||
'class' => Bridge\RocketChat\RocketChatTransportFactory::class,
|
'class' => Bridge\RocketChat\RocketChatTransportFactory::class,
|
||||||
'package' => 'rocketchat-notifier',
|
'package' => 'symfony/rocket-chat-notifier',
|
||||||
],
|
],
|
||||||
'twilio' => [
|
'twilio' => [
|
||||||
'class' => Bridge\Twilio\TwilioTransportFactory::class,
|
'class' => Bridge\Twilio\TwilioTransportFactory::class,
|
||||||
@ -64,7 +64,7 @@ class UnsupportedSchemeException extends LogicException
|
|||||||
],
|
],
|
||||||
'ovhcloud' => [
|
'ovhcloud' => [
|
||||||
'class' => Bridge\OvhCloud\OvhCloudTransportFactory::class,
|
'class' => Bridge\OvhCloud\OvhCloudTransportFactory::class,
|
||||||
'package' => 'symfony/ovhcloud-notifier',
|
'package' => 'symfony/ovh-cloud-notifier',
|
||||||
],
|
],
|
||||||
'sinch' => [
|
'sinch' => [
|
||||||
'class' => Bridge\Sinch\SinchTransportFactory::class,
|
'class' => Bridge\Sinch\SinchTransportFactory::class,
|
||||||
|
Reference in New Issue
Block a user