Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb4fdfc8

Browse files
committed
Fix compatibility with symfony/notifier 5.2
1 parent0a914ef commitb4fdfc8

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

‎src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatTransport.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
useSymfony\Component\Notifier\Exception\TransportException;
1717
useSymfony\Component\Notifier\Message\ChatMessage;
1818
useSymfony\Component\Notifier\Message\MessageInterface;
19+
useSymfony\Component\Notifier\Message\SentMessage;
1920
useSymfony\Component\Notifier\Transport\AbstractTransport;
2021
useSymfony\Contracts\EventDispatcher\EventDispatcherInterface;
2122
useSymfony\Contracts\HttpClient\HttpClientInterface;
@@ -89,7 +90,7 @@ public function supports(MessageInterface $message): bool
8990
/**
9091
* @see https://developers.google.com/hangouts/chat/how-tos/webhooks
9192
*/
92-
protectedfunctiondoSend(MessageInterface$message):void
93+
protectedfunctiondoSend(MessageInterface$message):SentMessage
9394
{
9495
if (!$messageinstanceof ChatMessage) {
9596
thrownewLogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).',__CLASS__, ChatMessage::class,\get_class($message)));
@@ -138,5 +139,10 @@ protected function doSend(MessageInterface $message): void
138139
if (!\array_key_exists('name',$result)) {
139140
thrownewTransportException(sprintf('Unable to post the Google Chat message: "%s".',$response->getContent(false)),$response);
140141
}
142+
143+
$sentMessage =newSentMessage($message, (string)$this);
144+
$sentMessage->setMessageId($result['name']);
145+
146+
return$sentMessage;
141147
}
142148
}

‎src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class GoogleChatTransportTest extends TestCase
2929
publicfunctiontestToStringContainsProperties():void
3030
{
3131
$transport =newGoogleChatTransport('My-Space','theAccessKey','theAccessToken=',$this->createMock(HttpClientInterface::class));
32-
$transport->setHost('testHost');
32+
$transport->setHost(null);
3333

34-
$this->assertSame('googlechat://theAccessKey:theAccessToken%3D@testHost/My-Space', (string)$transport);
34+
$this->assertSame('googlechat://theAccessKey:theAccessToken%3D@chat.googleapis.com/My-Space', (string)$transport);
3535
}
3636

3737
publicfunctiontestSupportsChatMessage():void
@@ -71,7 +71,9 @@ public function testSendWithEmptyArrayResponseThrows(): void
7171

7272
$transport =newGoogleChatTransport('My-Space','theAccessKey','theAccessToken=',$client);
7373

74-
$transport->send(newChatMessage('testMessage'));
74+
$sentMessage =$transport->send(newChatMessage('testMessage'));
75+
76+
$this->assertSame('spaces/My-Space/messages/abcdefg.hijklmno',$sentMessage->getMessageId());
7577
}
7678

7779
publicfunctiontestSendWithErrorResponseThrows():void
@@ -93,7 +95,9 @@ public function testSendWithErrorResponseThrows(): void
9395

9496
$transport =newGoogleChatTransport('My-Space','theAccessKey','theAccessToken=',$client);
9597

96-
$transport->send(newChatMessage('testMessage'));
98+
$sentMessage =$transport->send(newChatMessage('testMessage'));
99+
100+
$this->assertSame('spaces/My-Space/messages/abcdefg.hijklmno',$sentMessage->getMessageId());
97101
}
98102

99103
publicfunctiontestSendWithOptions():void
@@ -123,7 +127,9 @@ public function testSendWithOptions(): void
123127
$transport =newGoogleChatTransport('My-Space','theAccessKey','theAccessToken=',$client);
124128
$transport->setThreadKey('My-Thread');
125129

126-
$transport->send(newChatMessage('testMessage'));
130+
$sentMessage =$transport->send(newChatMessage('testMessage'));
131+
132+
$this->assertSame('spaces/My-Space/messages/abcdefg.hijklmno',$sentMessage->getMessageId());
127133
}
128134

129135
publicfunctiontestSendWithNotification():void
@@ -153,7 +159,9 @@ public function testSendWithNotification(): void
153159

154160
$transport =newGoogleChatTransport('My-Space','theAccessKey','theAccessToken=',$client);
155161

156-
$transport->send($chatMessage);
162+
$sentMessage =$transport->send($chatMessage);
163+
164+
$this->assertSame('spaces/My-Space/messages/abcdefg.hijklmno',$sentMessage->getMessageId());
157165
}
158166

159167
publicfunctiontestSendWithInvalidOptions():void
@@ -196,6 +204,8 @@ public function testSendWith200ResponseButNotOk(): void
196204

197205
$transport =newGoogleChatTransport('My-Space','theAccessKey','theAccessToken=',$client);
198206

199-
$transport->send(newChatMessage('testMessage'));
207+
$sentMessage =$transport->send(newChatMessage('testMessage'));
208+
209+
$this->assertSame('spaces/My-Space/messages/abcdefg.hijklmno',$sentMessage->getMessageId());
200210
}
201211
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp