Skip to content
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

test: Test SendMessageToTransportsEventListener #7

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Tienvx\Bundle\PactProviderBundle\Tests\Unit\EventListener;

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Event\SendMessageToTransportsEvent;
use Tienvx\Bundle\PactMessengerBundle\EventListener\SendMessageToTransportsEventListener;
use Tienvx\Bundle\PactMessengerBundle\Service\EnvelopeCollectorInterface;
use Tienvx\Bundle\PactMessengerBundle\Tests\TestApplication\Message\UserCreated;

class SendMessageToTransportsEventListenerTest extends TestCase
{
private SendMessageToTransportsEventListener $listener;
protected EnvelopeCollectorInterface|MockObject $collector;

protected function setUp(): void
{
$this->collector = $this->createMock(EnvelopeCollectorInterface::class);
$this->listener = new SendMessageToTransportsEventListener($this->collector);
}

public function testCollect(): void
{
$event = new SendMessageToTransportsEvent($envelop = new Envelope(new UserCreated(123)), ['async']);
$this->collector
->expects($this->once())
->method('collect')
->with($envelop);
call_user_func($this->listener, $event);
}
}