zenstruck / messenger-test

Assertions and helpers for testing your symfony/messenger queues.
MIT License
218 stars 15 forks source link

Testing failure transport #71

Open mtret opened 6 months ago

mtret commented 6 months ago

Hi, is there a way of testing whether failed messages end up in a correct failure_transport? Basically what I want to do is something like this:

public function testOrderFailure(): void {
    $this->transport('failed_order')->queue()->assertEmpty();
    $this->transport('async_order')->queue()->assertEmpty();
    $this->transport('async_order')->send(new Envelope(new OrderPaidMessage($this->order))); 
    $this->transport('async_order')->process(); //exception will be thrown

    $this->transport('async_order')->queue()->assertEmpty();
    $this->transport('failed_order')->queue()->assertCount(1);
}

I've got ?catch_exceptions=false configured for the async_order transport-

kbond commented 5 months ago

I'd like this to be possible but haven't dug into this yet. I guess the code above doesn't work?

Related: https://github.com/zenstruck/messenger-test/issues/2

mtret commented 5 months ago

Yeah, the code does not work. Thank you though. :+1: