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

[5.5] Add withMiddleware function in MakesHttpRequests #22060

Merged

Conversation

mathieutu
Copy link
Contributor

Hi.
This PR adds a withMiddleware method, as the inverse of withoutMiddleware one.

Example:

I have a middleware applied to all my application. I want to deactivate this middleware during the tests:

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication, RefreshDatabase;

    protected function setUp()
    {
        parent::setUp();
        
        $this->withoutMiddleware(MyMiddleware::class);
    }
}

But, just in some tests, where the middleware is needed, I would like to re-enable it:

public function testThatMyMiddlewareIsApplied() {
        $this->withMiddleware(MyMiddleware::class);
        // my test
}

It's kind the same than withExceptionHandling method.

It's fully tested, and I've taken this opportunity to add some tests for the withoutMiddleware existing method.

Thanks for your answer.

@mathieutu mathieutu changed the title Add withMiddleware function in MakesHttpRequests [5.5] Add withMiddleware function in MakesHttpRequests Nov 13, 2017
@taylorotwell taylorotwell merged commit 47a543f into laravel:5.5 Nov 13, 2017
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.

2 participants