Skip to content

[12.x] Option to disable dispatchAfterResponse in a test #55456

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

Open
wants to merge 1 commit into
base: 12.x
Choose a base branch
from

Conversation

gdebrauwer
Copy link
Contributor

When you use afterResponse() on a job in route and you want to test that job, then there is currently no easy way to do this because the job will never be executed in the test.

/** @test */
public function some_job()
{
    dispatch(function () {
         // will not be executed when running the test
    })->afterResponse();
}

This PR fixes that by providing an option to disable (similar to withoutDefer)

/** @test */
public function some_job()
{
    Bus::disableDispatchingAfterResponse();

    dispatch(function () {
         // will be executed when running the test
    })->afterResponse();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant