Search code examples
middlewarelumenlumen-5.8

Skip authorization while unit testing in Lumen


Is there a way to skip Authorization middleware when running unit testing for a Lumen application?


Solution

  • At the top of the test case add the following:

    <?php
    
    use Laravel\Lumen\Testing\WithoutMiddleware;
    
    class MyTest extends TestCase
    {
        use WithoutMiddleware;
    ...
    

    When you run unit testing again the test case will run the application without the middleware.