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

Commitca46f10

Browse files
committed
bug#40982 [Notifier] Fix return SentMessage then Messenger not used (WaylandAce)
This PR was merged into the 5.2 branch.Discussion----------[Notifier] Fix return SentMessage then Messenger not used| Q | A| ------------- | ---| Branch? | 5.2| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets | --| License | MIT| Doc PR | --#37748 Broke the Notifier when Transport not used.Commits-------1245114 [Notifier] Fix return SentMessage then Messenger not used
2 parents3f57255 +1245114 commitca46f10

File tree

5 files changed

+129
-7
lines changed

5 files changed

+129
-7
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: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
namespaceSymfony\Component\Notifier\Tests;
4+
5+
usePHPUnit\Framework\MockObject\MockObject;
6+
usePHPUnit\Framework\TestCase;
7+
useSymfony\Component\Messenger\Envelope;
8+
useSymfony\Component\Messenger\MessageBusInterface;
9+
useSymfony\Component\Notifier\Chatter;
10+
useSymfony\Component\Notifier\Message\SentMessage;
11+
useSymfony\Component\Notifier\Tests\Transport\DummyMessage;
12+
useSymfony\Component\Notifier\Transport\TransportInterface;
13+
14+
class ChatterTestextends TestCase
15+
{
16+
/** @var MockObject&TransportInterface */
17+
private$transport;
18+
19+
/** @var MockObject&MessageBusInterface */
20+
private$bus;
21+
22+
protectedfunctionsetUp():void
23+
{
24+
$this->transport =$this->createMock(TransportInterface::class);
25+
$this->bus =$this->createMock(MessageBusInterface::class);
26+
}
27+
28+
publicfunctiontestSendWithoutBus()
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+
$chatter =newChatter($this->transport);
41+
$this->assertSame($sentMessage,$chatter->send($message));
42+
$this->assertSame($message,$sentMessage->getOriginalMessage());
43+
}
44+
45+
publicfunctiontestSendWithBus()
46+
{
47+
$message =newDummyMessage();
48+
49+
$this->transport
50+
->expects($this->never())
51+
->method('send')
52+
->with($message);
53+
54+
$this->bus
55+
->expects($this->once())
56+
->method('dispatch')
57+
->with($message)
58+
->willReturn(newEnvelope(new \stdClass()));
59+
60+
$chatter =newChatter($this->transport,$this->bus);
61+
$this->assertNull($chatter->send($message));
62+
}
63+
}
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\Envelope;
8+
useSymfony\Component\Messenger\MessageBusInterface;
9+
useSymfony\Component\Notifier\Message\SentMessage;
10+
useSymfony\Component\Notifier\Tests\Transport\DummyMessage;
11+
useSymfony\Component\Notifier\Texter;
12+
useSymfony\Component\Notifier\Transport\TransportInterface;
13+
14+
class TexterTestextends TestCase
15+
{
16+
/** @var MockObject&TransportInterface */
17+
private$transport;
18+
19+
/** @var MockObject&MessageBusInterface */
20+
private$bus;
21+
22+
protectedfunctionsetUp():void
23+
{
24+
$this->transport =$this->createMock(TransportInterface::class);
25+
$this->bus =$this->createMock(MessageBusInterface::class);
26+
}
27+
28+
publicfunctiontestSendWithoutBus()
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+
$texter =newTexter($this->transport);
40+
$this->assertSame($sentMessage,$texter->send($message));
41+
$this->assertSame($message,$sentMessage->getOriginalMessage());
42+
}
43+
44+
publicfunctiontestSendWithBus()
45+
{
46+
$message =newDummyMessage();
47+
48+
$this->transport
49+
->expects($this->never())
50+
->method('send')
51+
->with($message);
52+
53+
$this->bus
54+
->expects($this->once())
55+
->method('dispatch')
56+
->with($message)
57+
->willReturn(newEnvelope(new \stdClass()));
58+
59+
$texter =newTexter($this->transport,$this->bus);
60+
$this->assertNull($texter->send($message));
61+
}
62+
}

‎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) {

‎src/Symfony/Component/Notifier/composer.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
},
2323
"require-dev": {
2424
"symfony/event-dispatcher-contracts":"^2",
25-
"symfony/http-client-contracts":"^2"
25+
"symfony/http-client-contracts":"^2",
26+
"symfony/messenger":"^4.4 || ^5.0"
2627
},
2728
"conflict": {
2829
"symfony/http-kernel":"<4.4",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp