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

Commit0e13d25

Browse files
committed
[Notifier] Fix return SentMessage then Messenger not used
1 parent2ad08d5 commit0e13d25

File tree

4 files changed

+125
-6
lines changed

4 files changed

+125
-6
lines changed

‎src/Symfony/Component/Notifier/Chatter.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ public function supports(MessageInterface $message): bool
5151
publicfunctionsend(MessageInterface$message): ?SentMessage
5252
{
5353
if (null ===$this->bus) {
54-
$this->transport->send($message);
55-
56-
returnnull;
54+
return$this->transport->send($message);
5755
}
5856

5957
if (null !==$this->dispatcher) {
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespaceSymfony\Component\Notifier\Tests;
4+
5+
usePHPUnit\Framework\MockObject\MockObject;
6+
usePHPUnit\Framework\TestCase;
7+
useSymfony\Component\Messenger\MessageBusInterface;
8+
useSymfony\Component\Notifier\Chatter;
9+
useSymfony\Component\Notifier\Message\SentMessage;
10+
useSymfony\Component\Notifier\Tests\Transport\DummyMessage;
11+
useSymfony\Component\Notifier\Transport\TransportInterface;
12+
13+
class ChatterTestextends TestCase
14+
{
15+
/** @var MockObject&TransportInterface */
16+
private$transport;
17+
/** @var MockObject&MessageBusInterface */
18+
private$bus;
19+
20+
protectedfunctionsetUp():void
21+
{
22+
$this->transport =$this->createMock(TransportInterface::class);
23+
$this->bus =$this->createMock(MessageBusInterface::class);
24+
}
25+
26+
publicfunctiontestSendWithoutBus()
27+
{
28+
$chatter =newChatter($this->transport);
29+
30+
$message =newDummyMessage();
31+
32+
$sentMessage =newSentMessage($message,'any');
33+
34+
$this->transport
35+
->expects($this->once())
36+
->method('send')
37+
->with($message)
38+
->willReturn($sentMessage);
39+
40+
$this->assertSame($sentMessage,$chatter->send($message));
41+
$this->assertSame($message,$sentMessage->getOriginalMessage());
42+
}
43+
44+
publicfunctiontestSendWithBus()
45+
{
46+
$chatter =newChatter($this->transport,$this->bus);
47+
48+
$message =newDummyMessage();
49+
50+
$this->transport
51+
->expects($this->once())
52+
->method('send')
53+
->with($message);
54+
55+
$this->bus
56+
->expects($this->once())
57+
->method('dispatch')
58+
->with($message);
59+
60+
$this->assertNull($chatter->send($message));
61+
}
62+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespaceSymfony\Component\Notifier\Tests;
4+
5+
usePHPUnit\Framework\MockObject\MockObject;
6+
usePHPUnit\Framework\TestCase;
7+
useSymfony\Component\Messenger\MessageBusInterface;
8+
useSymfony\Component\Notifier\Message\SentMessage;
9+
useSymfony\Component\Notifier\Tests\Transport\DummyMessage;
10+
useSymfony\Component\Notifier\Texter;
11+
useSymfony\Component\Notifier\Transport\TransportInterface;
12+
13+
class TexterTestextends TestCase
14+
{
15+
/** @var MockObject&TransportInterface */
16+
private$transport;
17+
/** @var MockObject&MessageBusInterface */
18+
private$bus;
19+
20+
protectedfunctionsetUp():void
21+
{
22+
$this->transport =$this->createMock(TransportInterface::class);
23+
$this->bus =$this->createMock(MessageBusInterface::class);
24+
}
25+
26+
publicfunctiontestSendWithoutBus()
27+
{
28+
$chatter =newTexter($this->transport);
29+
30+
$message =newDummyMessage();
31+
$sentMessage =newSentMessage($message,'any');
32+
33+
$this->transport
34+
->expects($this->once())
35+
->method('send')
36+
->with($message)
37+
->willReturn($sentMessage);
38+
39+
$this->assertSame($sentMessage,$chatter->send($message));
40+
$this->assertSame($message,$sentMessage->getOriginalMessage());
41+
}
42+
43+
publicfunctiontestSendWithBus()
44+
{
45+
$chatter =newTexter($this->transport,$this->bus);
46+
47+
$message =newDummyMessage();
48+
49+
$this->transport
50+
->expects($this->once())
51+
->method('send')
52+
->with($message);
53+
54+
$this->bus
55+
->expects($this->once())
56+
->method('dispatch')
57+
->with($message);
58+
59+
$this->assertNull($chatter->send($message));
60+
}
61+
}

‎src/Symfony/Component/Notifier/Texter.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ public function supports(MessageInterface $message): bool
5151
publicfunctionsend(MessageInterface$message): ?SentMessage
5252
{
5353
if (null ===$this->bus) {
54-
$this->transport->send($message);
55-
56-
returnnull;
54+
return$this->transport->send($message);
5755
}
5856

5957
if (null !==$this->dispatcher) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp