-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Notifier] Fix return SentMessage then Messenger not used #40982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
OskarStark
merged 1 commit into
symfony:5.2
from
WaylandAce:fix/notifier_null_sentmessage
May 7, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Notifier] Fix return SentMessage then Messenger not used
- Loading branch information
commit 12451142576e7c3bd7c97e9ac93bbb1c07b90420
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\Notifier\Tests; | ||
|
||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Messenger\Envelope; | ||
use Symfony\Component\Messenger\MessageBusInterface; | ||
WaylandAce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
use Symfony\Component\Notifier\Chatter; | ||
use Symfony\Component\Notifier\Message\SentMessage; | ||
use Symfony\Component\Notifier\Tests\Transport\DummyMessage; | ||
use Symfony\Component\Notifier\Transport\TransportInterface; | ||
|
||
class ChatterTest extends TestCase | ||
{ | ||
/** @var MockObject&TransportInterface */ | ||
private $transport; | ||
|
||
/** @var MockObject&MessageBusInterface */ | ||
WaylandAce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private $bus; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->transport = $this->createMock(TransportInterface::class); | ||
$this->bus = $this->createMock(MessageBusInterface::class); | ||
} | ||
|
||
public function testSendWithoutBus() | ||
{ | ||
$message = new DummyMessage(); | ||
|
||
$sentMessage = new SentMessage($message, 'any'); | ||
|
||
$this->transport | ||
->expects($this->once()) | ||
->method('send') | ||
->with($message) | ||
->willReturn($sentMessage); | ||
|
||
$chatter = new Chatter($this->transport); | ||
$this->assertSame($sentMessage, $chatter->send($message)); | ||
$this->assertSame($message, $sentMessage->getOriginalMessage()); | ||
} | ||
|
||
public function testSendWithBus() | ||
{ | ||
$message = new DummyMessage(); | ||
|
||
$this->transport | ||
->expects($this->never()) | ||
->method('send') | ||
->with($message); | ||
|
||
$this->bus | ||
->expects($this->once()) | ||
->method('dispatch') | ||
->with($message) | ||
->willReturn(new Envelope(new \stdClass())); | ||
|
||
$chatter = new Chatter($this->transport, $this->bus); | ||
$this->assertNull($chatter->send($message)); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\Notifier\Tests; | ||
|
||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Messenger\Envelope; | ||
use Symfony\Component\Messenger\MessageBusInterface; | ||
use Symfony\Component\Notifier\Message\SentMessage; | ||
use Symfony\Component\Notifier\Tests\Transport\DummyMessage; | ||
use Symfony\Component\Notifier\Texter; | ||
use Symfony\Component\Notifier\Transport\TransportInterface; | ||
|
||
class TexterTest extends TestCase | ||
{ | ||
/** @var MockObject&TransportInterface */ | ||
private $transport; | ||
WaylandAce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** @var MockObject&MessageBusInterface */ | ||
WaylandAce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private $bus; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->transport = $this->createMock(TransportInterface::class); | ||
$this->bus = $this->createMock(MessageBusInterface::class); | ||
} | ||
|
||
public function testSendWithoutBus() | ||
{ | ||
$message = new DummyMessage(); | ||
$sentMessage = new SentMessage($message, 'any'); | ||
|
||
$this->transport | ||
->expects($this->once()) | ||
->method('send') | ||
->with($message) | ||
->willReturn($sentMessage); | ||
|
||
$texter = new Texter($this->transport); | ||
$this->assertSame($sentMessage, $texter->send($message)); | ||
$this->assertSame($message, $sentMessage->getOriginalMessage()); | ||
} | ||
|
||
public function testSendWithBus() | ||
{ | ||
$message = new DummyMessage(); | ||
|
||
$this->transport | ||
->expects($this->never()) | ||
->method('send') | ||
->with($message); | ||
|
||
$this->bus | ||
->expects($this->once()) | ||
->method('dispatch') | ||
->with($message) | ||
->willReturn(new Envelope(new \stdClass())); | ||
|
||
$texter = new Texter($this->transport, $this->bus); | ||
$this->assertNull($texter->send($message)); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.