Skip to content

Commit

Permalink
Add reset message queues before scenario with zentruck/messenger-test
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiidonii committed Oct 20, 2024
1 parent d10f1b7 commit af563da
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/TransportRetrieverTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace BehatMessengerContext\Tests;

use BehatMessengerContext\Context\TransportRetriever;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Transport\InMemory\InMemoryTransport;
use Symfony\Contracts\Service\ServiceProviderInterface;

final class TransportRetrieverTest extends TestCase
{
public function testGetTransportsSuccessfully(): void
{
$inMemoryTransport = $this->createMock(InMemoryTransport::class);
$serviceProvider = $this->createMock(ServiceProviderInterface::class);
$serviceProvider
->expects($this->once())
->method('getProvidedServices')
->willReturn(['messenger.transport.test']);

$serviceProvider
->expects(self::once())
->method('get')
->with('messenger.transport.test')
->willReturn($inMemoryTransport);

$transportRetriever = new TransportRetriever($serviceProvider);

self::assertEquals(
['messenger.transport.test' => $inMemoryTransport],
$transportRetriever->getAllTransports(),
);
}
}

0 comments on commit af563da

Please sign in to comment.