TestQueryBus example

use Symfony\Component\Messenger\MessageBus;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\Stamp\HandledStamp;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;

class HandleTraitTest extends TestCase
{
    public function testItThrowsOnNoMessageBusInstance()
    {
        $this->expectException(LogicException::class);
        $this->expectExceptionMessage('You must provide a "Symfony\Component\Messenger\MessageBusInterface" instance in the "Symfony\Component\Messenger\Tests\TestQueryBus::$messageBus" property, but that property has not been initialized yet.');
        $queryBus = new TestQueryBus(null);
        $query = new DummyMessage('Hello');

        $queryBus->query($query);
    }

    public function testHandleReturnsHandledStampResult()
    {
        $bus = $this->createMock(MessageBus::class);
        $queryBus = new TestQueryBus($bus);

        $query = new DummyMessage('Hello');
        
Home | Imprint | This part of the site doesn't use cookies.